# vaibhavnaiyar/betteruptime architecture

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

- Interactive diagram: https://gitdiagram.com/vaibhavnaiyar/betteruptime
- Repository: https://github.com/vaibhavnaiyar/betteruptime

## Overview

BetterUptime is a website-availability monitor. A user signs up or signs in, then adds monitored URLs and views recent check status and response times. The API stores monitor records; a recurring pusher queues URLs, and workers check them and persist ticks for the dashboard to retrieve. The repository excerpts show the API, web client, pusher, and worker interactions; Redis-stream internals and the Prisma schema were not excerpted, so those connections are limited to the visible imports and calls.

Main entry points: [`packages/store/index.ts`](https://github.com/vaibhavnaiyar/betteruptime/blob/main/packages/store/index.ts) (Store client), [`apps/web/lib/api.ts`](https://github.com/vaibhavnaiyar/betteruptime/blob/main/apps/web/lib/api.ts) (API client), [`apps/worker/index.ts`](https://github.com/vaibhavnaiyar/betteruptime/blob/main/apps/worker/index.ts) (Check worker), [`apps/api/routes/v1/index.ts`](https://github.com/vaibhavnaiyar/betteruptime/blob/main/apps/api/routes/v1/index.ts) (V1 router)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web app"]
  node_landing["Landing page<br/>[page.tsx]"]
  node_signup["Sign-up page<br/>[page.tsx]"]
  node_signin["Sign-in page<br/>[page.tsx]"]
  node_dashboard["Dashboard<br/>[page.tsx]"]
  node_webclient["API client<br/>[api.ts]"]
end

subgraph group_api["API"]
  node_apiapp["API server<br/>[index.ts]"]
  node_router["V1 router<br/>[index.ts]"]
  node_authroutes["User routes<br/>[user.ts]"]
  node_monroutes["Website routes<br/>[website.ts]"]
  node_authmw["Token middleware<br/>[auth.ts]"]
end

subgraph group_monitoring["Monitoring pipeline"]
  node_pusher["Monitor pusher<br/>[index.ts]"]
  node_worker["Check worker<br/>[index.ts]"]
  node_streamlib["Stream client<br/>[index.ts]"]
  node_redis["Redis stream"]
end

subgraph group_data["Persistence"]
  node_storelib["Store client<br/>[index.ts]"]
  node_database[("Prisma database<br/>[schema.prisma]")]
end

node_user(("User"))
node_website(("Monitored website"))

node_user -->|"visits"| node_landing
node_user -->|"registers"| node_signup
node_user -->|"signs in"| node_signin
node_user -->|"manages monitors"| node_dashboard
node_signup -->|"calls signup/signin"| node_webclient
node_signin -->|"calls signin"| node_webclient
node_dashboard -->|"loads and manages"| node_webclient
node_webclient -->|"HTTP requests"| node_apiapp
node_apiapp -->|"mounts routes"| node_router
node_router -->|"registers routes"| node_authroutes
node_router -->|"registers routes"| node_monroutes
node_authroutes -->|"reads/writes users"| node_storelib
node_monroutes -->|"protects endpoints"| node_authmw
node_monroutes -->|"reads/writes monitors"| node_storelib
node_storelib -.->|"accesses"| node_database
node_pusher -->|"loads websites"| node_storelib
node_pusher -->|"queues checks"| node_streamlib
node_streamlib -.->|"writes/reads stream"| node_redis
node_worker -->|"reads and acknowledges"| node_streamlib
node_worker -->|"checks URL"| node_website
node_worker -->|"writes check ticks"| node_storelib

click node_landing "https://github.com/vaibhavnaiyar/betteruptime/blob/main/apps/web/app/page.tsx"
click node_signup "https://github.com/vaibhavnaiyar/betteruptime/blob/main/apps/web/app/signup/page.tsx"
click node_signin "https://github.com/vaibhavnaiyar/betteruptime/blob/main/apps/web/app/signin/page.tsx"
click node_dashboard "https://github.com/vaibhavnaiyar/betteruptime/blob/main/apps/web/app/dashboard/page.tsx"
click node_webclient "https://github.com/vaibhavnaiyar/betteruptime/blob/main/apps/web/lib/api.ts"
click node_apiapp "https://github.com/vaibhavnaiyar/betteruptime/blob/main/apps/api/index.ts"
click node_router "https://github.com/vaibhavnaiyar/betteruptime/blob/main/apps/api/routes/v1/index.ts"
click node_authroutes "https://github.com/vaibhavnaiyar/betteruptime/blob/main/apps/api/routes/v1/user.ts"
click node_monroutes "https://github.com/vaibhavnaiyar/betteruptime/blob/main/apps/api/routes/v1/website.ts"
click node_authmw "https://github.com/vaibhavnaiyar/betteruptime/blob/main/apps/api/middleware/auth.ts"
click node_pusher "https://github.com/vaibhavnaiyar/betteruptime/blob/main/apps/pusher/index.ts"
click node_worker "https://github.com/vaibhavnaiyar/betteruptime/blob/main/apps/worker/index.ts"
click node_streamlib "https://github.com/vaibhavnaiyar/betteruptime/blob/main/packages/redis-stream/index.ts"
click node_storelib "https://github.com/vaibhavnaiyar/betteruptime/blob/main/packages/store/index.ts"
click node_database "https://github.com/vaibhavnaiyar/betteruptime/blob/main/packages/store/prisma/schema.prisma"

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_landing,node_signup,node_signin,node_dashboard,node_webclient,node_user toneBlue
class node_apiapp,node_router,node_authroutes,node_monroutes,node_authmw toneAmber
class node_pusher,node_worker,node_streamlib,node_redis toneMint
class node_storelib,node_database toneRose
class node_website toneIndigo
```

## Components

### Web app

- [Landing page](https://github.com/vaibhavnaiyar/betteruptime/blob/main/apps/web/app/page.tsx): `apps/web/app/page.tsx`
- [Sign-up page](https://github.com/vaibhavnaiyar/betteruptime/blob/main/apps/web/app/signup/page.tsx): `apps/web/app/signup/page.tsx`
- [Sign-in page](https://github.com/vaibhavnaiyar/betteruptime/blob/main/apps/web/app/signin/page.tsx): `apps/web/app/signin/page.tsx`
- [Dashboard](https://github.com/vaibhavnaiyar/betteruptime/blob/main/apps/web/app/dashboard/page.tsx): `apps/web/app/dashboard/page.tsx`
- [API client](https://github.com/vaibhavnaiyar/betteruptime/blob/main/apps/web/lib/api.ts): `apps/web/lib/api.ts`

### API

- [API server](https://github.com/vaibhavnaiyar/betteruptime/blob/main/apps/api/index.ts): `apps/api/index.ts`
- [V1 router](https://github.com/vaibhavnaiyar/betteruptime/blob/main/apps/api/routes/v1/index.ts): `apps/api/routes/v1/index.ts`
- [User routes](https://github.com/vaibhavnaiyar/betteruptime/blob/main/apps/api/routes/v1/user.ts): `apps/api/routes/v1/user.ts`
- [Website routes](https://github.com/vaibhavnaiyar/betteruptime/blob/main/apps/api/routes/v1/website.ts): `apps/api/routes/v1/website.ts`
- [Token middleware](https://github.com/vaibhavnaiyar/betteruptime/blob/main/apps/api/middleware/auth.ts): `apps/api/middleware/auth.ts`

### Monitoring pipeline

- [Monitor pusher](https://github.com/vaibhavnaiyar/betteruptime/blob/main/apps/pusher/index.ts): `apps/pusher/index.ts`
- [Check worker](https://github.com/vaibhavnaiyar/betteruptime/blob/main/apps/worker/index.ts): `apps/worker/index.ts`
- [Stream client](https://github.com/vaibhavnaiyar/betteruptime/blob/main/packages/redis-stream/index.ts): `packages/redis-stream/index.ts`
- **Redis stream**

### Persistence

- [Store client](https://github.com/vaibhavnaiyar/betteruptime/blob/main/packages/store/index.ts): `packages/store/index.ts`
- [Prisma database](https://github.com/vaibhavnaiyar/betteruptime/blob/main/packages/store/prisma/schema.prisma): `packages/store/prisma/schema.prisma`

### Other components

- **User**
- **Monitored website**

## Connections

- User → Landing page: visits (evidence: `apps/web/app/page.tsx`)
- User → Sign-up page: registers (evidence: `apps/web/app/signup/page.tsx`)
- User → Sign-in page: signs in (evidence: `apps/web/app/signin/page.tsx`)
- User → Dashboard: manages monitors (evidence: `apps/web/app/dashboard/page.tsx`)
- Sign-up page → API client: calls signup/signin (evidence: `apps/web/app/signup/page.tsx`)
- Sign-in page → API client: calls signin (evidence: `apps/web/app/signin/page.tsx`)
- Dashboard → API client: loads and manages (evidence: `apps/web/app/dashboard/page.tsx`)
- API client → API server: HTTP requests (evidence: `apps/web/lib/api.ts`)
- API server → V1 router: mounts routes (evidence: `apps/api/index.ts`)
- V1 router → User routes: registers routes (evidence: `apps/api/routes/v1/index.ts`)
- V1 router → Website routes: registers routes (evidence: `apps/api/routes/v1/index.ts`)
- User routes → Store client: reads/writes users (evidence: `apps/api/routes/v1/user.ts`)
- Website routes → Token middleware: protects endpoints (evidence: `apps/api/routes/v1/website.ts`)
- Website routes → Store client: reads/writes monitors (evidence: `apps/api/routes/v1/website.ts`)
- Store client → Prisma database: accesses
- Monitor pusher → Store client: loads websites (evidence: `apps/pusher/index.ts`)
- Monitor pusher → Stream client: queues checks (evidence: `apps/pusher/index.ts`)
- Stream client → Redis stream: writes/reads stream
- Check worker → Stream client: reads and acknowledges (evidence: `apps/worker/index.ts`)
- Check worker → Monitored website: checks URL (evidence: `apps/worker/index.ts`)
- Check worker → Store client: writes check ticks (evidence: `apps/worker/index.ts`)
