A clean FastAPI backend for academic performance tracking and GPA analytics. Built with modern Python practices for reliability and maintainability.
- Student Management: User registration, authentication with JWT tokens
- Grade Processing: OCR-powered grade sheet analysis using Google Gemini Vision
- Analytics: Calculate CGPA, semester-wise performance, grade trends
- API-First: RESTful endpoints for integration with frontend applications
src/
├── app/main.py # FastAPI application entry point
├── routers/ # HTTP API endpoints (active routes)
│ ├── auth/ # Authentication & user management
│ ├── users/ # User profile operations
│ ├── grades/ # Grade upload & OCR processing
│ └── analytics/ # GPA calculations & reporting
├── shared/ # Core utilities & models
│ ├── entities.py # Database models (SQLModel)
│ ├── database.py # Azure SQL connection & sessions
│ ├── security.py # JWT & password hashing
│ └── config.py # Environment configuration
└── features/ # Legacy feature modules (being phased out)
- FastAPI - Web framework with automatic OpenAPI docs
- SQLModel - Type-safe database models & queries
- Azure SQL - Cloud database with auto-scaling
- Argon2 - Password hashing
- JWT - Stateless authentication
- Google Gemini Vision - OCR for grade sheet processing
- Docker - Containerized deployment
- Python 3.12+
- UV package manager
- Azure SQL Database (or modify for local SQLite)
# Clone the repository
git clone https://github.com/lsvishaal/GPAlytics_Backend_LS.git
cd GPAlytics_Backend_LS
# Install dependencies
uv install
# Set up environment variables
cp .env.example .env
# Edit .env with your database credentials and secretsCreate .env file with:
# Database
DATABASE_URL="mssql+aioodbc://user:pass@server.database.windows.net:1433/db?driver=ODBC+Driver+18+for+SQL+Server&Encrypt=yes&TrustServerCertificate=no&Connection+Timeout=30"
# Authentication
JWT_SECRET_KEY="your-secret-key-here"
JWT_ALGORITHM=HS256
JWT_EXPIRE_MINUTES=30
# OCR Processing
GEMINI_KEY="your-google-gemini-api-key"
# Application
DEBUG=true
ENVIRONMENT=development# Development server (auto-reload)
uv run uvicorn src.app.main:app --reload --host 0.0.0.0 --port 8000
# Production server
uv run uvicorn src.app.main:app --host 0.0.0.0 --port 8000
# With Docker
docker-compose up --buildOnce running, visit:
- Swagger UI: http://localhost:8000/docs
- ReDoc: http://localhost:8000/redoc
- Health Check: http://localhost:8000/health
POST /auth/register- Create new user accountPOST /auth/login- Authenticate user & get JWT tokensPOST /auth/refresh- Refresh access tokenPOST /auth/forgot-password- Password reset
GET /users/me- Get current user profile
POST /grades/upload- Upload grade sheet (OCR processing)GET /grades/- List user's gradesDELETE /grades/semester/{id}- Delete semester grades
GET /analytics/cgpa- Calculate overall CGPAGET /analytics/semesters- Semester-wise breakdown
# All tests
uv run pytest
# With coverage
uv run pytest --cov=src
# Specific test file
uv run pytest tests/integration/auth/test_login.py -v# Format code
uv run black src/ tests/
# Lint code
uv run ruff check src/ tests/
# Type checking
uv run mypy src/# Reset database (development only)
uv run python scripts/reset_db.py
# Check database health
curl http://localhost:8000/health# Build production image
docker build -f docker/Dockerfile -t gpalytics-backend .
# Run with environment
docker run -p 8000:8000 --env-file .env gpalytics-backendConfigured in docker/docker-compose.yml for Azure deployment with:
- Azure SQL Database integration
- Redis caching layer
- Health checks & monitoring
src/routers/- Active API routes following feature-based organizationsrc/shared/- Core utilities shared across all featuressrc/features/- Legacy modules being gradually removedtests/- Test suite mirroring src structuredocker/- Containerization configsdocs/- Architecture documentation
- Create feature branch from
development - Make changes following existing patterns
- Add tests for new functionality
- Update documentation as needed
- Submit PR with clear description
Private project - All rights reserved.