# michniks2001/overthinker-ai architecture

> Architecture diagram of the GitHub repository michniks2001/overthinker-ai, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-10-24). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/michniks2001/overthinker-ai
- Repository: https://github.com/michniks2001/overthinker-ai

## Overview

##### Project type and purpose
- This is a full-stack Next.js application (React on the frontend with built-in serverless API routes on the backend).
- It serves dynamic pages under `app/` (using the Next.js App Router), includes UI components in `components/ui/`, and provides two API endpoints—`/api/study-session` and `/api/upload`.
- There’s a simple database utility in `utils/db.js` (likely for persisting study sessions) and a file-upload utility in `lib/utils.js`.

##### File structure
Top-level folders and their roles:
- `app/` – Next.js App Router directory:
- `page.js`, `quiz/page.js` → React page components (server-rendered + client hydration).
- `api/` → Serverless API route handlers:
– `study-session/route.js` → CRUD logic for study sessions, uses `utils/db.js`.
– `upload/route.js` → Handles multipart file uploads, uses `lib/utils.js`.
- `globals.css`, `layout.js` → Global styles & layout wrapper.
- `components/ui/` – Reusable UI primitives (Button, Card, Input, FileUpload).
- `utils/db.js` – Database connection & query helpers.
- `lib/utils.js` – Shared utility functions (e.g. file parsing).
- `public/` – Static assets.
- Config files: `next.config.mjs`, `postcss.config.mjs`, `eslint.config.mjs`, `jsconfig.json`.

##### Key architectural insights from README
- Standard Next.js stack: React + serverless routes.
- Deployed on Vercel (implied serverless functions).
- No explicit microservices—everything lives in one Next.js codebase.

## Diagram (Mermaid)

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

    %% Frontend Layer
    subgraph "Next.js Frontend Layer"
        direction TB
        PageHome["Home Page (app/page.js)"]:::frontend
        QuizPage["Quiz Page (app/quiz/page.js)"]:::frontend
        Layout["Layout (app/layout.js)"]:::frontend
        Globals["Globals CSS (app/globals.css)"]:::frontend
        subgraph "UI Components"
            direction TB
            Button["Button"]:::frontend
            Card["Card"]:::frontend
            Input["Input"]:::frontend
            FileUploadUI["FileUpload"]:::frontend
        end
    end

    %% API Layer
    subgraph "Next.js API Layer"
        direction TB
        StudyAPI["Study Session API (app/api/study-session/route.js)"]:::api
        UploadAPI["Upload API (app/api/upload/route.js)"]:::api
    end

    %% Data & Storage
    subgraph "Data & Storage"
        direction TB
        DB["Database Utility (utils/db.js)"]:::data
        FileUtil["File Storage Util (lib/utils.js)"]:::data
        Assets["Static Assets (public/)"]:::external
    end

    %% Configuration
    subgraph "Configuration Files"
        direction TB
        NextConfig["next.config.mjs"]:::external
        PostCSS["postcss.config.mjs"]:::external
        ESLint["eslint.config.mjs"]:::external
        JSConfig["jsconfig.json"]:::external
    end

    %% Connections
    Client -->|"GET /"| PageHome
    Client -->|"GET /quiz"| QuizPage
    PageHome -->|"uses layout"| Layout
    QuizPage -->|"uses layout"| Layout
    Layout -->|"imports globals"| Globals
    PageHome -->|"renders UI components"| Button
    PageHome -->|"renders UI components"| Card
    PageHome -->|"renders UI components"| Input
    PageHome -->|"renders UI components"| FileUploadUI
    QuizPage -->|"renders UI components"| Button
    QuizPage -->|"renders UI components"| Card
    QuizPage -->|"renders UI components"| Input
    QuizPage -->|"renders UI components"| FileUploadUI

    Client -->|"/api/study-session POST/GET"| StudyAPI
    Client -->|"/api/upload POST"| UploadAPI

    StudyAPI -->|"DB query"| DB
    UploadAPI -->|"file processing"| FileUtil

    Client -.->|"fetch static assets"| Assets

    NextConfig --> PageHome
    NextConfig --> StudyAPI
    PostCSS --> Globals
    ESLint --> PageHome
    ESLint --> StudyAPI
    JSConfig --> PageHome
    JSConfig --> StudyAPI

    %% Click Events
    click PageHome "https://github.com/michniks2001/overthinker-ai/blob/main/app/page.js"
    click QuizPage "https://github.com/michniks2001/overthinker-ai/blob/main/app/quiz/page.js"
    click Layout "https://github.com/michniks2001/overthinker-ai/blob/main/app/layout.js"
    click Globals "https://github.com/michniks2001/overthinker-ai/blob/main/app/globals.css"
    click Button "https://github.com/michniks2001/overthinker-ai/blob/main/components/ui/button.jsx"
    click Card "https://github.com/michniks2001/overthinker-ai/blob/main/components/ui/card.jsx"
    click Input "https://github.com/michniks2001/overthinker-ai/blob/main/components/ui/input.jsx"
    click FileUploadUI "https://github.com/michniks2001/overthinker-ai/blob/main/components/ui/file-upload.jsx"
    click StudyAPI "https://github.com/michniks2001/overthinker-ai/blob/main/app/api/study-session/route.js"
    click UploadAPI "https://github.com/michniks2001/overthinker-ai/blob/main/app/api/upload/route.js"
    click DB "https://github.com/michniks2001/overthinker-ai/blob/main/utils/db.js"
    click FileUtil "https://github.com/michniks2001/overthinker-ai/blob/main/lib/utils.js"
    click Assets "https://github.com/michniks2001/overthinker-ai/tree/main/public/"
    click NextConfig "https://github.com/michniks2001/overthinker-ai/blob/main/next.config.mjs"
    click PostCSS "https://github.com/michniks2001/overthinker-ai/blob/main/postcss.config.mjs"
    click ESLint "https://github.com/michniks2001/overthinker-ai/blob/main/eslint.config.mjs"
    click JSConfig "https://github.com/michniks2001/overthinker-ai/blob/main/jsconfig.json"

    %% Styles
    classDef client fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef frontend fill:#90EE90,stroke:#333,stroke-width:1px
    classDef api fill:#FFA500,stroke:#333,stroke-width:1px
    classDef data fill:#D8BFD8,stroke:#333,stroke-width:1px
    classDef external fill:#D3D3D3,stroke:#333,stroke-width:1px
```
