How aidankhatana/zoltai works
Main Components
• Frontend (Presentation Layer):
• Represented by Next.js pages (e.g., pages in src/app such as “about”, “login”, “register”, “profile”, “quizzes”, “roadmaps”, etc.).
• Contains reusable UI components (e.g., Header, Footer, Navbar, Hero, CTA) found in the src/components directory.
• Provides layouts and context providers (e.g., AuthContext, RoadmapContext) that manage client-side state.
• API / Backend Services:
• The project exposes a series of API endpoints under src/app/api that handle authentication (login, register), quiz retrieval, roadmap queries, environment and database checks, and more.
• Each endpoint is defined as a route (using Next.js API Routes) corresponding to specific functionalities.
• Business Logic and Libraries:
• Core functionalities such as authentication and utility functions are encapsulated in the src/lib directory.
• Specifically, integration with the Gemini API is managed through modules in src/lib/gemini and src/lib/gemini/index.ts.
• The src/lib/db directory (with pg-client.ts) indicates that a PostgreSQL database is likely used.
• External Services:
• Integration with the Google Gemini API for AI-powered learning path generation.
• Authentication likely relies on a third-party or in-built NextAuth.js driver.
• Deployment is on Vercel, and deployment-related files (e.g., vercel.json) should be noted.
Relationships and Interactions
• User Interaction Flow:
• Users load the Next.js frontend (served on Vercel) and navigate through pages such as login, registration, quizzes, and learning roadmap displays.
• Contexts (AuthContext and RoadmapContext) ensure that user-specific data and application state are passed down the component tree.
• API Communication:
• Frontend components communicate with the backend through RESTful API endpoints (e.g., under /api/auth, /api/quizzes, /api/roadmaps).
• Backend Processing:
• The API endpoints invoke functions in the lib directory. For example, authentication endpoints use functions from src/lib/auth.ts.
• API endpoints manage database interaction through the pg-client in src/lib/db.
• The Gemini API integrations are performed at the business logic layer (src/lib/gemini), with endpoints calling these functions to process user queries and generate personalized learning paths.
• External Service Integration:
• NextAuth.js (if detailed further in code/config) as a component handling authentication flows.
Architectural Patterns and Design Principles
• Modular Separation:
• The project shows clear separation between presentation (pages and UI components), business logic (lib functions for authentication, Gemini integration, and utility operations), and API endpoints that act as intermediaries.
• API-First Approach:
• The clear definition of API subdirectories (e.g., for authentication, quizzes, roadmaps) suggests that the system is designed around a robust and modular API layer.
• Use of Context Providers:
• Application-wide state is managed via React Context (AuthContext and RoadmapContext), which is important for user authentication and roadmap state.
• Serverless/Route-Based Functions:
• By using Next.js API routes, the application follows a serverless or microservice-inspired pattern where each API endpoint encapsulates a specific piece of functionality.