# casolin/sagx architecture

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

- Interactive diagram: https://gitdiagram.com/casolin/sagx
- Repository: https://github.com/casolin/sagx

## Overview

SagX is an enterprise mission-management platform: users authenticate and work through role-gated workflows for missions, machines, alerts, and materials, with collaboration and operational status updates. The browser client communicates with the server over HTTP and sockets; the README documents live chat, calls, and screen sharing. The graph includes those documented capabilities, but sampled evidence does not expose all route and socket wiring, so some cross-system links are unverified. AI assignment is visible in the machine controller; the AI and reporting modules are represented without guessed internal links.

Main entry points: [`client/src/App.tsx`](https://github.com/casolin/sagx/blob/main/client/src/App.tsx) (Client application), [`server/src/modules/missions/mission.controller.ts`](https://github.com/casolin/sagx/blob/main/server/src/modules/missions/mission.controller.ts) (Mission workflows), [`server/src/modules/machines/machine.controller.ts`](https://github.com/casolin/sagx/blob/main/server/src/modules/machines/machine.controller.ts) (Machine workflows), [`client/src/services/socket.service.ts`](https://github.com/casolin/sagx/blob/main/client/src/services/socket.service.ts) (Socket client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Web client"]
  node_app["Client application<br/>[App.tsx]"]
  node_router["Role-gated routes<br/>[AppRouter.tsx]"]
  node_clientauth["Client auth state<br/>[AuthContext.tsx]"]
  node_socketclient["Socket client<br/>[socket.service.ts]"]
  node_callpage["Call interface<br/>[CallPage.tsx]"]
end

subgraph group_operations["Operations workflows"]
  node_mission["Mission workflows"]
  node_missionlogic["Mission rules<br/>[mission.service.ts]"]
  node_machine["Machine workflows"]
  node_materials["Material inventory"]
  node_alerts["Alert handling"]
  node_aiassign["AI assignment<br/>[solver.py]"]
end

subgraph group_collaboration["Collaboration"]
  node_chat["Chat messaging"]
  node_rooms["Chat rooms<br/>[room.controller.ts]"]
  node_calls["Call signaling<br/>[call.socket.ts]"]
  node_socketserver["Socket event service<br/>[socket.service.ts]"]
end

subgraph group_platform["Identity and insights"]
  node_auth["Authentication<br/>[auth.service.ts]"]
  node_twofactor["Two-factor auth"]
  node_users[("User accounts<br/>[user.model.ts]")]
  node_kpi["Operational KPIs<br/>[kpi.service.ts]"]
  node_notifications["Notifications"]
  node_report["Report generation<br/>[generateRapport.py]"]
end

node_user(("Staff users"))

node_user -->|"uses"| node_app
node_app -->|"renders"| node_router
node_app -->|"initializes"| node_socketclient
node_app -->|"displays"| node_callpage
node_router -->|"gates access"| node_user
node_app -->|"reads auth"| node_clientauth
node_clientauth -->|"initializes session"| node_socketclient
node_socketclient -.->|"signals calls"| node_calls
node_socketclient -.->|"exchanges events"| node_socketserver
node_mission -->|"calls"| node_missionlogic
node_mission -->|"consumes materials"| node_materials
node_machine -->|"resolves materials"| node_materials
node_machine -->|"creates mission"| node_missionlogic
node_machine -->|"requests assignment"| node_aiassign
node_mission -->|"broadcasts updates"| node_kpi
node_machine -->|"broadcasts updates"| node_kpi
node_mission -->|"creates notices"| node_notifications
node_chat -->|"creates notices"| node_notifications
node_rooms -->|"creates notices"| node_notifications
node_auth -->|"reads accounts"| node_users
node_auth -->|"uses"| node_twofactor
node_user -->|"collaborates"| node_chat
node_user -->|"starts calls"| node_calls
node_user -->|"manages work"| node_mission

click node_app "https://github.com/casolin/sagx/blob/main/client/src/App.tsx"
click node_router "https://github.com/casolin/sagx/blob/main/client/src/routes/AppRouter.tsx"
click node_clientauth "https://github.com/casolin/sagx/blob/main/client/src/context/AuthContext.tsx"
click node_socketclient "https://github.com/casolin/sagx/blob/main/client/src/services/socket.service.ts"
click node_callpage "https://github.com/casolin/sagx/blob/main/client/src/pages/CallPage.tsx"
click node_mission "https://github.com/casolin/sagx/blob/main/server/src/modules/missions/mission.controller.ts"
click node_missionlogic "https://github.com/casolin/sagx/blob/main/server/src/modules/missions/mission.service.ts"
click node_machine "https://github.com/casolin/sagx/blob/main/server/src/modules/machines/machine.controller.ts"
click node_materials "https://github.com/casolin/sagx/blob/main/server/src/modules/materials/material.service.ts"
click node_alerts "https://github.com/casolin/sagx/blob/main/server/src/modules/alert/alert.controller.ts"
click node_aiassign "https://github.com/casolin/sagx/blob/main/ai/assignment/solver.py"
click node_chat "https://github.com/casolin/sagx/blob/main/server/src/modules/message/message.controller.ts"
click node_rooms "https://github.com/casolin/sagx/blob/main/server/src/modules/room/room.controller.ts"
click node_calls "https://github.com/casolin/sagx/blob/main/server/src/sockets/call.socket.ts"
click node_socketserver "https://github.com/casolin/sagx/blob/main/server/src/sockets/socket.service.ts"
click node_auth "https://github.com/casolin/sagx/blob/main/server/src/modules/auth/auth.service.ts"
click node_twofactor "https://github.com/casolin/sagx/blob/main/server/src/services/twoFactor.service.ts"
click node_users "https://github.com/casolin/sagx/blob/main/server/src/modules/users/user.model.ts"
click node_kpi "https://github.com/casolin/sagx/blob/main/server/src/modules/kpi/kpi.service.ts"
click node_notifications "https://github.com/casolin/sagx/blob/main/server/src/modules/notification/notification.service.ts"
click node_report "https://github.com/casolin/sagx/blob/main/ai/rapport/generateRapport.py"

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_app,node_router,node_clientauth,node_socketclient,node_callpage,node_user toneBlue
class node_mission,node_missionlogic,node_machine,node_materials,node_alerts,node_aiassign toneAmber
class node_chat,node_rooms,node_calls,node_socketserver toneMint
class node_auth,node_twofactor,node_users,node_kpi,node_notifications,node_report toneRose
```

## Components

### Web client

- [Client application](https://github.com/casolin/sagx/blob/main/client/src/App.tsx): `client/src/App.tsx`
- [Role-gated routes](https://github.com/casolin/sagx/blob/main/client/src/routes/AppRouter.tsx): `client/src/routes/AppRouter.tsx`
- [Client auth state](https://github.com/casolin/sagx/blob/main/client/src/context/AuthContext.tsx): `client/src/context/AuthContext.tsx`
- [Socket client](https://github.com/casolin/sagx/blob/main/client/src/services/socket.service.ts): `client/src/services/socket.service.ts`
- [Call interface](https://github.com/casolin/sagx/blob/main/client/src/pages/CallPage.tsx): `client/src/pages/CallPage.tsx`

### Operations workflows

- [Mission workflows](https://github.com/casolin/sagx/blob/main/server/src/modules/missions/mission.controller.ts): `server/src/modules/missions/mission.controller.ts`
- [Mission rules](https://github.com/casolin/sagx/blob/main/server/src/modules/missions/mission.service.ts): `server/src/modules/missions/mission.service.ts`
- [Machine workflows](https://github.com/casolin/sagx/blob/main/server/src/modules/machines/machine.controller.ts): `server/src/modules/machines/machine.controller.ts`
- [Material inventory](https://github.com/casolin/sagx/blob/main/server/src/modules/materials/material.service.ts): `server/src/modules/materials/material.service.ts`
- [Alert handling](https://github.com/casolin/sagx/blob/main/server/src/modules/alert/alert.controller.ts): `server/src/modules/alert/alert.controller.ts`
- [AI assignment](https://github.com/casolin/sagx/blob/main/ai/assignment/solver.py): `ai/assignment/solver.py`

### Collaboration

- [Chat messaging](https://github.com/casolin/sagx/blob/main/server/src/modules/message/message.controller.ts): `server/src/modules/message/message.controller.ts`
- [Chat rooms](https://github.com/casolin/sagx/blob/main/server/src/modules/room/room.controller.ts): `server/src/modules/room/room.controller.ts`
- [Call signaling](https://github.com/casolin/sagx/blob/main/server/src/sockets/call.socket.ts): `server/src/sockets/call.socket.ts`
- [Socket event service](https://github.com/casolin/sagx/blob/main/server/src/sockets/socket.service.ts): `server/src/sockets/socket.service.ts`

### Identity and insights

- [Authentication](https://github.com/casolin/sagx/blob/main/server/src/modules/auth/auth.service.ts): `server/src/modules/auth/auth.service.ts`
- [Two-factor auth](https://github.com/casolin/sagx/blob/main/server/src/services/twoFactor.service.ts): `server/src/services/twoFactor.service.ts`
- [User accounts](https://github.com/casolin/sagx/blob/main/server/src/modules/users/user.model.ts): `server/src/modules/users/user.model.ts`
- [Operational KPIs](https://github.com/casolin/sagx/blob/main/server/src/modules/kpi/kpi.service.ts): `server/src/modules/kpi/kpi.service.ts`
- [Notifications](https://github.com/casolin/sagx/blob/main/server/src/modules/notification/notification.service.ts): `server/src/modules/notification/notification.service.ts`
- [Report generation](https://github.com/casolin/sagx/blob/main/ai/rapport/generateRapport.py): `ai/rapport/generateRapport.py`

### Other components

- **Staff users**

## Connections

- Staff users → Client application: uses
- Client application → Role-gated routes: renders (evidence: `client/src/App.tsx`)
- Client application → Socket client: initializes (evidence: `client/src/App.tsx`)
- Client application → Call interface: displays (evidence: `client/src/App.tsx`)
- Role-gated routes → Staff users: gates access (evidence: `client/src/routes/AppRouter.tsx`)
- Client application → Client auth state: reads auth (evidence: `client/src/App.tsx`)
- Client auth state → Socket client: initializes session (evidence: `client/src/context/AuthContext.tsx`)
- Socket client → Call signaling: signals calls
- Socket client → Socket event service: exchanges events
- Mission workflows → Mission rules: calls (evidence: `server/src/modules/missions/mission.controller.ts`)
- Mission workflows → Material inventory: consumes materials (evidence: `server/src/modules/missions/mission.controller.ts`)
- Machine workflows → Material inventory: resolves materials (evidence: `server/src/modules/machines/machine.controller.ts`)
- Machine workflows → Mission rules: creates mission (evidence: `server/src/modules/machines/machine.controller.ts`)
- Machine workflows → AI assignment: requests assignment (evidence: `server/src/modules/machines/machine.controller.ts`)
- Mission workflows → Operational KPIs: broadcasts updates (evidence: `server/src/modules/missions/mission.controller.ts`)
- Machine workflows → Operational KPIs: broadcasts updates (evidence: `server/src/modules/machines/machine.controller.ts`)
- Mission workflows → Notifications: creates notices (evidence: `server/src/modules/missions/mission.controller.ts`)
- Chat messaging → Notifications: creates notices (evidence: `server/src/modules/message/message.controller.ts`)
- Chat rooms → Notifications: creates notices (evidence: `server/src/modules/room/room.controller.ts`)
- Authentication → User accounts: reads accounts (evidence: `server/src/modules/auth/auth.service.ts`)
- Authentication → Two-factor auth: uses (evidence: `server/src/modules/auth/auth.service.ts`)
- Staff users → Chat messaging: collaborates
- Staff users → Call signaling: starts calls
- Staff users → Mission workflows: manages work
