Skip to content

Siddharth-Khattar/ScienceHack

Repository files navigation

ScienceHack Backend API

FastAPI backend for ScienceHack application with Google Cloud Platform deployment support.

Info: The code for the frontend is available at ScienceHack Frontend.

Quick Start

Prerequisites

  • Python 3.12+
  • Docker (optional, for containerized development)
  • Git

1. Clone and Setup

git clone <repository-url>
cd ScienceHack

2. Environment Configuration

# Copy environment template
cp .env.example .env

# Edit .env with your values
# Required: Set your OPENAI_API_KEY

Important: Update .env with your actual API keys:

OPENAI_API_KEY=your_actual_openai_api_key_here

Development Setup

Option A: Docker Development (Recommended)

macOS/Linux

# Start development server with hot reload
docker-compose up api

# Or run in background
docker-compose up -d api

Windows (WSL2)

# Ensure Docker permissions (run once)
sudo usermod -aG docker $USER
newgrp docker

# Start development server
docker-compose up api

Windows (PowerShell/CMD)

# Start development server
docker-compose up api

Option B: Local Python Development

macOS/Linux

# Create virtual environment
python3 -m venv .venv
source .venv/bin/activate

# Install dependencies
pip install -r requirements.txt

# Run development server
python main.py

Windows (PowerShell)

# Create virtual environment
python -m venv .venv
.venv\Scripts\Activate.ps1

# Install dependencies
pip install -r requirements.txt

# Run development server
python main.py

Windows (Command Prompt)

# Create virtual environment
python -m venv .venv
.venv\Scripts\activate.bat

# Install dependencies
pip install -r requirements.txt

# Run development server
python main.py

API Endpoints

  • GET / - Root endpoint
  • GET /health - Health check with system metrics

Access Your API

Environment Variables

Variable Required Default Description
ENVIRONMENT No development development or production
PORT No 8000 Server port
OPENAI_API_KEY Yes - OpenAI API key
MISTRAL_API_KEY Yes - Mistral API key
GOOGLE_API_KEY Yes - Google API key
LOG_LEVEL No DEBUG Logging level

Deployment

Google Cloud Platform

# Deploy to GCP App Engine
gcloud app deploy

# Or build Docker image
docker build -t sciencehack-api .

Production Environment

Set ENVIRONMENT=production in your deployment environment.

Troubleshooting

Docker Permission Issues (Linux/WSL)

sudo usermod -aG docker $USER
newgrp docker
# OR restart your terminal/WSL

Import Errors

# Rebuild Docker image
docker-compose build --no-cache

# Or update local dependencies
pip install -r requirements.txt --upgrade

Port Already in Use

# Kill process on port 8000
# Linux/Mac:
sudo lsof -t -i:8000 | xargs kill -9
# Windows:
netstat -ano | findstr :8000
taskkill /PID <PID> /F

Development Commands

# Stop all containers
docker-compose down

# Rebuild and start
docker-compose up --build api

# View logs
docker-compose logs -f api

# Run production mode locally
docker-compose up api-prod

About

Backend implementation of Conflicta, an AI-Powered Conflict Resolution Training Platform. Project submission to ScienceHack 2025, Munich.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •