alembic
feat: flashcard implimentedapp
feat: flashcard implimentedassets
question paper downloaddocs
feat: dict serviceopenapi
feat: flashcard implimentedscripts
question paper downloadstatic
service of worksheettests
feat: flashcard implimented.dockerignore
initial.env.example
initial.gitignore
initial.python-version
initialalembic.ini
initialdocker-compose.yml
feat: Implement learning module with user profiles, daily vocabulary, SM-2 progress tracking, and audio TTS service.Dockerfile
initialfeatures.md
service of worksheetpyproject.toml
learning module fixREADME.md
updated Readmeuv.lock
feat: document summaryBhashaAI Backend
BhashaAI Backend is a fast, asynchronous FastAPI service that powers the education platform. It provides APIs for Question Paper generation (PDF), Flashcards, and Dictionary services using Generative AI (Google Gemini).
π Architecture
The backend is structured as a layered monolith with clear separation of concerns.
graph TD
Client[Frontend / Client] --> |HTTP/JSON| API[FastAPI Router]
API --> |Pydantic| Schema[Validation Layer]
Schema --> Service[Service Layer]
Service --> |SQLAlchemy| DB[(PostgreSQL + pgvector)]
Service --> |LangChain| AI[Model providers]
Service --> |ReportLab/FPDF| PDF[PDF Generator]
subgraph "Infrastructure"
Redis[Redis Cache]
MinIO[MinIO Storage]
end
Service --> Redis
Service --> MinIOKey Technologies
- Core: FastAPI, Python 3.12
- Data: PostgreSQL (Async), SQLAlchemy 2.0, Alembic
- AI: LangChain, Google Gemini
- Storage: MinIO (S3 Compatible), Redis
- Package Manager:
uv
π Getting Started
Prerequisites
- Python 3.10+
- PostgreSQL, Redis
- Google Gemini API Key
Installation
-
Clone and enter directory:
cd bhasaai-backend -
Install dependencies using
uv:# Install uv if needed: pip install uv uv sync -
Environment Setup: Copy
.env.exampleto.env:cp .env.example .envRequired Variables:
DATABASE_URL=postgresql+asyncpg://user:pass@localhost:5432/education_ai SECRET_KEY=your_secret_key GEMINI_API_KEY=your_gemini_key REDIS_URL=redis://localhost:6379/0 MINIO_ENDPOINT=localhost:9000 MINIO_ACCESS_KEY=minioadmin MINIO_SECRET_KEY=minioadmin -
Run Migrations:
uv run alembic upgrade head -
Run Server:
uv run uvicorn app.main:app --reload
π³ Docker Setup
The backend includes a production-ready Dockerfile.
Build & Run
docker build -t bhasaai-backend .
docker run -p 8000:8000 --env-file .env bhasaai-backendFull Stack (Recommended)
Use the root docker-compose.yml to spin up Postgres, Redis, MinIO, and Backend together.
π§ͺ Testing
Run the test suite using pytest:
uv run pytestπ API Services
/api/v1/auth: User authentication (JWT)/api/v1/question-papers: Generate & Download papers/api/v1/flashcards: Create decks & SRS study/api/v1/dictionary: English-Gujarati dictionary