# code100x/dpin-uptime architecture

> Architecture diagram of the GitHub repository code100x/dpin-uptime, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-04-18). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/code100x/dpin-uptime
- Repository: https://github.com/code100x/dpin-uptime

## Overview

1. **Repository shape**
   - This is a **Turborepo monorepo** with multiple runnable apps and shared packages.
   - The main top-level boundary is between `apps/*` for deployable services and `packages/*` for reusable libraries/config.

2. **Primary user-facing app: `apps/frontend`**
   - A **Next.js App Router** application (`app/` directory) with a dashboard route and root page.
   - It has its own `components/`, `hooks/`, `lib/`, global styles, and theme provider.
   - `hooks/useWebsites.tsx` suggests the UI consumes website-related data, likely from the API layer.
   - This is the main presentation layer in the system.

3. **Backend API: `apps/api`**
   - A separate TypeScript service with `index.ts`, `middleware.ts`, `config.ts`, and `types.d.ts`.
   - The presence of middleware and config indicates an **HTTP API/service boundary** rather than a UI app.
   - It is the likely integration point for the frontend and the internal service layer.

4. **Internal services/workers: `apps/hub` and `apps/validator`**
   - These are standalone TypeScript executables with their own package configs and entrypoints.
   - From names alone, `hub` looks like a coordination/orchestration service, and `validator` looks like a validation/verification worker or service.
   - Their exact responsibilities are not visible here, but architecturally they are separate backend boundaries from the API and frontend.

5. **Persistence layer: `packages/db`**
   - This package contains a full **Prisma schema**, migrations, and seed script.
   - That makes it the repo’s database abstraction and schema source of truth.
   - The migration history shows the data model has evolved around features like `disabled` and `payout`, which are likely important domain concepts.

6. **Shared domain/utilities: `packages/common`**
   - A small shared package for code reused across apps.
   - In a diagram, this should sit as a shared library dependency feeding multiple services, not as a runtime service.

7. **Shared UI library: `packages/ui`**
   - A reusable React component package with components like `button`, `card`, and `code`.
   - This is distinct from `apps/frontend/components`, which are app-specific pieces.
   - It’s the design-system boundary for shared presentation primitives.

8. **Shared configuration packages**
   - `packages/eslint-config` centralizes lint rules across the repo.
   - `packages/typescript-config` centralizes TS compiler settings for base, React library, and Next.js targets.
   - These are build-time and developer-experience dependencies, not runtime services.

9. **Frontend composition vs shared components**
   - The frontend mixes **local app components** (`apps/frontend/components/Appbar.tsx`, `theme-provider.tsx`) with **shared UI primitives** from `packages/ui`.
   - This indicates a layered UI architecture: app-specific layout/navigation on top of reusable design components.

10. **Data flow you should draw**
   - The most likely runtime flow is **browser → Next.js frontend → API service → database**.
   - `hub` and `validator` likely participate in internal processing or validation around the same domain data, probably using the shared `common` and `db` packages.
   - `packages/db` is the persistence boundary; the API and backend services are the consumers of that layer.

11. **Build and execution model**
   - Turborepo coordinates builds, dev tasks, and caching across apps/packages.
   - The repo is TypeScript-first across the board.
   - The architecture is therefore a **modular monorepo** with separate deployables and shared libraries, rather than a single app with internal folders.

12. **What is most important for an architecture diagram**
   - Show four deployable app nodes: **frontend**, **api**, **hub**, **validator**.
   - Show shared libraries beneath them: **common**, **db/Prisma**, **ui**, plus config packages.
   - Emphasize that `db` is a shared persistence module, `ui` is a reusable presentation module, and `common` is cross-cutting domain code.
   - Treat `hub` and `validator` as backend components with distinct responsibilities, even though their implementation details are not visible from the tree.

