How thanhquang2004/study-tracker-genai works
Project Type & Purpose
• It’s a server-side application built on NestJS (Node.js + TypeScript).
• It exposes RESTful endpoints via controllers.
• It uses Prisma as an ORM to persist data in a relational database.
• It implements authentication (local/JWT + Google OAuth).
• It includes business modules: user management, roadmaps, and an AI-powered “gemini” module (quiz, question, roadmap generation).
File Structure & Patterns
Top‐level modules under src/:
– auth/ (controllers, services, guards, strategies, DTOs, decorator)
– user/ (controllers, services, entities, DTOs)
– roadmap/ (controllers, services, entities, DTOs)
– gemini/ (controllers, services, DTOs)
– prisma/ (PrismaModule & PrismaService)
Standard Nest layering: Controller → Service → (PrismaService → DB).
Guards & strategies for auth, DTOs for data validation, Entities for ORM mappings.
Core Components
• Client(s): web or mobile front-end (HTTP requests).
• API Layer (NestJS):
– Controllers (AuthController, UserController, RoadmapController, GeminiController)
– Services (AuthService, UserService, RoadmapService, GeminiService)
– Guards & Strategies (JWT, Local, Google)
• Persistence Layer:
– PrismaService & generated client
– Underlying SQL database (PostgreSQL, MySQL, etc.)
• External Services:
– Google OAuth / OpenID Connect (for social login)
– External AI/LLM API that “gemini” module calls (e.g., Google Gemini or OpenAI)
Relationships & Data Flows
• Client → HTTP Request → Controller
• Controller → Service (calls business logic)
• Service → PrismaService → Database (CRUD)
• AuthController → AuthService → JWT/Google Strategy → Token issuance/validation
• GeminiService → External AI API → Response → formatted DTO → Controller → Client
Important Architectural Patterns
• Modular monolith (single Nest application composed of coherent modules).
• Layered (Presentation → Business Logic → Data Access).
• Pluggable authentication via Guards + Strategies.
• DTOs for input/output validation.
• Dependency injection throughout (Nest’s @Injectable services).
• NestJS Application boundary containing all modules.
• Modules (Auth, User, Roadmap, Gemini) with their internal Controllers & Services.
• PrismaService as the shared data-access component.
• External Google OAuth service connected to AuthService/Strategy.
• External AI/LLM service connected to GeminiService.
– Client → Controller
– Controller → Service
– Service → PrismaService → DB
– Service → External AI / OAuth