FastAPI backend for ScienceHack application with Google Cloud Platform deployment support.
Info: The code for the frontend is available at ScienceHack Frontend.
- Python 3.12+
- Docker (optional, for containerized development)
- Git
git clone <repository-url>
cd ScienceHack# Copy environment template
cp .env.example .env
# Edit .env with your values
# Required: Set your OPENAI_API_KEYImportant: Update .env with your actual API keys:
OPENAI_API_KEY=your_actual_openai_api_key_here
# Start development server with hot reload
docker-compose up api
# Or run in background
docker-compose up -d api# Ensure Docker permissions (run once)
sudo usermod -aG docker $USER
newgrp docker
# Start development server
docker-compose up api# Start development server
docker-compose up api# Create virtual environment
python3 -m venv .venv
source .venv/bin/activate
# Install dependencies
pip install -r requirements.txt
# Run development server
python main.py# Create virtual environment
python -m venv .venv
.venv\Scripts\Activate.ps1
# Install dependencies
pip install -r requirements.txt
# Run development server
python main.py# Create virtual environment
python -m venv .venv
.venv\Scripts\activate.bat
# Install dependencies
pip install -r requirements.txt
# Run development server
python main.py- GET / - Root endpoint
- GET /health - Health check with system metrics
- Local Development: http://localhost:8000
- API Documentation: http://localhost:8000/docs (Swagger UI)
- Health Check: http://localhost:8000/health
| 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 |
# Deploy to GCP App Engine
gcloud app deploy
# Or build Docker image
docker build -t sciencehack-api .Set ENVIRONMENT=production in your deployment environment.
sudo usermod -aG docker $USER
newgrp docker
# OR restart your terminal/WSL# Rebuild Docker image
docker-compose build --no-cache
# Or update local dependencies
pip install -r requirements.txt --upgrade# Kill process on port 8000
# Linux/Mac:
sudo lsof -t -i:8000 | xargs kill -9
# Windows:
netstat -ano | findstr :8000
taskkill /PID <PID> /F# 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