# gitmasterjatin/approximate_qe architecture

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

- Interactive diagram: https://gitdiagram.com/gitmasterjatin/approximate_qe
- Repository: https://github.com/gitmasterjatin/approximate_qe

## Overview

##### Major Components
- Monorepo Orchestrator (Turbo CLI/Turbo Engine)
- Apps:
- Backend
– Data-processing scripts (Python loader, sampling, sketching)
– HTTP API server (TypeScript/Node, `middleware.ts`, `server.ts`)
- Web Frontend
– Next.js application (React/TypeScript)
- Shared Packages (internal libraries/configs):
- @repo/db (Prisma schema & client)
- @repo/ui (React UI component library)
- @repo/typescript-config (TS configurations)
- @repo/eslint-config (ESLint configurations)
- External Services:
- Database (e.g., PostgreSQL)
- Vercel Remote Cache (optional caching service)
- CI/CD environment (build & deploy pipelines)

##### Relationships & Data Flows
- Turborepo orchestrates `build` & `dev` tasks for all apps/packages.
- Backend data-processing scripts read raw data, produce merged_data.csv → this is ingested or referenced by the HTTP API.
- HTTP API imports the Prisma client from `@repo/db` to talk to the Database.
- Web Frontend uses:
– UI components from `@repo/ui`
– TypeScript settings from `@repo/typescript-config`
– Linting rules from `@repo/eslint-config`
- Web Frontend communicates with the HTTP API over HTTP/HTTPS.
- Remote Caching (Vercel) connects with Turborepo to cache build artifacts.
- CI/CD pipelines pull from the monorepo, run Turbo tasks, and deploy apps.

##### Architectural Patterns
- Monorepo architecture using Turborepo for fast, cross-package builds & caching.
- Clear separation:
- Data processing (Python) vs. API layer (Node/TS) vs. UI layer (Next.js).
- Shared libraries/config files promote DRY and consistency.
- API-first design: frontend consumes REST (or GraphQL) endpoints expos ed by HTTP API.

##### Technologies & Frameworks
- Turborepo (turbo.json)
- Python 3.x (data loader scripts, notebooks)
- Node.js + TypeScript (HTTP API, Next.js)
- Next.js 13 (app directory, server/client components)
- Prisma ORM (schema.prisma)
- React component library (`@repo/ui`)
- ESLint & Prettier (linting/formatting)
- Vercel (optional remote cache & deployment)

