# tanay-277/gsol architecture

> Architecture diagram of the GitHub repository tanay-277/gsol, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-05). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/tanay-277/gsol
- Repository: https://github.com/tanay-277/gsol

## Overview

- Client/Browser – Represents the end-user’s device that loads the React/Next.js frontend.
- Frontend Layer – Built with Next.js and React.
- Pages & Routing: The src/app directory is organized with separate routes for authentication ((auth)), main application pages (account, course, dashboard, forum, history, onboarding), and others.
- UI Components: The src/components directory includes reusable UI elements (buttons, modals, charts, etc.) and specialized components like ChatBot.
- Providers & Hooks: The src/providers and src/hooks directories encapsulate global state (e.g., theme, query, user state) and reusable logic.
- API/Backend Layer – Located in src/app/api along with multiple endpoints for authentication, content generation, quiz handling, and event-specific processing (such as Inngest-triggered functions).
- Authentication endpoints under /api/auth
- Course/quiz generation endpoints
- AI integration endpoints (e.g., generateContent & Inngest endpoints for flash cards, quiz, video)
- Database & ORM – Managed by PostgreSQL, interfaced via Prisma.
- The prisma folder contains the schema and migrations indicating evolving database structure.
- src/db/index.ts provides central database connections.
- External Services –
- AI Services: Google Gemini is used for personalization and AI processing.
- Other possible integrations: Caching or state sharing may use systems like Redis (as per tech stack) and media upload support.
- Infrastructure/DevOps – Tools for containerization (docker-compose.yml) and deployment configuration (vercel.json) outline the support systems in place.

##### Relationships and Interactions
- The Client (Browser) interacts with the Next.js Frontend.
- The Frontend consumes API endpoints to fetch or submit data.
- UI Components and Providers manage state from user interactions.
- The API layer acts as the intermediary between the frontend and the PostgreSQL database.
- API endpoints manage authentication, data fetching (courses, quizzes, analytics), and dynamic content generation.
- The Prisma ORM mediates communication with the PostgreSQL database.
- Background tasks (using Inngest endpoints) handle asynchronous processes such as flash card generation, quiz feedback, or video processing.
- Docker-Compose orchestrates the environment during development, showing connections between containers (app, database, cache) if needing a more deployment-specific view.

##### Architectural Patterns & Design Principles
- Layer Separation: Illustrate a clear separation between the client-side (Next.js/React components) and server-side API implementations.
- Modular Structure: Emphasize how the file tree organizes related functionality into features (e.g., dashboard, course, quiz).
- API Design: Use RESTful endpoints structured within the src/app/api folder to denote different responsibilities (auth, content generation, analysis).
- Database Abstraction: Show how Prisma and migrations abstract database changes and provide reliable persistent storage.
- External Integration: Clearly indicate the integration with external AI services (Google Gemini) and event-driven workflows (via Inngest).

##### Additional Details to Capture
- Architectural notes on state management: Mention the use of Zustand, global providers, and custom hooks to manage user state and UI themes.
- Modularity in the application’s file structure, which follows patterns common in contemporary Next.js projects (routing, file-system API routing, and component-based UI).
- Build and deployment pipelines (Docker for local development, Vercel for production) if needing to reflect the CI/CD aspects.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Client Layer
    Client["Client/Browser"]:::client

    %% Frontend Layer
    subgraph "Frontend Layer"
        AuthPages["Auth Pages"]:::frontend
        MainPages["Main Pages"]:::frontend
        UIComponents["UI Components"]:::frontend
        ChatBot["ChatBot"]:::frontend
        Providers["Providers"]:::frontend
        Hooks["Hooks"]:::frontend
    end

    %% API/Backend Layer
    subgraph "API/Backend Layer"
        AuthAPI["Auth API"]:::backend
        GenerateCourse["Course Generation API"]:::backend
        GenerateContent["Content Generation API"]:::backend
        InngestAPI["Inngest Functions"]:::backend
    end

    %% Database & ORM
    subgraph "Database & ORM"
        Prisma["Prisma ORM & Migrations"]:::database
        DBConnect["Database Connection"]:::database
    end

    %% External Services
    subgraph "External Services"
        GoogleGemini["Google Gemini (AI Services)"]:::external
    end

    %% Infrastructure/DevOps
    subgraph "Infrastructure/DevOps"
        DockerComp["Docker Compose"]:::devops
        VercelDep["Vercel Deployment"]:::devops
    end

    %% Connections
    Client --> AuthPages
    Client --> MainPages

    AuthPages --> UIComponents
    MainPages --> UIComponents
    UIComponents --> ChatBot
    UIComponents --> AuthAPI
    UIComponents --> GenerateCourse
    UIComponents --> GenerateContent
    UIComponents --> InngestAPI

    AuthAPI --> DBConnect
    GenerateCourse --> DBConnect
    GenerateContent --> DBConnect
    InngestAPI --> DBConnect

    GenerateContent --> GoogleGemini
    InngestAPI --> GoogleGemini

    %% Infrastructure connections (dotted lines indicate deployment orchestration)
    DockerComp --- DBConnect
    VercelDep --- UIComponents

    %% Click Events
    click AuthPages "https://github.com/tanay-277/gsol/tree/main/src/app/(auth)"
    click MainPages "https://github.com/tanay-277/gsol/tree/main/src/app/(main)"
    click UIComponents "https://github.com/tanay-277/gsol/tree/main/src/components"
    click ChatBot "https://github.com/tanay-277/gsol/blob/main/src/components/ChatBot.tsx"
    click Providers "https://github.com/tanay-277/gsol/tree/main/src/providers"
    click Hooks "https://github.com/tanay-277/gsol/tree/main/src/hooks"

    click AuthAPI "https://github.com/tanay-277/gsol/tree/main/src/app/api/auth"
    click GenerateCourse "https://github.com/tanay-277/gsol/tree/main/src/app/api/generate-course"
    click GenerateContent "https://github.com/tanay-277/gsol/tree/main/src/app/api/generateContent"
    click InngestAPI "https://github.com/tanay-277/gsol/tree/main/src/app/api/inngest"

    click Prisma "https://github.com/tanay-277/gsol/blob/main/prisma/schema.prisma"
    click DBConnect "https://github.com/tanay-277/gsol/blob/main/src/db/index.ts"

    click DockerComp "https://github.com/tanay-277/gsol/blob/main/docker-compose.yml"
    click VercelDep "https://github.com/tanay-277/gsol/blob/main/vercel.json"

    %% Styles
    classDef client fill:#ADD8E6,stroke:#000,stroke-width:2px;
    classDef frontend fill:#90EE90,stroke:#000,stroke-width:2px;
    classDef backend fill:#FFB6C1,stroke:#000,stroke-width:2px;
    classDef database fill:#FFFFE0,stroke:#000,stroke-width:2px;
    classDef external fill:#D3D3D3,stroke:#000,stroke-width:2px;
    classDef devops fill:#F5DEB3,stroke:#000,stroke-width:2px;
```
