How abdullah270602/adaptive-e-learning-platform-bakend works
Project Type and Purpose
• This is a FastAPI-based backend service for an adaptive learning platform.
• It exposes RESTful endpoints for authentication, document handling, quiz/MCQ generation, search (RAG), study mode, streak tracking, and library search.
• It integrates with PostgreSQL, Redis, MinIO (S3), Qdrant (vector DB), and external LLM providers.
File Structure
• Top-level:
• main.py: FastAPI app instantiation, middleware, router registration
• app/routes: API controllers (auth, file, quiz, study_mode, etc.)
• app/services: Business logic (file processing, LLM prompts, RAG, vector search, etc.)
• app/database: Raw SQL queries and connection management
• app/cache: Redis caching wrappers (metadata & learning profile)
• app/schemas: Pydantic models for request/response validation
• scripts/init_db.py & DB_schema_script.sql: DB initialization
• Configuration: .env.example, pyproject.toml, uv.lock
README
• Confirms architecture: FastAPI <-> PostgreSQL, Redis, MinIO, Qdrant, LLMs
• Calls out each subsystem: Auth (Google OAuth2 + JWT), Document conversion, Quiz generation, RAG search, Study Mode, Streaks/Leaderboards, Library search, Caching, Storage.
a. Main Components
1. Client/User (Web or Mobile)
2. FastAPI Backend (main.py)
• API Layer (app/routes)
• Service Layer (app/services)
• Data Layer (app/database, app/cache)
3. PostgreSQL Database
4. Redis Cache
5. MinIO (S3-compatible storage)
6. Qdrant Vector DB
7. External LLM Providers (OpenAI, Groq, DeepSeek, etc.)
8. Google OAuth2 (Auth provider)
b. Relationships & Interactions
• Client ↔ FastAPI API Layer
• API Layer → Service Layer for each request
• Service Layer reads/writes:
• PostgreSQL (user data, metadata, quizzes, progress, streaks)
• Redis (model & metadata caching)
• MinIO (upload/download documents, generated files)
• Qdrant (semantic vectors & RAG search)
• Service Layer calls external LLM APIs for quiz generation, profile summaries, MCQs, etc.
• Auth Flow: FastAPI ↔ Google OAuth2 ↔ issue JWT ↔ stored in PostgreSQL
c. Architectural Patterns & Design Principles
• Layered architecture: Controllers → Services → Data Stores
• Separation of concerns: routing, business logic, persistence, caching, storage
• Dependency injection via FastAPI dependencies (e.g., DB connection, auth)
• Stateless services with external state in DB, cache, and object storage
• RAG integration: vector store + full-text chunks
d. Key Technologies & Frameworks
• FastAPI (Python)
• Pydantic schemas
• PostgreSQL (psycopg2)
• Redis (redis-py)
• MinIO (boto3 or S3 SDK)
• Qdrant (qdrant-client)
• LibreOffice (document conversion CLI)
• LLM SDKs (OpenAI, etc.)