##### Elements
- Clear labels on all components (e.g., “Next.js Web App”, “HTTP API (Node/TS)”, “Prisma Client”).

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Monorepo Orchestrator"
        Turbo["Turbo CLI/Engine"]:::orchestrator
    end

    subgraph "Apps"
        subgraph "Backend"
            direction TB
            subgraph "Data Processing (Python)"
                Loader["Continuous Loader"]:::backend
                Notebook["Jupyter Notebook"]:::backend
                Combined["Combined Script"]:::backend
                Sampling["Sampling Script"]:::backend
                Sketching["Sketching Script"]:::backend
                CSV["merged_data.csv"]:::backend
            end
            subgraph "HTTP API (Node/TS)"
                Middleware["middleware.ts"]:::backend
                Server["server.ts"]:::backend
                PrismaClient["Prisma Client"]:::shared
            end
        end
        subgraph "Web Frontend"
            direction TB
            NextApp["Next.js App"]:::frontend
            Globals["globals.css"]:::frontend
            Layout["layout.tsx"]:::frontend
            Login["login/page.tsx"]:::frontend
            MainPage["page.tsx"]:::frontend
            PageCSS["page.module.css"]:::frontend
            Config["next.config.js"]:::frontend
            TSWeb["tsconfig.json"]:::frontend
            ESLintWeb["eslint.config.js"]:::frontend
        end
    end

    subgraph "Shared Packages"
        DBPkg["@repo/db"]:::shared
        UIPkg["@repo/ui"]:::shared
        TSPkg["@repo/typescript-config"]:::shared
        ESLintPkg["@repo/eslint-config"]:::shared
    end

    subgraph "External Services"
        Database["PostgreSQL"]:::external
        VercelCache["Vercel Remote Cache"]:::external
        CICD["CI/CD Pipelines"]:::external
    end

    Turbo -->|orchestrates build/dev| Loader
    Turbo -->|orchestrates build/dev| Notebook
    Turbo -->|orchestrates build/dev| Combined
    Turbo -->|orchestrates build/dev| Sampling
    Turbo -->|orchestrates build/dev| Sketching
    Turbo -->|orchestrates build/dev| Middleware
    Turbo -->|orchestrates build/dev| Server
    Turbo -->|orchestrates build/dev| NextApp
    Turbo -->|orchestrates build/dev| DBPkg
    Turbo -->|orchestrates build/dev| UIPkg
    Turbo -->|orchestrates build/dev| TSPkg
    Turbo -->|orchestrates build/dev| ESLintPkg
    Turbo -->|caches builds| VercelCache

    Loader -->|writes CSV| CSV
    Combined -->|writes CSV| CSV
    Sampling -->|writes CSV| CSV
    Sketching -->|writes CSV| CSV
    CSV -->|ingested by| Server

    Server -->|imports Prisma Client| PrismaClient
    PrismaClient -->|connects to| Database
    Server -->|depends on| DBPkg

    NextApp -->|imports UI components| UIPkg
    NextApp -->|imports TS configs| TSPkg
    NextApp -->|imports ESLint rules| ESLintPkg
    NextApp -->|HTTP calls| Server

    CICD -->|runs Turbo tasks| Turbo
    CICD -->|deploys apps| Server
    CICD -->|deploys apps| NextApp

    click Turbo "https://github.com/gitmasterjatin/approximate_qe/blob/main/turbo.json"
    click Loader "https://github.com/gitmasterjatin/approximate_qe/blob/main/apps/backend/continuous.py"
    click Notebook "https://github.com/gitmasterjatin/approximate_qe/blob/main/apps/backend/data.ipynb"
    click Combined "https://github.com/gitmasterjatin/approximate_qe/blob/main/apps/backend/loader/combined.py"
    click Sampling "https://github.com/gitmasterjatin/approximate_qe/blob/main/apps/backend/sampling.py"
    click Sketching "https://github.com/gitmasterjatin/approximate_qe/blob/main/apps/backend/sketching.py"
    click CSV "https://github.com/gitmasterjatin/approximate_qe/blob/main/apps/backend/merged_data.csv"
    click Middleware "https://github.com/gitmasterjatin/approximate_qe/blob/main/apps/backend/http_api/middleware.ts"
    click Server "https://github.com/gitmasterjatin/approximate_qe/blob/main/apps/backend/http_api/server.ts"
    click NextApp "https://github.com/gitmasterjatin/approximate_qe/tree/main/apps/web/app"
    click Globals "https://github.com/gitmasterjatin/approximate_qe/blob/main/apps/web/app/globals.css"
    click Layout "https://github.com/gitmasterjatin/approximate_qe/blob/main/apps/web/app/layout.tsx"
    click Login "https://github.com/gitmasterjatin/approximate_qe/blob/main/apps/web/app/login/page.tsx"
    click MainPage "https://github.com/gitmasterjatin/approximate_qe/blob/main/apps/web/app/page.tsx"
    click PageCSS "https://github.com/gitmasterjatin/approximate_qe/blob/main/apps/web/app/page.module.css"
    click Config "https://github.com/gitmasterjatin/approximate_qe/blob/main/apps/web/next.config.js"
    click TSWeb "https://github.com/gitmasterjatin/approximate_qe/blob/main/apps/web/tsconfig.json"
    click ESLintWeb "https://github.com/gitmasterjatin/approximate_qe/blob/main/apps/web/eslint.config.js"
    click DBPkg "https://github.com/gitmasterjatin/approximate_qe/blob/main/packages/db/prisma/schema.prisma"
    click UIPkg "https://github.com/gitmasterjatin/approximate_qe/blob/main/packages/ui/package.json"
    click TSPkg "https://github.com/gitmasterjatin/approximate_qe/blob/main/packages/typescript-config/package.json"
    click ESLintPkg "https://github.com/gitmasterjatin/approximate_qe/blob/main/packages/eslint-config/package.json"

    classDef orchestrator fill:#D8BFD8,stroke:#000,stroke-width:1px
    classDef backend fill:#8FBC8F,stroke:#000,stroke-width:1px
    classDef frontend fill:#87CEFA,stroke:#000,stroke-width:1px
    classDef shared fill:#D3D3D3,stroke:#000,stroke-width:1px
    classDef external fill:#FFA500,stroke:#000,stroke-width:1px
```
