How sahil-kg7/testmaker works
Project Type and Purpose
• This is a RESTful backend service (“testmaker”) implemented in Python using FastAPI.
• Purpose: allow users to assemble test papers from a pool of questions (MCQ, fill-in, short answer, etc.), persisting data in a MySQL database, and offering utilities for backups.
File Structure
• Top-level:
• app.py – FastAPI application entrypoint
• app_config.ini / db_config.py – configuration files for application and database
• controllers/ – HTTP endpoint definitions (API layer)
• services/ – business logic layer
• db/ – repository/data access layer
• models/ – in-memory and ORM models (SQLModel)
• utils/ – logging, backup scripts, other helpers
• enums/ & exceptions/ – domain enums and custom error types
• backups/ – SQL dump snapshots
• Layering pattern: Controllers → Services → Repositories → Database
Extract Insights from README
• Tech stack: FastAPI for HTTP API, SQLModel (built on Pydantic + SQLAlchemy) for ORM, MySQL as RDBMS.
• No frontend/UI component—solely a backend microservice.
a. Main Components
• API Layer (FastAPI app.py)
• Controller Modules (ClassController, TestController, etc.)
• Service Layer (ClassService, TestService, etc.)
• Data Access Layer (ClassRepo, TestRepo, etc.)
• Database (MySQL instance)
• Utility Scripts (mysql_backup_script)
• Configuration (app_config.ini, db_config.py)
• Supporting Modules (Enums, Exceptions, Logging)
b. Relationships & Data Flow
1. Client → HTTP Request → FastAPI Routing in app.py
2. Routing → Controller → Service Layer
3. Service Layer applies business rules → calls Repository
4. Repository uses SQLModel → executes SQL on MySQL
5. Database returns records → Repository → Service → Controller → HTTP Response
6. Backup script (utils/mysql_backup_script) connects to MySQL for dumps
c. Architectural Patterns & Principles
• Layered Architecture (API, Service, Repository)
• Repository Pattern for data access
• Separation of Concerns: controllers handle transport, services handle logic, repos handle persistence
• Use of Pydantic/SQLModel for data validation
d. Key Technologies
• FastAPI (ASGI web framework)
• SQLModel / SQLAlchemy (ORM layer)
• MySQL (persistent storage)
• Python modules: enums, custom exceptions, logging utilities
Detail
• Exception and logging utilities as supportive side-nodes that hook into controllers/services.