# jusaldesai1/aegisflow architecture

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

- Interactive diagram: https://gitdiagram.com/jusaldesai1/aegisflow
- Repository: https://github.com/jusaldesai1/aegisflow

## Overview

AegisFlow is a multi-agency emergency operations platform: operators enter through authentication, review role-specific incident and situational data, then coordinate alerts and resource dispatch. The README describes live incident updates flowing through the WebSocket layer into application state and UI. The tree also identifies GIS, analytics, offline support, and multiple role dashboards; their detailed wiring is not shown in the sampled source, so uncertain links are omitted. The README mentions optional Firebase and backend storage, but their implementation is not present in the tree.

Main entry points: [`src/components/dashboards`](https://github.com/jusaldesai1/aegisflow/tree/main/src/components/dashboards) (Role dashboards), [`lib/stores/useAuthStore.ts`](https://github.com/jusaldesai1/aegisflow/blob/main/lib/stores/useAuthStore.ts) (Authentication state), [`src/hooks/useDisasterDetection.ts`](https://github.com/jusaldesai1/aegisflow/blob/main/src/hooks/useDisasterDetection.ts) (Disaster detection), [`src/app/auth/login/page.tsx`](https://github.com/jusaldesai1/aegisflow/blob/main/src/app/auth/login/page.tsx) (Login page)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_access["Access and Roles"]
  node_authpage["Login page<br/>[page.tsx]"]
  node_auth["Authentication state<br/>[useAuthStore.ts]"]
  node_rbac["Role permissions<br/>[rbac.ts]"]
end

subgraph group_response["Incident Response"]
  node_detection["Disaster detection"]
  node_disasters["Incident state<br/>[disasterStore.ts]"]
  node_dispatch["Dispatch panel<br/>[DispatchPanel.tsx]"]
  node_alerts["Alert views<br/>[AlertStack.tsx]"]
  node_incidentmodal["Incident details<br/>[IncidentModal.tsx]"]
end

subgraph group_operations["Operations Views"]
  node_dashboardpage["Dashboard entry<br/>[page.tsx]"]
  node_roleviews["Role dashboards"]
  node_gis["GIS situational map"]
  node_metrics["Operations metrics<br/>[MetricsCards.tsx]"]
  node_resources["Resource tracking"]
end

subgraph group_realtime["Realtime and Data"]
  node_api["REST API client<br/>[api.ts]"]
  node_ws["WebSocket manager<br/>[wsManager.ts]"]
  node_wshook["WebSocket hook<br/>[useWebSocket.ts]"]
  node_stores["Operations and GIS state<br/>[operationsStore.ts]"]
end

subgraph group_resilience["Offline Support"]
  node_offline["Offline utilities<br/>[offline.ts]"]
end

node_operator(("Agency operator"))
node_backend[("Backend services")]
node_wsserver(("Incident event source"))

node_operator -->|"opens login"| node_authpage
node_authpage -->|"submits credentials"| node_auth
node_auth -->|"requests login"| node_backend
node_auth -->|"checks permissions"| node_rbac
node_operator -->|"opens dashboard"| node_dashboardpage
node_dashboardpage -->|"renders role view"| node_roleviews
node_roleviews -->|"shows map"| node_gis
node_roleviews -->|"shows metrics"| node_metrics
node_roleviews -->|"shows resources"| node_resources
node_detection -->|"adds incidents"| node_disasters
node_detection -->|"creates alerts"| node_alerts
node_operator -->|"coordinates response"| node_dispatch
node_wsserver -->|"sends events"| node_ws
node_ws -->|"dispatches events"| node_wshook
node_wshook -->|"notifies subscribers"| node_stores
node_api -->|"calls REST services"| node_backend
node_offline -.->|"supports degraded use"| node_stores

click node_authpage "https://github.com/jusaldesai1/aegisflow/blob/main/src/app/auth/login/page.tsx"
click node_auth "https://github.com/jusaldesai1/aegisflow/blob/main/lib/stores/useAuthStore.ts"
click node_rbac "https://github.com/jusaldesai1/aegisflow/blob/main/src/utils/rbac.ts"
click node_detection "https://github.com/jusaldesai1/aegisflow/blob/main/src/hooks/useDisasterDetection.ts"
click node_disasters "https://github.com/jusaldesai1/aegisflow/blob/main/src/store/disasterStore.ts"
click node_dispatch "https://github.com/jusaldesai1/aegisflow/blob/main/src/components/DispatchPanel.tsx"
click node_alerts "https://github.com/jusaldesai1/aegisflow/blob/main/src/components/AlertStack.tsx"
click node_incidentmodal "https://github.com/jusaldesai1/aegisflow/blob/main/src/components/IncidentModal.tsx"
click node_dashboardpage "https://github.com/jusaldesai1/aegisflow/blob/main/src/app/dashboard/page.tsx"
click node_roleviews "https://github.com/jusaldesai1/aegisflow/tree/main/src/components/dashboards"
click node_gis "https://github.com/jusaldesai1/aegisflow/blob/main/src/components/GISMapContainer.tsx"
click node_metrics "https://github.com/jusaldesai1/aegisflow/blob/main/src/components/Dashboard/MetricsCards.tsx"
click node_resources "https://github.com/jusaldesai1/aegisflow/blob/main/src/components/Dashboard/ResourceTracker.tsx"
click node_api "https://github.com/jusaldesai1/aegisflow/blob/main/src/services/api.ts"
click node_ws "https://github.com/jusaldesai1/aegisflow/blob/main/lib/ws/wsManager.ts"
click node_wshook "https://github.com/jusaldesai1/aegisflow/blob/main/lib/hooks/useWebSocket.ts"
click node_stores "https://github.com/jusaldesai1/aegisflow/blob/main/src/stores/operationsStore.ts"
click node_offline "https://github.com/jusaldesai1/aegisflow/blob/main/src/utils/offline.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_authpage,node_auth,node_rbac toneBlue
class node_detection,node_disasters,node_dispatch,node_alerts,node_incidentmodal,node_backend toneAmber
class node_dashboardpage,node_roleviews,node_gis,node_metrics,node_resources toneMint
class node_api,node_ws,node_wshook,node_stores toneRose
class node_offline,node_operator,node_wsserver toneIndigo
```

## Components

### Access and Roles

- [Login page](https://github.com/jusaldesai1/aegisflow/blob/main/src/app/auth/login/page.tsx): `src/app/auth/login/page.tsx`
- [Authentication state](https://github.com/jusaldesai1/aegisflow/blob/main/lib/stores/useAuthStore.ts): `lib/stores/useAuthStore.ts`
- [Role permissions](https://github.com/jusaldesai1/aegisflow/blob/main/src/utils/rbac.ts): `src/utils/rbac.ts`

### Incident Response

- [Disaster detection](https://github.com/jusaldesai1/aegisflow/blob/main/src/hooks/useDisasterDetection.ts): `src/hooks/useDisasterDetection.ts`
- [Incident state](https://github.com/jusaldesai1/aegisflow/blob/main/src/store/disasterStore.ts): `src/store/disasterStore.ts`
- [Dispatch panel](https://github.com/jusaldesai1/aegisflow/blob/main/src/components/DispatchPanel.tsx): `src/components/DispatchPanel.tsx`
- [Alert views](https://github.com/jusaldesai1/aegisflow/blob/main/src/components/AlertStack.tsx): `src/components/AlertStack.tsx`
- [Incident details](https://github.com/jusaldesai1/aegisflow/blob/main/src/components/IncidentModal.tsx): `src/components/IncidentModal.tsx`

### Operations Views

- [Dashboard entry](https://github.com/jusaldesai1/aegisflow/blob/main/src/app/dashboard/page.tsx): `src/app/dashboard/page.tsx`
- [Role dashboards](https://github.com/jusaldesai1/aegisflow/tree/main/src/components/dashboards): `src/components/dashboards`
- [GIS situational map](https://github.com/jusaldesai1/aegisflow/blob/main/src/components/GISMapContainer.tsx): `src/components/GISMapContainer.tsx`
- [Operations metrics](https://github.com/jusaldesai1/aegisflow/blob/main/src/components/Dashboard/MetricsCards.tsx): `src/components/Dashboard/MetricsCards.tsx`
- [Resource tracking](https://github.com/jusaldesai1/aegisflow/blob/main/src/components/Dashboard/ResourceTracker.tsx): `src/components/Dashboard/ResourceTracker.tsx`

### Realtime and Data

- [REST API client](https://github.com/jusaldesai1/aegisflow/blob/main/src/services/api.ts): `src/services/api.ts`
- [WebSocket manager](https://github.com/jusaldesai1/aegisflow/blob/main/lib/ws/wsManager.ts): `lib/ws/wsManager.ts`
- [WebSocket hook](https://github.com/jusaldesai1/aegisflow/blob/main/lib/hooks/useWebSocket.ts): `lib/hooks/useWebSocket.ts`
- [Operations and GIS state](https://github.com/jusaldesai1/aegisflow/blob/main/src/stores/operationsStore.ts): `src/stores/operationsStore.ts`

### Offline Support

- [Offline utilities](https://github.com/jusaldesai1/aegisflow/blob/main/src/utils/offline.ts): `src/utils/offline.ts`

### Other components

- **Agency operator**
- **Backend services**
- **Incident event source**

## Connections

- Agency operator → Login page: opens login
- Login page → Authentication state: submits credentials
- Authentication state → Backend services: requests login
- Authentication state → Role permissions: checks permissions
- Agency operator → Dashboard entry: opens dashboard
- Dashboard entry → Role dashboards: renders role view
- Role dashboards → GIS situational map: shows map
- Role dashboards → Operations metrics: shows metrics
- Role dashboards → Resource tracking: shows resources
- Disaster detection → Incident state: adds incidents
- Disaster detection → Alert views: creates alerts
- Agency operator → Dispatch panel: coordinates response
- Incident event source → WebSocket manager: sends events
- WebSocket manager → WebSocket hook: dispatches events
- WebSocket hook → Operations and GIS state: notifies subscribers
- REST API client → Backend services: calls REST services
- Offline utilities → Operations and GIS state: supports degraded use
