# ayush2027-stack/coalgov-ai architecture

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

- Interactive diagram: https://gitdiagram.com/ayush2027-stack/coalgov-ai
- Repository: https://github.com/ayush2027-stack/coalgov-ai

## Overview

CoalGov AI is a mine-governance application for reviewing mine compliance, managing corrective actions, and conducting inspections with evidence and approval workflows. The principal path is the browser dashboard through tRPC procedures to domain data and persistent storage; inspection evidence also uses an external storage service. The sampled code supports the server wiring and several domain operations, but not the dashboard’s internal feature calls. The README is empty, so the UI’s other listed components are not treated as confirmed capabilities.

Main entry points: [`server/routers.ts`](https://github.com/ayush2027-stack/coalgov-ai/blob/main/server/routers.ts) (Governance procedures), [`server.ts`](https://github.com/ayush2027-stack/coalgov-ai/blob/main/server.ts) (Express server), [`client/src/main.tsx`](https://github.com/ayush2027-stack/coalgov-ai/blob/main/client/src/main.tsx) (Client bootstrap), [`server/db.ts`](https://github.com/ayush2027-stack/coalgov-ai/blob/main/server/db.ts) (Database access)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Browser application"]
  node_entry["Client bootstrap<br/>[main.tsx]"]
  node_app["App shell<br/>[App.tsx]"]
  node_dashboard["Governance dashboard<br/>[Home.tsx]"]
  node_trpc_client["tRPC client<br/>[main.tsx]"]
end

subgraph group_api["API and identity"]
  node_http_server["Express server<br/>[server.ts]"]
  node_context["Request context<br/>[context.ts]"]
  node_auth["OAuth routes<br/>[oauth.ts]"]
  node_storage_proxy["Storage proxy<br/>[storageProxy.ts]"]
end

subgraph group_domain["Governance workflows"]
  node_procedures["Governance procedures<br/>[routers.ts]"]
  node_system["System procedures<br/>[systemRouter.ts]"]
  node_mines_compliance["Mines and compliance<br/>[routers.ts]"]
  node_inspections["Inspection lifecycle<br/>[routers.ts]"]
  node_actions_audit["Actions and audit<br/>[routers.ts]"]
end

subgraph group_persistence["Data and files"]
  node_db_access["Database access<br/>[db.ts]"]
  node_schema["Governance schema<br/>[schema.ts]"]
  node_file_storage["Evidence storage<br/>[storage.ts]"]
end

node_operator(("Mine personnel"))
node_mysql[("MySQL database")]
node_forge["Forge storage API"]

node_operator -->|"uses"| node_entry
node_entry -->|"renders"| node_app
node_app -->|"renders"| node_dashboard
node_entry -->|"configures"| node_trpc_client
node_http_server -->|"registers"| node_auth
node_http_server -->|"registers"| node_storage_proxy
node_http_server -->|"mounts"| node_procedures
node_http_server -->|"creates context"| node_context
node_procedures -->|"includes"| node_system
node_procedures -->|"defines"| node_mines_compliance
node_procedures -->|"defines"| node_inspections
node_procedures -->|"defines"| node_actions_audit
node_procedures -->|"queries and writes"| node_db_access
node_procedures -->|"uploads evidence"| node_file_storage
node_db_access -->|"uses tables"| node_schema
node_db_access -->|"reads and writes"| node_mysql
node_file_storage -->|"requests upload URLs"| node_forge
node_storage_proxy -->|"requests download URL"| node_forge

click node_entry "https://github.com/ayush2027-stack/coalgov-ai/blob/main/client/src/main.tsx"
click node_app "https://github.com/ayush2027-stack/coalgov-ai/blob/main/client/src/App.tsx"
click node_dashboard "https://github.com/ayush2027-stack/coalgov-ai/blob/main/client/src/pages/Home.tsx"
click node_trpc_client "https://github.com/ayush2027-stack/coalgov-ai/blob/main/client/src/main.tsx"
click node_http_server "https://github.com/ayush2027-stack/coalgov-ai/blob/main/server.ts"
click node_context "https://github.com/ayush2027-stack/coalgov-ai/blob/main/server/_core/context.ts"
click node_auth "https://github.com/ayush2027-stack/coalgov-ai/blob/main/server/_core/oauth.ts"
click node_procedures "https://github.com/ayush2027-stack/coalgov-ai/blob/main/server/routers.ts"
click node_system "https://github.com/ayush2027-stack/coalgov-ai/blob/main/server/_core/systemRouter.ts"
click node_mines_compliance "https://github.com/ayush2027-stack/coalgov-ai/blob/main/server/routers.ts"
click node_inspections "https://github.com/ayush2027-stack/coalgov-ai/blob/main/server/routers.ts"
click node_actions_audit "https://github.com/ayush2027-stack/coalgov-ai/blob/main/server/routers.ts"
click node_db_access "https://github.com/ayush2027-stack/coalgov-ai/blob/main/server/db.ts"
click node_schema "https://github.com/ayush2027-stack/coalgov-ai/blob/main/drizzle/schema.ts"
click node_file_storage "https://github.com/ayush2027-stack/coalgov-ai/blob/main/server/storage.ts"
click node_storage_proxy "https://github.com/ayush2027-stack/coalgov-ai/blob/main/server/_core/storageProxy.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_app,node_dashboard,node_trpc_client toneBlue
class node_http_server,node_context,node_auth,node_storage_proxy,node_mysql,node_forge toneAmber
class node_procedures,node_system,node_mines_compliance,node_inspections,node_actions_audit toneMint
class node_db_access,node_schema,node_file_storage toneRose
class node_operator toneIndigo
```

## Components

### Browser application

- [Client bootstrap](https://github.com/ayush2027-stack/coalgov-ai/blob/main/client/src/main.tsx): `client/src/main.tsx`
- [App shell](https://github.com/ayush2027-stack/coalgov-ai/blob/main/client/src/App.tsx): `client/src/App.tsx`
- [Governance dashboard](https://github.com/ayush2027-stack/coalgov-ai/blob/main/client/src/pages/Home.tsx): `client/src/pages/Home.tsx`
- [tRPC client](https://github.com/ayush2027-stack/coalgov-ai/blob/main/client/src/main.tsx): `client/src/main.tsx`

### API and identity

- [Express server](https://github.com/ayush2027-stack/coalgov-ai/blob/main/server.ts): `server.ts`
- [Request context](https://github.com/ayush2027-stack/coalgov-ai/blob/main/server/_core/context.ts): `server/_core/context.ts`
- [OAuth routes](https://github.com/ayush2027-stack/coalgov-ai/blob/main/server/_core/oauth.ts): `server/_core/oauth.ts`
- [Storage proxy](https://github.com/ayush2027-stack/coalgov-ai/blob/main/server/_core/storageProxy.ts): `server/_core/storageProxy.ts`

### Governance workflows

- [Governance procedures](https://github.com/ayush2027-stack/coalgov-ai/blob/main/server/routers.ts): `server/routers.ts`
- [System procedures](https://github.com/ayush2027-stack/coalgov-ai/blob/main/server/_core/systemRouter.ts): `server/_core/systemRouter.ts`
- [Mines and compliance](https://github.com/ayush2027-stack/coalgov-ai/blob/main/server/routers.ts): `server/routers.ts`
- [Inspection lifecycle](https://github.com/ayush2027-stack/coalgov-ai/blob/main/server/routers.ts): `server/routers.ts`
- [Actions and audit](https://github.com/ayush2027-stack/coalgov-ai/blob/main/server/routers.ts): `server/routers.ts`

### Data and files

- [Database access](https://github.com/ayush2027-stack/coalgov-ai/blob/main/server/db.ts): `server/db.ts`
- [Governance schema](https://github.com/ayush2027-stack/coalgov-ai/blob/main/drizzle/schema.ts): `drizzle/schema.ts`
- [Evidence storage](https://github.com/ayush2027-stack/coalgov-ai/blob/main/server/storage.ts): `server/storage.ts`

### Other components

- **Mine personnel**
- **MySQL database**
- **Forge storage API**

## Connections

- Mine personnel → Client bootstrap: uses (evidence: `client/src/main.tsx`)
- Client bootstrap → App shell: renders (evidence: `client/src/main.tsx`)
- App shell → Governance dashboard: renders (evidence: `client/src/App.tsx`)
- Client bootstrap → tRPC client: configures (evidence: `client/src/main.tsx`)
- Express server → OAuth routes: registers (evidence: `server.ts`)
- Express server → Storage proxy: registers (evidence: `server.ts`)
- Express server → Governance procedures: mounts (evidence: `server.ts`)
- Express server → Request context: creates context (evidence: `server.ts`)
- Governance procedures → System procedures: includes (evidence: `server/routers.ts`)
- Governance procedures → Mines and compliance: defines (evidence: `server/routers.ts`)
- Governance procedures → Inspection lifecycle: defines (evidence: `server/routers.ts`)
- Governance procedures → Actions and audit: defines (evidence: `server/routers.ts`)
- Governance procedures → Database access: queries and writes (evidence: `server/routers.ts`)
- Governance procedures → Evidence storage: uploads evidence (evidence: `server/routers.ts`)
- Database access → Governance schema: uses tables (evidence: `server/db.ts`)
- Database access → MySQL database: reads and writes (evidence: `server/db.ts`)
- Evidence storage → Forge storage API: requests upload URLs (evidence: `server/storage.ts`)
- Storage proxy → Forge storage API: requests download URL (evidence: `server/_core/storageProxy.ts`)
