# rig-360-media/rig-forge architecture

> Architecture diagram of the GitHub repository rig-360-media/rig-forge, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/rig-360-media/rig-forge
- Repository: https://github.com/rig-360-media/rig-forge

## Overview

RIG Forge is an internal workforce platform combining project and task management, communication, and AI assistance. A user signs in, works through dashboard features backed by API routes and tenant-scoped PostgreSQL, and can use Forgie to query operational data or propose confirmed actions. Distinct branches cover native chat, reporting and scheduled operations, and Google, GitHub, NAS, and WhatsApp integrations. The README documents overall behavior; source excerpts and the SOURCE INDEX support selected internal calls, so unsampled route-level wiring is not expanded.

Main entry points: [`app/api/assistant/message/route.ts`](https://github.com/rig-360-media/rig-forge/blob/main/app/api/assistant/message/route.ts) (Assistant message API), [`app/dashboard/page.tsx`](https://github.com/rig-360-media/rig-forge/blob/main/app/dashboard/page.tsx) (Web dashboard), [`lib/db.ts`](https://github.com/rig-360-media/rig-forge/blob/main/lib/db.ts) (PostgreSQL store), [`lib/chat/service.ts`](https://github.com/rig-360-media/rig-forge/blob/main/lib/chat/service.ts) (Chat service)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_access["Access and tenancy"]
  node_dashboard["Web dashboard<br/>[page.tsx]"]
  node_auth_ui["Sign-in UI<br/>[page.tsx]"]
  node_auth_api["Authentication API<br/>[route.ts]"]
  node_auth_core["Session and roles<br/>[auth.ts]"]
  node_tenant["Tenant context<br/>[tenant-context.ts]"]
  node_database[("PostgreSQL store<br/>[db.ts]")]
end

subgraph group_work["Work management"]
  node_projects["Projects<br/>[route.ts]"]
  node_tasks["Tasks<br/>[route.ts]"]
  node_tickets["Ticket workflow<br/>[route.ts]"]
  node_threads["Project/task threads<br/>[threads.ts]"]
end

subgraph group_communication["Communication"]
  node_chat_ui["Native chat UI<br/>[ChatApp.tsx]"]
  node_chat_service["Chat service<br/>[service.ts]"]
  node_realtime(("Supabase Realtime"))
end

subgraph group_assistant["Forgie assistant"]
  node_forgie_ui["Forgie interface<br/>[ForgieChat.tsx]"]
  node_forgie_route["Assistant message API<br/>[route.ts]"]
  node_forgie_context["Context and prompts<br/>[context.ts]"]
  node_forgie_tools["Assistant tools<br/>[ai-sdk-tools.ts]"]
  node_llm["LLM providers<br/>[stream.ts]"]
end

subgraph group_operations["Operations and integrations"]
  node_reports["Weekly reports<br/>[route.ts]"]
  node_scheduled["Scheduled jobs<br/>[route.ts]"]
  node_integrations["Google, GitHub, NAS<br/>[index.ts]"]
  node_whatsapp["WhatsApp bridge<br/>[index.js]"]
  node_push["Web Push<br/>[send.ts]"]
end

node_user(("Team member"))

node_user -->|"signs in"| node_auth_ui
node_auth_ui -->|"submits credentials"| node_auth_api
node_auth_api -.->|"verifies session"| node_auth_core
node_auth_core -->|"sets organization"| node_tenant
node_tenant -->|"scopes queries"| node_database
node_user -->|"uses"| node_dashboard
node_dashboard -.->|"manages projects"| node_projects
node_dashboard -.->|"manages tasks"| node_tasks
node_dashboard -.->|"manages tickets"| node_tickets
node_dashboard -.->|"views discussions"| node_threads
node_projects -->|"reads and writes"| node_database
node_projects -.->|"supports lifecycle"| node_tasks
node_tasks -->|"reads and writes"| node_database
node_reports -.->|"aggregates data"| node_database
node_scheduled -->|"delivers digest"| node_user
node_user -->|"communicates"| node_chat_ui
node_chat_ui -.->|"uses chat API"| node_chat_service
node_chat_service -->|"reads and writes"| node_database
node_chat_service -->|"separates live delivery"| node_realtime
node_user -->|"asks Forgie"| node_forgie_ui
node_forgie_ui -.->|"sends message"| node_forgie_route
node_forgie_route -->|"builds context"| node_forgie_context
node_forgie_route -->|"dispatches tools"| node_forgie_tools
node_forgie_route -->|"starts streaming"| node_llm
node_forgie_tools -->|"invokes capabilities"| node_integrations
node_whatsapp -->|"routes inbound messages"| node_forgie_route
node_scheduled -.->|"generates assistant drafts"| node_forgie_route
node_chat_service -->|"sends notifications"| node_push

click node_dashboard "https://github.com/rig-360-media/rig-forge/blob/main/app/dashboard/page.tsx"
click node_auth_ui "https://github.com/rig-360-media/rig-forge/blob/main/app/(auth)/login/page.tsx"
click node_auth_api "https://github.com/rig-360-media/rig-forge/blob/main/app/api/auth/login/route.ts"
click node_auth_core "https://github.com/rig-360-media/rig-forge/blob/main/lib/auth.ts"
click node_tenant "https://github.com/rig-360-media/rig-forge/blob/main/lib/tenant-context.ts"
click node_database "https://github.com/rig-360-media/rig-forge/blob/main/lib/db.ts"
click node_projects "https://github.com/rig-360-media/rig-forge/blob/main/app/api/projects/route.ts"
click node_tasks "https://github.com/rig-360-media/rig-forge/blob/main/app/api/tasks/route.ts"
click node_tickets "https://github.com/rig-360-media/rig-forge/blob/main/app/api/tickets/route.ts"
click node_threads "https://github.com/rig-360-media/rig-forge/blob/main/lib/threads.ts"
click node_reports "https://github.com/rig-360-media/rig-forge/blob/main/app/api/reports/generate/route.ts"
click node_scheduled "https://github.com/rig-360-media/rig-forge/blob/main/app/api/cron/standup-digest/route.ts"
click node_chat_ui "https://github.com/rig-360-media/rig-forge/blob/main/components/chat/ChatApp.tsx"
click node_chat_service "https://github.com/rig-360-media/rig-forge/blob/main/lib/chat/service.ts"
click node_forgie_ui "https://github.com/rig-360-media/rig-forge/blob/main/components/assistant/ForgieChat.tsx"
click node_forgie_route "https://github.com/rig-360-media/rig-forge/blob/main/app/api/assistant/message/route.ts"
click node_forgie_context "https://github.com/rig-360-media/rig-forge/blob/main/lib/assistant/context.ts"
click node_forgie_tools "https://github.com/rig-360-media/rig-forge/blob/main/lib/assistant/ai-sdk-tools.ts"
click node_llm "https://github.com/rig-360-media/rig-forge/blob/main/lib/llm/stream.ts"
click node_integrations "https://github.com/rig-360-media/rig-forge/blob/main/lib/assistant/tools/index.ts"
click node_whatsapp "https://github.com/rig-360-media/rig-forge/blob/main/whatsapp-bridge/index.js"
click node_push "https://github.com/rig-360-media/rig-forge/blob/main/lib/push/send.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_dashboard,node_auth_ui,node_auth_api,node_auth_core,node_tenant,node_database toneBlue
class node_projects,node_tasks,node_tickets,node_threads toneAmber
class node_chat_ui,node_chat_service,node_realtime toneMint
class node_forgie_ui,node_forgie_route,node_forgie_context,node_forgie_tools,node_llm toneRose
class node_reports,node_scheduled,node_integrations,node_whatsapp,node_push,node_user toneIndigo
```

## Components

### Access and tenancy

- [Web dashboard](https://github.com/rig-360-media/rig-forge/blob/main/app/dashboard/page.tsx): `app/dashboard/page.tsx`
- [Sign-in UI](https://github.com/rig-360-media/rig-forge/blob/main/app/(auth)/login/page.tsx): `app/(auth)/login/page.tsx`
- [Authentication API](https://github.com/rig-360-media/rig-forge/blob/main/app/api/auth/login/route.ts): `app/api/auth/login/route.ts`
- [Session and roles](https://github.com/rig-360-media/rig-forge/blob/main/lib/auth.ts): `lib/auth.ts`
- [Tenant context](https://github.com/rig-360-media/rig-forge/blob/main/lib/tenant-context.ts): `lib/tenant-context.ts`
- [PostgreSQL store](https://github.com/rig-360-media/rig-forge/blob/main/lib/db.ts): `lib/db.ts`

### Work management

- [Projects](https://github.com/rig-360-media/rig-forge/blob/main/app/api/projects/route.ts): `app/api/projects/route.ts`
- [Tasks](https://github.com/rig-360-media/rig-forge/blob/main/app/api/tasks/route.ts): `app/api/tasks/route.ts`
- [Ticket workflow](https://github.com/rig-360-media/rig-forge/blob/main/app/api/tickets/route.ts): `app/api/tickets/route.ts`
- [Project/task threads](https://github.com/rig-360-media/rig-forge/blob/main/lib/threads.ts): `lib/threads.ts`

### Communication

- [Native chat UI](https://github.com/rig-360-media/rig-forge/blob/main/components/chat/ChatApp.tsx): `components/chat/ChatApp.tsx`
- [Chat service](https://github.com/rig-360-media/rig-forge/blob/main/lib/chat/service.ts): `lib/chat/service.ts`
- **Supabase Realtime**

### Forgie assistant

- [Forgie interface](https://github.com/rig-360-media/rig-forge/blob/main/components/assistant/ForgieChat.tsx): `components/assistant/ForgieChat.tsx`
- [Assistant message API](https://github.com/rig-360-media/rig-forge/blob/main/app/api/assistant/message/route.ts): `app/api/assistant/message/route.ts`
- [Context and prompts](https://github.com/rig-360-media/rig-forge/blob/main/lib/assistant/context.ts): `lib/assistant/context.ts`
- [Assistant tools](https://github.com/rig-360-media/rig-forge/blob/main/lib/assistant/ai-sdk-tools.ts): `lib/assistant/ai-sdk-tools.ts`
- [LLM providers](https://github.com/rig-360-media/rig-forge/blob/main/lib/llm/stream.ts): `lib/llm/stream.ts`

### Operations and integrations

- [Weekly reports](https://github.com/rig-360-media/rig-forge/blob/main/app/api/reports/generate/route.ts): `app/api/reports/generate/route.ts`
- [Scheduled jobs](https://github.com/rig-360-media/rig-forge/blob/main/app/api/cron/standup-digest/route.ts): `app/api/cron/standup-digest/route.ts`
- [Google, GitHub, NAS](https://github.com/rig-360-media/rig-forge/blob/main/lib/assistant/tools/index.ts): `lib/assistant/tools/index.ts`
- [WhatsApp bridge](https://github.com/rig-360-media/rig-forge/blob/main/whatsapp-bridge/index.js): `whatsapp-bridge/index.js`
- [Web Push](https://github.com/rig-360-media/rig-forge/blob/main/lib/push/send.ts): `lib/push/send.ts`

### Other components

- **Team member**

## Connections

- Team member → Sign-in UI: signs in (evidence: `README.md`)
- Sign-in UI → Authentication API: submits credentials (evidence: `app/(auth)/login/page.tsx`)
- Authentication API → Session and roles: verifies session
- Session and roles → Tenant context: sets organization (evidence: `lib/auth.ts`)
- Tenant context → PostgreSQL store: scopes queries (evidence: `lib/db.ts`)
- Team member → Web dashboard: uses (evidence: `README.md`)
- Web dashboard → Projects: manages projects
- Web dashboard → Tasks: manages tasks
- Web dashboard → Ticket workflow: manages tickets
- Web dashboard → Project/task threads: views discussions
- Projects → PostgreSQL store: reads and writes (evidence: `app/api/projects/route.ts`)
- Projects → Tasks: supports lifecycle
- Tasks → PostgreSQL store: reads and writes (evidence: `app/api/tasks/route.ts`)
- Weekly reports → PostgreSQL store: aggregates data (evidence: `app/api/reports/generate/route.ts`)
- Scheduled jobs → Team member: delivers digest (evidence: `README.md`)
- Team member → Native chat UI: communicates (evidence: `README.md`)
- Native chat UI → Chat service: uses chat API
- Chat service → PostgreSQL store: reads and writes (evidence: `lib/chat/service.ts`)
- Chat service → Supabase Realtime: separates live delivery (evidence: `lib/chat/service.ts`)
- Team member → Forgie interface: asks Forgie (evidence: `README.md`)
- Forgie interface → Assistant message API: sends message
- Assistant message API → Context and prompts: builds context (evidence: `app/api/assistant/message/route.ts`)
- Assistant message API → Assistant tools: dispatches tools (evidence: `app/api/assistant/message/route.ts`)
- Assistant message API → LLM providers: starts streaming (evidence: `app/api/assistant/message/route.ts`)
- Assistant tools → Google, GitHub, NAS: invokes capabilities (evidence: `lib/assistant/ai-sdk-tools.ts`)
- WhatsApp bridge → Assistant message API: routes inbound messages (evidence: `README.md`)
- Scheduled jobs → Assistant message API: generates assistant drafts
- Chat service → Web Push: sends notifications (evidence: `lib/chat/service.ts`)
