Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 75 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# Git
.git/
.gitignore
.gitattributes

# Python
__pycache__/
*.py[cod]
*$py.class
*.so
.Python
*.egg
*.egg-info/
dist/
build/
pip-log.txt
pip-delete-this-directory.txt
.tox/
.nox/
.coverage
.coverage.*
htmlcov/
.pytest_cache/
.mypy_cache/
.ruff_cache/
.hypothesis/
*.cover
*.log

# Virtual environments
.venv/
venv/
ENV/
env/
env.bak/
venv.bak/

# IDE
.vscode/
.idea/
*.swp
*.swo
*~
.DS_Store

# Environment files (copy .env.example manually)
.env
.env.local
.env.*.local
.env.docker

# Tests
tests/
test_*.py
*_test.py
conftest.py

# Documentation
docs/
*.md
!README.md

# CI/CD
.github/
.gitlab-ci.yml
.travis.yml

# Docker
Dockerfile*
docker-compose*.yml
.dockerignore

# Other
*.txt
requirements*.txt
108 changes: 108 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
# ========================================
# Application Settings
# ========================================
ENVIRONMENT=development
DEBUG=true
LOG_LEVEL=INFO
LOG_FORMAT=colored

# ========================================
# API Configuration
# ========================================
# API key for authentication (optional - if not set, no auth required)
# Set this to enable authentication for your API
API_KEY=test-api-key-123

# Server configuration
HOST=0.0.0.0
PORT=8000
WORKERS=1

# API metadata
API_TITLE=Transcript Analysis API
API_VERSION=1.0.0
API_PREFIX=/api/v1

# Feature flags
ENABLE_DOCS=true
ENABLE_REQUEST_LOGGING=true
ENABLE_GZIP=true

# ========================================
# LLM Provider Configuration
# ========================================
# Provider selection: openai or groq
LLM_PROVIDER=openai

# OpenAI Configuration
OPENAI_API_KEY=sk-your-api-key-here
OPENAI_MODEL=gpt-4o
OPENAI_TIMEOUT=30
OPENAI_MAX_RETRIES=3

# Groq Configuration (automatic fallback if OpenAI key not available)
GROQ_API_KEY=gsk-your-groq-api-key-here
GROQ_MODEL=llama-3.3-70b-versatile

# ========================================
# Security Configuration
# ========================================
# Rate limiting
ENABLE_RATE_LIMITING=true
RATE_LIMIT_DEFAULT=20/minute

# Input/Output limits
MAX_INPUT_TOKENS=100000
MAX_OUTPUT_TOKENS=4000

# Security features
ENABLE_PII_DETECTION=true
ENABLE_OUTPUT_MODERATION=true

# ========================================
# Repository Backend Configuration
# ========================================
# Storage backend: memory or redis
# Use 'memory' for development/testing (data lost on restart)
# Use 'redis' for production (persistent storage)
REPOSITORY_BACKEND=redis

# ========================================
# Redis Configuration
# ========================================
# Required if REPOSITORY_BACKEND=redis
REDIS_HOST=localhost
REDIS_PORT=6379
REDIS_DB=0

# Optional Redis settings
REDIS_PASSWORD=
REDIS_MAX_CONNECTIONS=10
REDIS_TTL_SECONDS=

# Fallback IP if DNS resolution fails (optional)
REDIS_FALLBACK_IP=

# ========================================
# Analysis Configuration
# ========================================
MAX_CONCURRENT_ANALYSES=10
MAX_TRANSCRIPT_LENGTH=100000

# ========================================
# CORS Configuration
# ========================================
# Allowed origins (comma-separated or JSON array format)
CORS_ORIGINS=["http://localhost:3000","http://localhost:8000"]
CORS_ALLOW_CREDENTIALS=true
CORS_ALLOW_METHODS=["*"]
CORS_ALLOW_HEADERS=["*"]

# ========================================
# Notes
# ========================================
# 1. Copy this file to .env and fill in your actual values
# 2. Never commit .env file to version control (it's in .gitignore)
# 3. For production, set ENVIRONMENT=production and DEBUG=false
# 4. At least one LLM provider key (OpenAI or Groq) is required
# 5. If REPOSITORY_BACKEND=redis, ensure Redis is running and accessible
84 changes: 83 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,83 @@
.env
# Environment variables
.env
.env.local
.env.*.local

# Python cache and compiled files
**/__pycache__/
*.pyc
*.pyo
*.pyd
.Python
*.so
*.egg
*.egg-info/
dist/
build/

# Testing and coverage
.coverage
.coverage.*
htmlcov/
.pytest_cache/
.tox/
.nox/

# Virtual environments
venv/
ENV/
env/
.venv

# UV lock file (optional - uncomment if you want to regenerate)
# uv.lock

# IDE and editor files
.vscode/
.idea/
*.swp
*.swo
*~
.DS_Store

# Internal documentation (not for submission)
docs/
*_SUCCESS.md
*_VERIFICATION.md
*_REPORT.md
*_SUMMARY.md
*_INDEX.md
CLAUDE.md

# Tool state directories
.swarm/
.claude-flow/
.claude/
.mcp.json

# Frontend artifacts in root (should be in frontend/ only)
/node_modules/
/package-lock.json
/package.json
/docker-compose.dev.yml

# Redis data
redis-data/
*.rdb
*.aof

# Logs
logs/
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# OS files
Thumbs.db
.DS_Store

# Temporary files
*.tmp
*.temp
.cache/
63 changes: 63 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Multi-stage build for ml-tech-assessment FastAPI application
# Uses uv for fast dependency management

# ============================================
# Stage 1: Builder - Install dependencies
# ============================================
FROM python:3.12-slim AS builder

# Install uv for fast dependency management
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/

# Set working directory
WORKDIR /app

# Copy dependency files
COPY pyproject.toml ./

# Install dependencies with uv
# Use --no-dev to exclude development dependencies
RUN uv pip install --system --no-cache -r pyproject.toml

# ============================================
# Stage 2: Runtime - Minimal production image
# ============================================
FROM python:3.12-slim

# Set environment variables
ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
# Prevent pip from checking for updates
PIP_DISABLE_PIP_VERSION_CHECK=1 \
# Application defaults
HOST=0.0.0.0 \
PORT=8000

# Create non-root user for security
RUN groupadd -r appuser && useradd -r -g appuser appuser

# Set working directory
WORKDIR /app

# Copy Python packages from builder
COPY --from=builder /usr/local/lib/python3.12/site-packages /usr/local/lib/python3.12/site-packages
COPY --from=builder /usr/local/bin /usr/local/bin

# Copy application code
COPY app/backend/ ./app/backend/

# Change ownership to non-root user
RUN chown -R appuser:appuser /app

# Switch to non-root user
USER appuser

# Expose port
EXPOSE 8000

# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD python -c "import urllib.request; urllib.request.urlopen('http://localhost:8000/api/v1/health/live').read()" || exit 1

# Run the application
CMD ["uvicorn", "app.backend.main:app", "--host", "0.0.0.0", "--port", "8000"]
Loading