# lloydflo/emergencyresponsesystem architecture

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

- Interactive diagram: https://gitdiagram.com/lloydflo/emergencyresponsesystem
- Repository: https://github.com/lloydflo/emergencyresponsesystem

## Overview

This is a PHP emergency-response operations system covering incident intake, dispatch, responder operations, interagency coordination, resources, and administration. A documented admin workflow keeps converted anonymous tips in the Inter-Agency Conversations page: an administrator opens a linked incident card to view read-only details without leaving the page. The graph preserves major capabilities indicated by the repository structure, but most feature implementations were not excerpted; dashed, uncited links mark inferred workflow connections rather than verified calls.

Main entry points: [`includes/db.php`](https://github.com/lloydflo/emergencyresponsesystem/blob/main/includes/db.php) (Operational Database), [`api/system_API/anonymous_tip.php`](https://github.com/lloydflo/emergencyresponsesystem/blob/main/api/system_API/anonymous_tip.php) (Anonymous Tips), [`api/interagency_chat_threads.php`](https://github.com/lloydflo/emergencyresponsesystem/blob/main/api/interagency_chat_threads.php) (Interagency Chat), [`api/api_app/_operational_api.php`](https://github.com/lloydflo/emergencyresponsesystem/blob/main/api/api_app/_operational_api.php) (Responder Operations API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_incident["Incident Operations"]
  node_incident_intake["Incident Intake<br/>[calls_create.php]"]
  node_incident_review["Incident Review"]
  node_anonymous_tips["Anonymous Tips<br/>[anonymous_tip.php]"]
  node_system_api_router["System API Router<br/>[index.php]"]
  node_dispatch["Dispatch &amp; Allocation"]
end

subgraph group_coordination["Interagency Coordination"]
  node_interagency_ui["Interagency UI<br/>[interagency.php]"]
  node_interagency_chat["Interagency Chat"]
  node_external_incident_sync["Agency Incident Sync"]
end

subgraph group_field["Responder Operations"]
  node_responder_api["Responder Operations API"]
  node_route_requests["Alternative Routes"]
  node_unit_presence["Unit Presence<br/>[user_presence.php]"]
  node_resource_ops["Resource Operations"]
end

subgraph group_admin["Administration &amp; Insights"]
  node_admin_insights["Admin &amp; Analytics<br/>[analytics.php]"]
  node_reports["Reports"]
end

subgraph group_foundation["Shared Services"]
  node_authentication["Authentication<br/>[auth.php]"]
  node_database[("Operational Database<br/>[db.php]")]
  node_activity_audit["Activity Audit<br/>[activity_log.php]"]
  node_media_storage["Media Storage<br/>[media_storage.php]"]
end

node_administrator(("Administrator"))
node_dispatcher(("Dispatcher"))
node_responder(("Responder"))
node_external_agency(("External Agency"))

node_administrator -->|"opens"| node_interagency_ui
node_interagency_ui -.->|"views linked incident"| node_anonymous_tips
node_system_api_router -->|"routes to"| node_anonymous_tips
node_anonymous_tips -->|"uses"| node_authentication
node_anonymous_tips -->|"uses"| node_activity_audit
node_anonymous_tips -.->|"accesses"| node_database
node_dispatcher -.->|"dispatches incidents"| node_dispatch
node_dispatch -.->|"assigns incidents"| node_incident_intake
node_responder -.->|"updates operations"| node_responder_api
node_responder_api -->|"connects through"| node_database
node_responder_api -.->|"serves route operations"| node_route_requests
node_responder_api -.->|"serves presence operations"| node_unit_presence
node_dispatcher -.->|"manages resources"| node_resource_ops
node_external_agency -.->|"sends incidents"| node_external_incident_sync
node_external_incident_sync -->|"reads and writes"| node_database
node_administrator -.->|"reviews operations"| node_admin_insights
node_admin_insights -.->|"views reports"| node_reports
node_interagency_ui -.->|"uses chat"| node_interagency_chat
node_interagency_chat -->|"requires auth"| node_authentication
node_interagency_chat -->|"updates presence"| node_unit_presence
node_interagency_chat -->|"reads and writes"| node_database
node_authentication -->|"uses"| node_database
node_activity_audit -->|"writes events"| node_database
node_unit_presence -->|"uses unit resources"| node_database

click node_incident_intake "https://github.com/lloydflo/emergencyresponsesystem/blob/main/api/calls_create.php"
click node_incident_review "https://github.com/lloydflo/emergencyresponsesystem/blob/main/api/incident_admin_review_submit.php"
click node_anonymous_tips "https://github.com/lloydflo/emergencyresponsesystem/blob/main/api/system_API/anonymous_tip.php"
click node_system_api_router "https://github.com/lloydflo/emergencyresponsesystem/blob/main/api/system_API/index.php"
click node_dispatch "https://github.com/lloydflo/emergencyresponsesystem/blob/main/api/Incidents/dispatch-incidents.php"
click node_interagency_ui "https://github.com/lloydflo/emergencyresponsesystem/blob/main/admin/interagency.php"
click node_interagency_chat "https://github.com/lloydflo/emergencyresponsesystem/blob/main/api/interagency_chat_threads.php"
click node_external_incident_sync "https://github.com/lloydflo/emergencyresponsesystem/blob/main/api/system_API/interagency_external_incident_send.php"
click node_responder_api "https://github.com/lloydflo/emergencyresponsesystem/blob/main/api/api_app/_operational_api.php"
click node_route_requests "https://github.com/lloydflo/emergencyresponsesystem/blob/main/api/api_app/get-pending-alternative-routes.php"
click node_unit_presence "https://github.com/lloydflo/emergencyresponsesystem/blob/main/includes/user_presence.php"
click node_resource_ops "https://github.com/lloydflo/emergencyresponsesystem/blob/main/api/resource_request_dispatch.php"
click node_admin_insights "https://github.com/lloydflo/emergencyresponsesystem/blob/main/admin/analytics.php"
click node_reports "https://github.com/lloydflo/emergencyresponsesystem/blob/main/api/reports_incident_summary.php"
click node_authentication "https://github.com/lloydflo/emergencyresponsesystem/blob/main/includes/auth.php"
click node_database "https://github.com/lloydflo/emergencyresponsesystem/blob/main/includes/db.php"
click node_activity_audit "https://github.com/lloydflo/emergencyresponsesystem/blob/main/includes/activity_log.php"
click node_media_storage "https://github.com/lloydflo/emergencyresponsesystem/blob/main/includes/media_storage.php"

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_incident_intake,node_incident_review,node_anonymous_tips,node_system_api_router,node_dispatch toneBlue
class node_interagency_ui,node_interagency_chat,node_external_incident_sync toneAmber
class node_responder_api,node_route_requests,node_unit_presence,node_resource_ops toneMint
class node_admin_insights,node_reports toneRose
class node_authentication,node_database,node_activity_audit,node_media_storage,node_administrator,node_dispatcher,node_responder,node_external_agency toneIndigo
```

## Components

### Incident Operations

- [Incident Intake](https://github.com/lloydflo/emergencyresponsesystem/blob/main/api/calls_create.php): `api/calls_create.php`
- [Incident Review](https://github.com/lloydflo/emergencyresponsesystem/blob/main/api/incident_admin_review_submit.php): `api/incident_admin_review_submit.php`
- [Anonymous Tips](https://github.com/lloydflo/emergencyresponsesystem/blob/main/api/system_API/anonymous_tip.php): `api/system_API/anonymous_tip.php`
- [System API Router](https://github.com/lloydflo/emergencyresponsesystem/blob/main/api/system_API/index.php): `api/system_API/index.php`
- [Dispatch & Allocation](https://github.com/lloydflo/emergencyresponsesystem/blob/main/api/Incidents/dispatch-incidents.php): `api/Incidents/dispatch-incidents.php`

### Interagency Coordination

- [Interagency UI](https://github.com/lloydflo/emergencyresponsesystem/blob/main/admin/interagency.php): `admin/interagency.php`
- [Interagency Chat](https://github.com/lloydflo/emergencyresponsesystem/blob/main/api/interagency_chat_threads.php): `api/interagency_chat_threads.php`
- [Agency Incident Sync](https://github.com/lloydflo/emergencyresponsesystem/blob/main/api/system_API/interagency_external_incident_send.php): `api/system_API/interagency_external_incident_send.php`

### Responder Operations

- [Responder Operations API](https://github.com/lloydflo/emergencyresponsesystem/blob/main/api/api_app/_operational_api.php): `api/api_app/_operational_api.php`
- [Alternative Routes](https://github.com/lloydflo/emergencyresponsesystem/blob/main/api/api_app/get-pending-alternative-routes.php): `api/api_app/get-pending-alternative-routes.php`
- [Unit Presence](https://github.com/lloydflo/emergencyresponsesystem/blob/main/includes/user_presence.php): `includes/user_presence.php`
- [Resource Operations](https://github.com/lloydflo/emergencyresponsesystem/blob/main/api/resource_request_dispatch.php): `api/resource_request_dispatch.php`

### Administration & Insights

- [Admin & Analytics](https://github.com/lloydflo/emergencyresponsesystem/blob/main/admin/analytics.php): `admin/analytics.php`
- [Reports](https://github.com/lloydflo/emergencyresponsesystem/blob/main/api/reports_incident_summary.php): `api/reports_incident_summary.php`

### Shared Services

- [Authentication](https://github.com/lloydflo/emergencyresponsesystem/blob/main/includes/auth.php): `includes/auth.php`
- [Operational Database](https://github.com/lloydflo/emergencyresponsesystem/blob/main/includes/db.php): `includes/db.php`
- [Activity Audit](https://github.com/lloydflo/emergencyresponsesystem/blob/main/includes/activity_log.php): `includes/activity_log.php`
- [Media Storage](https://github.com/lloydflo/emergencyresponsesystem/blob/main/includes/media_storage.php): `includes/media_storage.php`

### Other components

- **Administrator**
- **Dispatcher**
- **Responder**
- **External Agency**

## Connections

- Administrator → Interagency UI: opens
- Interagency UI → Anonymous Tips: views linked incident
- System API Router → Anonymous Tips: routes to (evidence: `api/system_API/index.php`)
- Anonymous Tips → Authentication: uses (evidence: `api/system_API/anonymous_tip.php`)
- Anonymous Tips → Activity Audit: uses (evidence: `api/system_API/anonymous_tip.php`)
- Anonymous Tips → Operational Database: accesses
- Dispatcher → Dispatch & Allocation: dispatches incidents
- Dispatch & Allocation → Incident Intake: assigns incidents
- Responder → Responder Operations API: updates operations
- Responder Operations API → Operational Database: connects through (evidence: `api/api_app/_operational_api.php`)
- Responder Operations API → Alternative Routes: serves route operations
- Responder Operations API → Unit Presence: serves presence operations
- Dispatcher → Resource Operations: manages resources
- External Agency → Agency Incident Sync: sends incidents
- Agency Incident Sync → Operational Database: reads and writes (evidence: `api/system_API/interagency_external_incident_send.php`)
- Administrator → Admin & Analytics: reviews operations
- Admin & Analytics → Reports: views reports
- Interagency UI → Interagency Chat: uses chat
- Interagency Chat → Authentication: requires auth (evidence: `api/interagency_chat_threads.php`)
- Interagency Chat → Unit Presence: updates presence (evidence: `api/interagency_chat_threads.php`)
- Interagency Chat → Operational Database: reads and writes (evidence: `api/interagency_chat_threads.php`)
- Authentication → Operational Database: uses (evidence: `includes/auth.php`)
- Activity Audit → Operational Database: writes events (evidence: `includes/activity_log.php`)
- Unit Presence → Operational Database: uses unit resources (evidence: `includes/user_presence.php`)
