A full-stack Online Examination System built with FastAPI, MySQL, Redis, and a Vanilla JS frontend.
exam_system/
├── backend/
│ ├── app/
│ │ ├── core/ # Config, DB, Security, Cache, Logger
│ │ ├── models/ # SQLAlchemy models
│ │ ├── schemas/ # Pydantic schemas
│ │ ├── services/ # Business logic
│ │ ├── routes/ # API endpoints
│ │ ├── middleware/ # Logging middleware
│ │ ├── tests/ # pytest test suite
│ │ └── main.py
│ ├── Dockerfile
│ └── requirements.txt
├── frontend/
│ ├── index.html
│ ├── static/css/style.css
│ ├── static/js/app.js
│ └── nginx.conf
└── docker-compose.yml
- Docker Desktop + WSL2
- PowerShell or WSL terminal
# Clone / navigate to project
cd exam_system
# Build and start all services
docker-compose up --build
# Access the app:
# Frontend: http://localhost:3000
# API Docs: http://localhost:8000/docs
# Backend: http://localhost:8000docker-compose downdocker-compose down -v # removes volumes too
docker-compose up --build# Run tests inside the backend container
docker-compose exec backend pytest app/tests/ -v| Role | Permissions |
|---|---|
| Admin | Create/Edit/Delete exams, view all results, analytics, monitoring |
| Student | Take exams, view own results |
POST /api/auth/register- Register (admin or student)POST /api/auth/login- Login → returns JWTGET /api/auth/me- Get current user
GET /api/exams/- List all active examsPOST /api/exams/- Create exam with questions (Admin)GET /api/exams/{id}- Get exam detailPUT /api/exams/{id}- Update exam (Admin)DELETE /api/exams/{id}- Delete exam (Admin)
POST /api/results/submit- Submit exam answersGET /api/results/my- Student's own resultsGET /api/results/my/{id}- Result detailGET /api/results/admin/all- All results (Admin)GET /api/results/analytics/{exam_id}- Exam analytics (Admin)
GET /api/monitoring/health- Health checkGET /api/monitoring/stats- System stats (Admin)GET /api/monitoring/logs- Recent logs (Admin)
- Backend: FastAPI, SQLAlchemy, PyMySQL, Pydantic v2
- Auth: JWT (python-jose), bcrypt (passlib)
- Cache: Redis (Cache-Aside Pattern)
- Logging: Loguru
- Testing: pytest, FastAPI TestClient
- Database: MySQL 8.0
- Frontend: HTML/CSS/Vanilla JS
- Proxy: Nginx
- Containerization: Docker + docker-compose