# negisushant/dpi-uptime architecture

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

- Interactive diagram: https://gitdiagram.com/negisushant/dpi-uptime
- Repository: https://github.com/negisushant/dpi-uptime

## Overview

##### Project type and purpose
- This is a Turborepo-managed monorepo that houses multiple TypeScript apps and shared packages.
- It implements a full-stack platform composed of:
- A Next.js-based frontend (“apps/frontend”)
- A Node-based API service (“apps/api”)
- Two background services or “workers” (“apps/hub” and “apps/validator”)
- Shared libraries: a UI component library, common utilities, a Prisma-based DB layer, plus linting/TS configs.

##### File structure
- Top-level “apps/” directory contains deployable units:
- frontend (Next.js UI)
- api (HTTP server + middleware + types)
- hub (background worker)
- validator (background worker)
- “packages/” directory contains internal libs:
- common – shared functions and types
- db – Prisma ORM, migrations, database client
- ui – React component library
- eslint-config, typescript-config – developer tooling
- Root includes turbo.json for task orchestration, pnpm or npm locks, and global configs.

##### README for additional insights
- Confirms Next.js apps and shared TS packages.
- Emphasizes Turborepo features: task running, caching, remote cache integration.

##### Main components & interactions
a. Components (runtime view)
- Frontend App (Next.js)
- API Service (Node/Express or Next API routes)
- Hub Worker (Node script)
- Validator Worker (Node script)
- Database (PostgreSQL or similar behind Prisma)
- Turborepo Orchestrator (build/dev tool, not in runtime)
b. Relationships
- Frontend ↔ API: HTTP/REST or fetch/JSON calls
- API → Database: Prisma client reads/writes
- Hub & Validator → API or Database: likely consume tasks via API endpoints or direct DB polling
c. Architectural patterns
- Monorepo with code sharing (packages/)
- Service separation: UI layer, API layer, background workers
- Shared-library pattern for UI components and utility code
- Prisma as Data-Access-Layer (DAL)
d. Key technologies
- Next.js, React, TypeScript (frontend)
- Node.js, Express or built-in Next API (backend)
- Prisma ORM + migrations (packages/db)
- PNPM/Turbo (monorepo orchestration)
- Shared UI via packages/ui
- Shared logic via packages/common

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph "Monorepo (Turborepo)"
        direction TB

        subgraph "apps/"
            direction TB
            FE["Frontend App"]:::frontend
            API["API Service"]:::api
            Hub["Hub Worker"]:::worker
            Validator["Validator Worker"]:::worker
        end

        subgraph "packages/"
            direction TB
            common["common"]:::package
            ui["ui"]:::package
            dbpkg["db"]:::package
            eslint["eslint-config"]:::package
            tsconfig["typescript-config"]:::package
        end

        Turbo["Turborepo Orchestrator"]:::tool
    end

    DB["Database"]:::database

    %% Runtime flows
    FE -->|"REST/JSON"| API
    API -->|"Prisma Client"| DB
    Hub -.->|"Background Task"| API
    Validator -.->|"Background Task"| API

    %% Internal dependencies
    FE --> ui
    FE --> common
    API --> common
    API --> dbpkg
    Hub --> common
    Hub --> dbpkg
    Validator --> common
    Validator --> dbpkg

    %% Click Events
    click FE "https://github.com/negisushant/dpi-uptime/tree/main/apps/frontend"
    click API "https://github.com/negisushant/dpi-uptime/tree/main/apps/api"
    click Hub "https://github.com/negisushant/dpi-uptime/tree/main/apps/hub"
    click Validator "https://github.com/negisushant/dpi-uptime/tree/main/apps/validator"
    click dbpkg "https://github.com/negisushant/dpi-uptime/tree/main/packages/db"
    click common "https://github.com/negisushant/dpi-uptime/tree/main/packages/common"
    click ui "https://github.com/negisushant/dpi-uptime/tree/main/packages/ui"
    click eslint "https://github.com/negisushant/dpi-uptime/tree/main/packages/eslint-config"
    click tsconfig "https://github.com/negisushant/dpi-uptime/tree/main/packages/typescript-config"
    click Turbo "https://github.com/negisushant/dpi-uptime/blob/main/turbo.json"

    classDef frontend fill:#ADD8E6,stroke:#000
    classDef api fill:#90EE90,stroke:#000
    classDef worker fill:#D3D3D3,stroke:#000
    classDef database fill:#FFA500,stroke:#000
    classDef package fill:#F0F0F0,stroke:#000
    classDef tool fill:#FFE4B5,stroke:#000
```