Main entry points: [`apps/frontend`](https://github.com/code100x/dpin-uptime/tree/main/apps/frontend) (Frontend), [`turbo.json`](https://github.com/code100x/dpin-uptime/blob/main/turbo.json) (Turborepo), [`packages/db`](https://github.com/code100x/dpin-uptime/tree/main/packages/db) (Database), [`apps/api`](https://github.com/code100x/dpin-uptime/tree/main/apps/api) (API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_apps["Apps"]
  node_frontend["Frontend<br/>Next.js app"]
  node_frontend_app["App routes<br/>next app router"]
  node_frontend_components["App UI<br/>app components"]
  node_frontend_hooks["Data hooks<br/>client hooks"]
  node_api["API<br/>HTTP service"]
  node_hub["Hub<br/>worker service"]
  node_validator["Validator<br/>worker service"]
end

subgraph group_packages["Packages"]
  node_common["Common<br/>shared domain"]
  node_db[("Database<br/>prisma package")]
  node_db_schema["Prisma schema<br/>schema source<br/>[schema.prisma]"]
  node_db_migrations["Migrations<br/>schema history"]
  node_ui["UI kit<br/>react library"]
  node_ui_components["Primitives<br/>ui components"]
  node_eslint_config["ESLint config"]
  node_ts_config["TS config<br/>typescript config"]
end

node_turbo{{"Turborepo<br/>build orchestration<br/>[turbo.json]"}}

node_turbo -->|"builds"| node_frontend
node_turbo -->|"builds"| node_api
node_turbo -->|"builds"| node_hub
node_turbo -->|"builds"| node_validator
node_turbo -->|"builds"| node_common
node_turbo -->|"builds"| node_db
node_frontend -->|"contains"| node_frontend_app
node_frontend -->|"contains"| node_frontend_components
node_frontend -->|"contains"| node_frontend_hooks
node_frontend -->|"uses"| node_ui
node_frontend -->|"calls"| node_api
node_api -->|"reads/writes"| node_db
node_api -->|"uses"| node_common
node_hub -->|"uses"| node_common
node_hub -->|"uses"| node_db
node_validator -->|"uses"| node_common
node_validator -->|"uses"| node_db
node_db -->|"defines"| node_db_schema
node_db -->|"evolves"| node_db_migrations
node_frontend_components -->|"wraps"| node_ui
node_frontend -.->|"inherits"| node_eslint_config
node_frontend -.->|"inherits"| node_ts_config
node_api -.->|"inherits"| node_ts_config
node_hub -.->|"inherits"| node_ts_config
node_validator -.->|"inherits"| node_ts_config
node_ui -.->|"inherits"| node_eslint_config
node_ui -.->|"inherits"| node_ts_config

click node_turbo "https://github.com/code100x/dpin-uptime/blob/main/turbo.json"
click node_frontend "https://github.com/code100x/dpin-uptime/tree/main/apps/frontend"
click node_frontend_app "https://github.com/code100x/dpin-uptime/tree/main/apps/frontend/app"
click node_frontend_components "https://github.com/code100x/dpin-uptime/tree/main/apps/frontend/components"
click node_frontend_hooks "https://github.com/code100x/dpin-uptime/tree/main/apps/frontend/hooks"
click node_api "https://github.com/code100x/dpin-uptime/tree/main/apps/api"
click node_hub "https://github.com/code100x/dpin-uptime/tree/main/apps/hub"
click node_validator "https://github.com/code100x/dpin-uptime/tree/main/apps/validator"
click node_common "https://github.com/code100x/dpin-uptime/tree/main/packages/common"
click node_db "https://github.com/code100x/dpin-uptime/tree/main/packages/db"
click node_db_schema "https://github.com/code100x/dpin-uptime/blob/main/packages/db/prisma/schema.prisma"
click node_db_migrations "https://github.com/code100x/dpin-uptime/tree/main/packages/db/prisma/migrations"
click node_ui "https://github.com/code100x/dpin-uptime/tree/main/packages/ui"
click node_ui_components "https://github.com/code100x/dpin-uptime/tree/main/packages/ui/src"
click node_eslint_config "https://github.com/code100x/dpin-uptime/tree/main/packages/eslint-config"
click node_ts_config "https://github.com/code100x/dpin-uptime/tree/main/packages/typescript-config"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_frontend,node_frontend_app,node_frontend_components,node_frontend_hooks,node_api,node_hub,node_validator toneBlue
class node_common,node_db,node_db_schema,node_db_migrations,node_ui,node_ui_components,node_eslint_config,node_ts_config toneAmber
class node_turbo toneNeutral
```

## Components

### Apps

Deployable services and user-facing application

- [Frontend](https://github.com/code100x/dpin-uptime/tree/main/apps/frontend): Next.js app · Main dashboard and presentation layer · `apps/frontend`
- [App routes](https://github.com/code100x/dpin-uptime/tree/main/apps/frontend/app): next app router · Root page and dashboard routes · `apps/frontend/app`
- [App UI](https://github.com/code100x/dpin-uptime/tree/main/apps/frontend/components): app components · Layout, theme, and app-specific UI pieces · `apps/frontend/components`
- [Data hooks](https://github.com/code100x/dpin-uptime/tree/main/apps/frontend/hooks): client hooks · Frontend data access and UI state hooks · `apps/frontend/hooks`
- [API](https://github.com/code100x/dpin-uptime/tree/main/apps/api): HTTP service · Backend API boundary for app and service clients · `apps/api`
- [Hub](https://github.com/code100x/dpin-uptime/tree/main/apps/hub): worker service · Standalone backend coordination service · `apps/hub`
- [Validator](https://github.com/code100x/dpin-uptime/tree/main/apps/validator): worker service · Standalone validation and verification service · `apps/validator`

### Packages

Shared libraries, persistence, and tooling

- [Common](https://github.com/code100x/dpin-uptime/tree/main/packages/common): shared domain · Cross-cutting reusable code shared by services · `packages/common`
- [Database](https://github.com/code100x/dpin-uptime/tree/main/packages/db): prisma package · Database schema, migrations, and seed data · `packages/db`
- [Prisma schema](https://github.com/code100x/dpin-uptime/blob/main/packages/db/prisma/schema.prisma): schema source · Source of truth for the data model · `packages/db/prisma/schema.prisma`
- [Migrations](https://github.com/code100x/dpin-uptime/tree/main/packages/db/prisma/migrations): schema history · Database evolution and applied migration history · `packages/db/prisma/migrations`
- [UI kit](https://github.com/code100x/dpin-uptime/tree/main/packages/ui): react library · Shared presentation primitives for multiple apps · `packages/ui`
- [Primitives](https://github.com/code100x/dpin-uptime/tree/main/packages/ui/src): ui components · Reusable button, card, and code components · `packages/ui/src`
- [ESLint config](https://github.com/code100x/dpin-uptime/tree/main/packages/eslint-config): lint config · Shared lint rules for the monorepo · `packages/eslint-config`
- [TS config](https://github.com/code100x/dpin-uptime/tree/main/packages/typescript-config): typescript config · Shared TypeScript presets for base, React, and Next.js · `packages/typescript-config`

### Other components

- [Turborepo](https://github.com/code100x/dpin-uptime/blob/main/turbo.json): build orchestration · Monorepo task runner and cache coordinator · `turbo.json`

## Connections

- Turborepo → Frontend: builds · Coordinates tasks for the frontend app
- Turborepo → API: builds · Coordinates tasks for the API service
- Turborepo → Hub: builds · Coordinates tasks for the hub service
- Turborepo → Validator: builds · Coordinates tasks for the validator service
- Turborepo → Common: builds · Coordinates shared package tasks
- Turborepo → Database: builds · Coordinates database package tasks
- Frontend → App routes: contains · Next.js App Router pages and routes
- Frontend → App UI: contains · App-specific layout and theme components
- Frontend → Data hooks: contains · Client-side data hooks
- Frontend → UI kit: uses · Builds on shared UI primitives
- Frontend → API: calls · Fetches domain data from the backend API
- API → Database: reads/writes · Persists domain data through the database layer
- API → Common: uses · Shares domain code and utilities
- Hub → Common: uses · Shares domain code and utilities
- Hub → Database: uses · Coordinates work against the shared data model
- Validator → Common: uses · Shares domain code and utilities
- Validator → Database: uses · Validates against the shared data model
- Database → Prisma schema: defines · Prisma schema defines the data model
- Database → Migrations: evolves · Migration history tracks schema changes
- App UI → UI kit: wraps · App-specific components compose shared primitives
- Frontend → ESLint config: inherits · Uses shared lint configuration
- Frontend → TS config: inherits · Uses shared TypeScript configuration
- API → TS config: inherits · Uses shared TypeScript configuration
- Hub → TS config: inherits · Uses shared TypeScript configuration
- Validator → TS config: inherits · Uses shared TypeScript configuration
- UI kit → ESLint config: inherits · Uses shared lint configuration
- UI kit → TS config: inherits · Uses shared TypeScript configuration
