# axissxs/vellum architecture

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

- Interactive diagram: https://gitdiagram.com/axissxs/vellum
- Repository: https://github.com/axissxs/vellum

## Overview

#### 1. Purpose and entry points
Vellum is a self-hostable team-management platform: teams own projects, projects contain Kanban tasks and milestones, and users collaborate through comments, notifications, activity, and optional Telegram/push delivery. The Next.js App Router starts at `src/app/page.tsx`; login and first-run setup are `src/app/login/page.tsx` and `src/app/setup/page.tsx`. Authenticated UI is rooted in `src/app/dashboard/layout.tsx`.

#### 2. Application and UI boundary
Server-rendered routes and client dashboard views are colocated under `src/app`. The dashboard is organized by operational domains—overview, tasks, teams, projects, activity, settings, admin, and super-admin—with interactive clients such as `src/app/dashboard/projects/[id]/KanbanBoard.tsx`, `src/app/dashboard/kanban/KanbanBoardClient.tsx`, and `src/app/dashboard/super-admin/SuperAdminClient.tsx`. Shared React state/data-fetching setup enters via `src/providers/QueryProvider.tsx`; domain hooks bridge browser UI to API endpoints, e.g. `src/hooks/useTasks.ts` and `src/hooks/useProjects.ts`.

#### 3. HTTP API and authorization
Route handlers in `src/app/api` form the primary backend boundary. Core CRUD resources include tasks, projects, teams, users, comments, milestones, activity, stats, and notifications; representative paths are `src/app/api/tasks/route.ts`, `src/app/api/projects/[id]/route.ts`, and `src/app/api/teams/[id]/members/route.ts`. Session lifecycle is handled by `src/app/api/auth/login/route.ts`, `src/app/api/auth/logout/route.ts`, and `src/lib/auth.ts`. The API must enforce the role model (Superadmin/Admin/Member) before exposing tenant/team data or mutations.

#### 4. Work-management data flow
Typical browser flow is: dashboard client/hook → typed API utility → App Router handler → Drizzle database operation → returned resource and refresh/realtime event. Tasks are the central work item, rendered in project and global Kanban views and linked to comments, assignees, priorities, statuses, dates, and milestones. Important UI/API seams are `src/app/dashboard/projects/[id]/TaskDetailModal.tsx`, `src/hooks/useComments.ts`, and `src/app/api/comments/[id]/route.ts`.

#### 5. Persistence, initialization, and deployment
PostgreSQL (including Neon) is the durable system of record, accessed through Drizzle. Schema and connection layer are `src/db/schema.ts` and `src/db/index.ts`; request-time/initial bootstrap is `src/db/bootstrap.ts`. Versioned schema history is committed under `drizzle/`, with migrations applied through deployment automation at `.github/workflows/apply-migrations.yml`. The app targets Node.js/Next.js on Vercel, with pooled and direct database URLs required.

#### 6. Collaboration and outbound integrations
Notification state is served from `src/app/api/notifications/route.ts`; browser push subscription/preferences use `src/app/api/push/subscribe/route.ts` and `src/lib/push.ts`, with service-worker support in `public/sw.js`. Realtime architecture is backed by Pusher adapters in `src/lib/pusher.ts` and `src/lib/pusher-broadcast.ts`, consumed by `src/hooks/useRealtime.ts`. Telegram pairing, webhook ingestion, and delivery/configuration are isolated behind `src/app/api/telegram/webhook/route.ts`, `src/app/api/telegram/pairing-code/route.ts`, and `src/lib/telegram.ts`.

#### 7. Governance and privileged operations
Activity/audit recording is a cross-cutting concern represented by `src/lib/audit.ts` and user-facing activity APIs. Super-admin routes segregate sensitive operations—users, session revocation, audit export, health, permission management, restore/trash, and Telegram administration—under `src/app/api/super-admin/`. Key control-plane endpoints include `src/app/api/super-admin/audit/export/route.ts`, `src/app/api/super-admin/sessions/[id]/route.ts`, and `src/app/api/super-admin/restore/route.ts`.

