How aksofttech/ai-backend works
This is a multi-tenant education backend for schools, teachers, and students. Its core content workflow is managing books and chapters, ingesting textbook PDFs into searchable chunks, then searching or chatting over that material; AI authoring tools also retrieve curriculum context before generating teaching materials. The API includes authentication and role-based access, curriculum and user management, assignments, quizzes, lectures, and an e-library, plus PDF/PPTX compilation. The graph includes major subsystems from the tree, but links are limited where sampled source did not establish their wiring.
Main entry points: rag-engine.service.ts RAG orchestration · auth.service.ts Authentication · ai-orchestrator.service.ts Generation orchestration · tenant.entity.ts Tenant and users
Components 24
Identity and tenancy
- Authentication
src/modules/auth/auth.service.ts - User management
src/modules/users/users.controller.ts - Tenant and users
src/database/entities/tenant.entity.ts
Learning workflows
- Assignments
src/modules/assignment/assignment.controller.ts - Quizzes and results
src/modules/quiz/quiz.controller.ts - Lectures
src/modules/lectures/lectures.controller.ts - E-library
src/modules/e-library/e-library.controller.ts
Curriculum knowledge
- Curriculum API
src/modules/curriculum/curriculum.controller.ts - RAG API
src/modules/rag-engine/rag-engine.controller.ts - RAG orchestration
src/modules/rag-engine/rag-engine.service.ts - PDF extraction
src/modules/rag-engine/services/pdf-extraction.service.ts - Chapter detection
src/modules/rag-engine/services/chapter-detection.service.ts - Text chunking
src/modules/rag-engine/services/chunking.service.ts - Embeddings
src/modules/rag-engine/services/embedding.service.ts - Vector search
src/modules/rag-engine/services/vector-search.service.ts - Curriculum chunks
src/database/entities/book-chunk.entity.ts
AI and output
- AI authoring API
src/modules/ai-tools/ai-tools.controller.ts - Generation orchestration
src/modules/ai-tools/ai-orchestrator.service.ts - Teaching content tools
src/modules/ai-tools/services/worksheet.service.ts - Generative AI service
src/modules/ai-tools/services/openai-chat.service.ts - Document compiler
src/modules/compiler/compiler.controller.ts
Other components
- API user
- PostgreSQL
- Embedding provider
Connections 26
- API user → Authentication: signs up or logs in
- Authentication → User management: looks up or creates
- Authentication → Tenant and users: creates tenant
- Authentication → API user: returns JWT
- API user → Curriculum API: manages curriculum
- API user → RAG API: ingests, searches, chats
- RAG API → RAG orchestration: dispatches requests
- RAG orchestration → PDF extraction: extracts PDF text
- RAG orchestration → Chapter detection: identifies chapters
- RAG orchestration → Text chunking: splits text
- RAG orchestration → Embeddings: requests vectors
- RAG orchestration → Vector search: searches vectors
- RAG orchestration → Curriculum chunks: reads and writes chunks
- Embeddings → Embedding provider: requests embeddings
- Curriculum chunks → PostgreSQL: persists curriculum chunks
- Tenant and users → PostgreSQL: persists tenants and users
- API user → Assignments: manages assignments
- API user → Quizzes and results: submits and views results
- API user → Lectures: uses lectures
- API user → E-library: uses e-library
- API user → AI authoring API: requests teaching materials
- AI authoring API → Generation orchestration: dispatches generation
- Generation orchestration → RAG orchestration: retrieves context
- Generation orchestration → Teaching content tools: selects content tool
- Teaching content tools → Generative AI service: generates content
- API user → Document compiler: requests PDF or PPTX