# theanuragg/uptime-monitoring architecture

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

- Interactive diagram: https://gitdiagram.com/theanuragg/uptime-monitoring
- Repository: https://github.com/theanuragg/uptime-monitoring

## Overview

##### Project type and purpose
- This is a monorepo full‑stack SaaS uptime monitoring platform (“DPin Uptime”).
- It comprises:
- A Next.js web frontend (apps/web) for users to sign up, view dashboards and manage services
- A RESTful API (apps/Api) serving website status data, handling auth and rate limiting
- Background services: a “Validator” (apps/Validator) that periodically polls user websites and records status, and a “Hub” (apps/Hub) that processes events (e.g., sending notification emails)
- Shared packages for common utilities, database access (Prisma), UI components, and configuration

##### File structure
- Top‑level “apps/” folder holds four runnable applications:
- web – Next.js front end
- Api – HTTP API built with Bun/TypeScript
- Validator – scheduled worker pinging websites
- Hub – event handler, e.g., email notifications
- “packages/” folder holds reusable libraries:
- Common – shared helper functions
- Db – Prisma schema and migration scripts
- eslint-config & typescript-config – lint and TS presets
- ui – shared React UI primitives
- Turbo.json and lock files indicate use of a Turborepo monorepo with workspace hoisting
- Config files (tsconfig.json, next.config.js, package.json) define build and deployment

##### README for additional insight
- It confirms this is a SaaS uptime monitoring tool with a landing page in development
- Future needs will include multi‑tenant support, alerts, email integration

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% External User
    User["User"]:::external

    %% Frontend Layer
    subgraph "Web Frontend"
        Web["Web Frontend (Next.js)"]:::frontend
    end

    %% API Layer
    subgraph "API Service (apps/Api)"
        Controllers["Controllers"]:::backend
        Routes["Routes"]:::backend
        Middlewares["Middlewares"]:::backend
        API["API Service"]:::frontend
    end

    %% Workers Layer
    subgraph "Background Workers"
        Validator["Validator Worker"]:::workers
        Hub["Hub Worker"]:::workers
    end

    %% Database
    DB["PostgreSQL Database"]:::database

    %% External Integrations
    subgraph "External Services"
        Auth["Auth Provider (Clerk)"]:::external
        Email["Email Service"]:::external
    end

    %% Shared Packages
    subgraph "Shared Packages"
        Common["Common Utilities"]:::shared
        UI["UI Primitives"]:::shared
        DbPkg["Db Package"]:::shared
        Migrations["prisma/migrations"]:::shared
        ESLint_Config["ESLint Config Presets"]:::shared
        TSConfig["TypeScript Config Presets"]:::shared
    end

    %% Data Flows
    User -->|"browses / interacts"| Web
    Web -->|"HTTP(S) requests"| API
    API -->|"CRUD operations"| DB
    Validator -->|"writes status records"| DB
    DB -->|"triggers events"| Hub
    Hub -->|"sends emails"| Email

    %% API Internal Flows
    API --> Controllers
    API --> Routes
    API --> Middlewares
    Middlewares --> Auth

    %% Shared Imports
    Web -.-> Common
    Web -.-> UI
    API -.-> Common
    API -.-> DbPkg
    Validator -.-> Common
    Validator -.-> DbPkg
    Hub -.-> Common
    Hub -.-> DbPkg
    API -.-> ESLint_Config
    API -.-> TSConfig
    Web -.-> ESLint_Config
    Web -.-> TSConfig
    Validator -.-> ESLint_Config
    Validator -.-> TSConfig
    Hub -.-> ESLint_Config
    Hub -.-> TSConfig

    %% Click Events
    click Web "https://github.com/theanuragg/uptime-monitoring/tree/main/apps/web"
    click API "https://github.com/theanuragg/uptime-monitoring/tree/main/apps/Api"
    click Validator "https://github.com/theanuragg/uptime-monitoring/tree/main/apps/Validator"
    click Hub "https://github.com/theanuragg/uptime-monitoring/tree/main/apps/Hub"
    click DbPkg "https://github.com/theanuragg/uptime-monitoring/tree/main/packages/Db"
    click Migrations "https://github.com/theanuragg/uptime-monitoring/tree/main/packages/Db/prisma/migrations"
    click Common "https://github.com/theanuragg/uptime-monitoring/tree/main/packages/Common"
    click UI "https://github.com/theanuragg/uptime-monitoring/tree/main/packages/ui"
    click Controllers "https://github.com/theanuragg/uptime-monitoring/tree/main/apps/Api/Controller"
    click Routes "https://github.com/theanuragg/uptime-monitoring/tree/main/apps/Api/Routes"
    click Middlewares "https://github.com/theanuragg/uptime-monitoring/tree/main/apps/Api/middlewares"
    click ESLint_Config "https://github.com/theanuragg/uptime-monitoring/tree/main/packages/eslint-config"
    click TSConfig "https://github.com/theanuragg/uptime-monitoring/tree/main/packages/typescript-config"

    %% Styles
    classDef frontend fill:#ADD8E6,stroke:#000
    classDef backend fill:#ADD8E6,stroke:#000
    classDef workers fill:#90EE90,stroke:#000
    classDef database fill:#D3D3D3,stroke:#000
    classDef external fill:#F0E68C,stroke:#000
    classDef shared fill:#FFDAB9,stroke:#000
```