Main entry points: [`src/app/api/tasks/route.ts`](https://github.com/axissxs/vellum/blob/master/src/app/api/tasks/route.ts) (Resource route handlers), [`src/providers/QueryProvider.tsx`](https://github.com/axissxs/vellum/blob/master/src/providers/QueryProvider.tsx) (Query state & domain hooks), [`src/db/index.ts`](https://github.com/axissxs/vellum/blob/master/src/db/index.ts) (Drizzle persistence), [`src/app/api/super-admin/audit/export/route.ts`](https://github.com/axissxs/vellum/blob/master/src/app/api/super-admin/audit/export/route.ts) (Super-admin control plane)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["Next.js UI"]
  node_entry["Public entry &amp; setup<br/>App Router pages<br/>[page.tsx]"]
  node_dashboard["Dashboard shell<br/>authenticated UI<br/>[layout.tsx]"]
  node_kanban["Kanban &amp; task detail<br/>interactive dashboard<br/>[KanbanBoard.tsx]"]
  node_query["Query state &amp; domain hooks<br/>client data layer<br/>[QueryProvider.tsx]"]
end

subgraph group_api["Application API"]
  node_api_routes["Resource route handlers<br/>App Router API<br/>[route.ts]"]
  node_auth{{"Session auth &amp; roles<br/>authorization<br/>[auth.ts]"}}
  node_tasks["Tasks &amp; comments<br/>work-management API<br/>[route.ts]"]
end

subgraph group_data["Data &amp; deployment"]
  node_database[("Drizzle persistence<br/>database access<br/>[index.ts]")]
  node_postgres[("PostgreSQL / Neon<br/>system of record")]
  node_migrations["Schema migrations<br/>deployment pipeline"]
  node_vercel(("Vercel Node runtime<br/>hosting platform"))
end

subgraph group_collab["Collaboration"]
  node_notifications["Notifications &amp; push<br/>outbound delivery<br/>[route.ts]"]
  node_realtime["Pusher realtime<br/>event delivery"]
  node_telegram["Telegram integration<br/>webhook and delivery<br/>[route.ts]"]
end

subgraph group_control["Governance"]
  node_audit["Audit activity<br/>cross-cutting record<br/>[audit.ts]"]
  node_superadmin{{"Super-admin control plane<br/>privileged API<br/>[route.ts]"}}
end

node_entry -->|"authenticated access"| node_dashboard
node_dashboard -->|"renders"| node_kanban
node_dashboard -->|"provides query state"| node_query
node_kanban -->|"uses task data"| node_query
node_query -->|"typed HTTP calls"| node_api_routes
node_api_routes -->|"authorizes requests"| node_auth
node_api_routes -->|"routes work operations"| node_tasks
node_api_routes -->|"reads and mutates"| node_database
node_tasks -->|"persists work data"| node_database
node_database -->|"Drizzle queries"| node_postgres
node_migrations -->|"applies schema history"| node_postgres
node_api_routes -->|"serves notification state"| node_notifications
node_api_routes -->|"publishes refresh events"| node_realtime
node_realtime -->|"triggers client refresh"| node_query
node_notifications -->|"broadcasts updates"| node_realtime
node_api_routes -->|"integration endpoints"| node_telegram
node_api_routes -.->|"records activity"| node_audit
node_superadmin -->|"requires superadmin role"| node_auth
node_superadmin -->|"administeres data"| node_database
node_superadmin -->|"exports and reviews"| node_audit
node_vercel -->|"hosts"| node_entry
node_vercel -->|"runs handlers"| node_api_routes

click node_entry "https://github.com/axissxs/vellum/blob/master/src/app/page.tsx"
click node_dashboard "https://github.com/axissxs/vellum/blob/master/src/app/dashboard/layout.tsx"
click node_kanban "https://github.com/axissxs/vellum/blob/master/src/app/dashboard/projects/%5Bid%5D/KanbanBoard.tsx"
click node_query "https://github.com/axissxs/vellum/blob/master/src/providers/QueryProvider.tsx"
click node_api_routes "https://github.com/axissxs/vellum/blob/master/src/app/api/tasks/route.ts"
click node_auth "https://github.com/axissxs/vellum/blob/master/src/lib/auth.ts"
click node_tasks "https://github.com/axissxs/vellum/blob/master/src/app/api/comments/%5Bid%5D/route.ts"
click node_database "https://github.com/axissxs/vellum/blob/master/src/db/index.ts"
click node_migrations "https://github.com/axissxs/vellum/blob/master/.github/workflows/apply-migrations.yml"
click node_notifications "https://github.com/axissxs/vellum/blob/master/src/app/api/notifications/route.ts"
click node_realtime "https://github.com/axissxs/vellum/blob/master/src/lib/pusher-broadcast.ts"
click node_telegram "https://github.com/axissxs/vellum/blob/master/src/app/api/telegram/webhook/route.ts"
click node_audit "https://github.com/axissxs/vellum/blob/master/src/lib/audit.ts"
click node_superadmin "https://github.com/axissxs/vellum/blob/master/src/app/api/super-admin/audit/export/route.ts"

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_entry,node_dashboard,node_kanban,node_query toneBlue
class node_api_routes,node_auth,node_tasks toneAmber
class node_database,node_postgres,node_migrations,node_vercel toneMint
class node_notifications,node_realtime,node_telegram toneRose
class node_audit,node_superadmin toneIndigo
```

## Components

### Next.js UI

- [Public entry & setup](https://github.com/axissxs/vellum/blob/master/src/app/page.tsx): App Router pages · Landing, login, and first-run setup. · `src/app/page.tsx`
- [Dashboard shell](https://github.com/axissxs/vellum/blob/master/src/app/dashboard/layout.tsx): authenticated UI · Root for operational dashboard domains. · `src/app/dashboard/layout.tsx`
- [Kanban & task detail](https://github.com/axissxs/vellum/blob/master/src/app/dashboard/projects/%5Bid%5D/KanbanBoard.tsx): interactive dashboard · Project and global task workflows. · `src/app/dashboard/projects/[id]/KanbanBoard.tsx`
- [Query state & domain hooks](https://github.com/axissxs/vellum/blob/master/src/providers/QueryProvider.tsx): client data layer · Hooks connect dashboard views to typed API calls. · `src/providers/QueryProvider.tsx`

### Application API

- [Resource route handlers](https://github.com/axissxs/vellum/blob/master/src/app/api/tasks/route.ts): App Router API · CRUD for tasks, projects, teams, comments, milestones, activity, stats, and notifications. · `src/app/api/tasks/route.ts`
- [Session auth & roles](https://github.com/axissxs/vellum/blob/master/src/lib/auth.ts): authorization · Enforces Superadmin, Admin, and Member access. · `src/lib/auth.ts`
- [Tasks & comments](https://github.com/axissxs/vellum/blob/master/src/app/api/comments/%5Bid%5D/route.ts): work-management API · Central work items link assignees, status, priority, dates, milestones, and comments. · `src/app/api/comments/[id]/route.ts`

### Data & deployment

- [Drizzle persistence](https://github.com/axissxs/vellum/blob/master/src/db/index.ts): database access · Schema, connection, and request-time bootstrap. · `src/db/index.ts`
- **PostgreSQL / Neon**: system of record
- [Schema migrations](https://github.com/axissxs/vellum/blob/master/.github/workflows/apply-migrations.yml): deployment pipeline · Versioned migrations are applied by GitHub Actions. · `.github/workflows/apply-migrations.yml`
- **Vercel Node runtime**: hosting platform · Runs the Next.js application.

### Collaboration

- [Notifications & push](https://github.com/axissxs/vellum/blob/master/src/app/api/notifications/route.ts): outbound delivery · Stores notification state and manages browser subscriptions. · `src/app/api/notifications/route.ts`
- [Pusher realtime](https://github.com/axissxs/vellum/blob/master/src/lib/pusher-broadcast.ts): event delivery · Broadcast adapters feed dashboard realtime hooks. · `src/lib/pusher-broadcast.ts`
- [Telegram integration](https://github.com/axissxs/vellum/blob/master/src/app/api/telegram/webhook/route.ts): webhook and delivery · Handles pairing, webhook ingestion, and Telegram delivery. · `src/app/api/telegram/webhook/route.ts`

### Governance

- [Audit activity](https://github.com/axissxs/vellum/blob/master/src/lib/audit.ts): cross-cutting record · Records governance-relevant activity. · `src/lib/audit.ts`
- [Super-admin control plane](https://github.com/axissxs/vellum/blob/master/src/app/api/super-admin/audit/export/route.ts): privileged API · Manages users, sessions, permissions, restore, health, audit export, and Telegram administration. · `src/app/api/super-admin/audit/export/route.ts`

## Connections

- Public entry & setup → Dashboard shell: authenticated access
- Dashboard shell → Kanban & task detail: renders
- Dashboard shell → Query state & domain hooks: provides query state
- Kanban & task detail → Query state & domain hooks: uses task data
- Query state & domain hooks → Resource route handlers: typed HTTP calls
- Resource route handlers → Session auth & roles: authorizes requests
- Resource route handlers → Tasks & comments: routes work operations
- Resource route handlers → Drizzle persistence: reads and mutates
- Tasks & comments → Drizzle persistence: persists work data
- Drizzle persistence → PostgreSQL / Neon: Drizzle queries
- Schema migrations → PostgreSQL / Neon: applies schema history
- Resource route handlers → Notifications & push: serves notification state
- Resource route handlers → Pusher realtime: publishes refresh events
- Pusher realtime → Query state & domain hooks: triggers client refresh
- Notifications & push → Pusher realtime: broadcasts updates
- Resource route handlers → Telegram integration: integration endpoints
- Resource route handlers → Audit activity: records activity
- Super-admin control plane → Session auth & roles: requires superadmin role
- Super-admin control plane → Drizzle persistence: administeres data
- Super-admin control plane → Audit activity: exports and reviews
- Vercel Node runtime → Public entry & setup: hosts
- Vercel Node runtime → Resource route handlers: runs handlers
