# guru071/crimetrack architecture

> Architecture diagram of the GitHub repository guru071/crimetrack, 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/guru071/crimetrack
- Repository: https://github.com/guru071/crimetrack

## Overview

C.A.S.E is a cross-platform law-enforcement records system. Officers sign in, manage case records through a configurable local, Google Sheets, or database source, and use spreadsheet, document/photo capture, analytics, and intelligence features. For shared-source changes, the app writes audit notifications that other clients poll and surface locally or natively. Firebase supports authentication and officer/station data; Operations Room messaging is ephemeral peer-to-peer. Source excerpts do not show every App route or backend API client, so uncertain links are omitted or marked unverified.

Main entry points: [`src/App.jsx`](https://github.com/guru071/crimetrack/blob/main/src/App.jsx) (CASE Workspace), [`src/dataSources.js`](https://github.com/guru071/crimetrack/blob/main/src/dataSources.js) (Record Data Sources), [`src/OperationsRoom.jsx`](https://github.com/guru071/crimetrack/blob/main/src/OperationsRoom.jsx) (Operations Room), [`backend/server.js`](https://github.com/guru071/crimetrack/blob/main/backend/server.js) (Sheets API Server)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Officer App"]
  node_entry["Web App Entry<br/>[main.jsx]"]
  node_app["CASE Workspace<br/>[App.jsx]"]
  node_login["Sign-In<br/>[LoginView.jsx]"]
  node_operations["Operations Room<br/>[OperationsRoom.jsx]"]
end

subgraph group_records["Records and Capture"]
  node_recordsui["Case Records<br/>[App.jsx]"]
  node_spreadsheet["Spreadsheet Editor"]
  node_scanner["Document Scanner"]
  node_photo["Photo Capture"]
end

subgraph group_intelligence["Intelligence Tools"]
  node_analytics["Advanced Analytics"]
  node_dbai["Database AI<br/>[DatabaseAI.jsx]"]
  node_policeintel["Police Intelligence"]
  node_investigator["Investigator Bot"]
end

subgraph group_services["Identity and Sync"]
  node_sources["Record Data Sources<br/>[dataSources.js]"]
  node_localstore[("Local Storage")]
  node_sheets[("Google Sheets")]
  node_databaseapi["Custom REST API"]
  node_firebase["Firebase Auth and Profiles<br/>[firebase.js]"]
  node_notifications["Audit Notifications<br/>[App.jsx]"]
end

subgraph group_backend["Backend Services"]
  node_express["Sheets API Server<br/>[server.js]"]
  node_sheetshandler["Sheets OAuth Handler"]
  node_drive["Drive Upload Service"]
end

node_officer(("Officer"))
node_peer["PeerJS Messaging"]
node_otherofficers(("Other Officers"))
node_device["Local Notification API"]

node_officer -->|"opens"| node_entry
node_entry -->|"renders"| node_app
node_app -->|"uses"| node_login
node_login -->|"authenticates with"| node_firebase
node_app -->|"manages records"| node_recordsui
node_app -->|"loads and saves"| node_sources
node_spreadsheet -->|"uses source settings"| node_sources
node_sources -.->|"reads and writes"| node_localstore
node_sources -->|"reads and writes"| node_sheets
node_sources -->|"calls REST API"| node_databaseapi
node_app -->|"opens editor"| node_spreadsheet
node_app -->|"opens scanner"| node_scanner
node_app -->|"opens capture"| node_photo
node_app -->|"uses"| node_dbai
node_policeintel -->|"renders"| node_investigator
node_policeintel -->|"analyzes records"| node_recordsui
node_analytics -.->|"provides analytics"| node_app
node_app -->|"writes and polls"| node_notifications
node_notifications -->|"writes audit logs"| node_sources
node_notifications -->|"triggers local alert"| node_device
node_otherofficers -->|"receives polled alerts"| node_notifications
node_officer -->|"joins room"| node_operations
node_operations -->|"sends ephemeral messages"| node_peer
node_operations -->|"uses profiles"| node_firebase
node_app -.->|"uses REST backend"| node_express
node_express -->|"routes Sheets requests"| node_sheetshandler
node_express -->|"uploads images"| node_drive
node_sheetshandler -->|"reads and writes"| node_sheets

click node_entry "https://github.com/guru071/crimetrack/blob/main/src/main.jsx"
click node_app "https://github.com/guru071/crimetrack/blob/main/src/App.jsx"
click node_login "https://github.com/guru071/crimetrack/blob/main/src/LoginView.jsx"
click node_operations "https://github.com/guru071/crimetrack/blob/main/src/OperationsRoom.jsx"
click node_recordsui "https://github.com/guru071/crimetrack/blob/main/src/App.jsx"
click node_spreadsheet "https://github.com/guru071/crimetrack/blob/main/src/ExcelSpreadsheet.jsx"
click node_scanner "https://github.com/guru071/crimetrack/blob/main/src/DocumentScannerModal.jsx"
click node_photo "https://github.com/guru071/crimetrack/blob/main/src/PhotoUploaderModal.jsx"
click node_sources "https://github.com/guru071/crimetrack/blob/main/src/dataSources.js"
click node_firebase "https://github.com/guru071/crimetrack/blob/main/src/firebase.js"
click node_notifications "https://github.com/guru071/crimetrack/blob/main/src/App.jsx"
click node_analytics "https://github.com/guru071/crimetrack/blob/main/src/AdvancedAnalytics.jsx"
click node_dbai "https://github.com/guru071/crimetrack/blob/main/src/features/DatabaseAI.jsx"
click node_policeintel "https://github.com/guru071/crimetrack/blob/main/src/features/PoliceIntelligenceEngine.jsx"
click node_investigator "https://github.com/guru071/crimetrack/blob/main/src/features/InvestigatorBot.jsx"
click node_express "https://github.com/guru071/crimetrack/blob/main/backend/server.js"
click node_sheetshandler "https://github.com/guru071/crimetrack/blob/main/backend/google-sheets-handler.js"
click node_drive "https://github.com/guru071/crimetrack/blob/main/backend/google-drive-service.js"

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_login,node_operations toneBlue
class node_recordsui,node_spreadsheet,node_scanner,node_photo toneAmber
class node_analytics,node_dbai,node_policeintel,node_investigator,node_device toneMint
class node_sources,node_localstore,node_sheets,node_databaseapi,node_firebase,node_notifications toneRose
class node_express,node_sheetshandler,node_drive,node_officer,node_peer,node_otherofficers toneIndigo
```

## Components

### Officer App

- [Web App Entry](https://github.com/guru071/crimetrack/blob/main/src/main.jsx): `src/main.jsx`
- [CASE Workspace](https://github.com/guru071/crimetrack/blob/main/src/App.jsx): `src/App.jsx`
- [Sign-In](https://github.com/guru071/crimetrack/blob/main/src/LoginView.jsx): `src/LoginView.jsx`
- [Operations Room](https://github.com/guru071/crimetrack/blob/main/src/OperationsRoom.jsx): `src/OperationsRoom.jsx`

### Records and Capture

- [Case Records](https://github.com/guru071/crimetrack/blob/main/src/App.jsx): `src/App.jsx`
- [Spreadsheet Editor](https://github.com/guru071/crimetrack/blob/main/src/ExcelSpreadsheet.jsx): `src/ExcelSpreadsheet.jsx`
- [Document Scanner](https://github.com/guru071/crimetrack/blob/main/src/DocumentScannerModal.jsx): `src/DocumentScannerModal.jsx`
- [Photo Capture](https://github.com/guru071/crimetrack/blob/main/src/PhotoUploaderModal.jsx): `src/PhotoUploaderModal.jsx`

### Intelligence Tools

- [Advanced Analytics](https://github.com/guru071/crimetrack/blob/main/src/AdvancedAnalytics.jsx): `src/AdvancedAnalytics.jsx`
- [Database AI](https://github.com/guru071/crimetrack/blob/main/src/features/DatabaseAI.jsx): `src/features/DatabaseAI.jsx`
- [Police Intelligence](https://github.com/guru071/crimetrack/blob/main/src/features/PoliceIntelligenceEngine.jsx): `src/features/PoliceIntelligenceEngine.jsx`
- [Investigator Bot](https://github.com/guru071/crimetrack/blob/main/src/features/InvestigatorBot.jsx): `src/features/InvestigatorBot.jsx`

### Identity and Sync

- [Record Data Sources](https://github.com/guru071/crimetrack/blob/main/src/dataSources.js): `src/dataSources.js`
- **Local Storage**
- **Google Sheets**
- **Custom REST API**
- [Firebase Auth and Profiles](https://github.com/guru071/crimetrack/blob/main/src/firebase.js): `src/firebase.js`
- [Audit Notifications](https://github.com/guru071/crimetrack/blob/main/src/App.jsx): `src/App.jsx`

### Backend Services

- [Sheets API Server](https://github.com/guru071/crimetrack/blob/main/backend/server.js): `backend/server.js`
- [Sheets OAuth Handler](https://github.com/guru071/crimetrack/blob/main/backend/google-sheets-handler.js): `backend/google-sheets-handler.js`
- [Drive Upload Service](https://github.com/guru071/crimetrack/blob/main/backend/google-drive-service.js): `backend/google-drive-service.js`

### Other components

- **Officer**
- **PeerJS Messaging**
- **Other Officers**
- **Local Notification API**

## Connections

- Officer → Web App Entry: opens (evidence: `src/main.jsx`)
- Web App Entry → CASE Workspace: renders (evidence: `src/main.jsx`)
- CASE Workspace → Sign-In: uses (evidence: `src/App.jsx`)
- Sign-In → Firebase Auth and Profiles: authenticates with (evidence: `src/LoginView.jsx`)
- CASE Workspace → Case Records: manages records (evidence: `src/App.jsx`)
- CASE Workspace → Record Data Sources: loads and saves (evidence: `src/App.jsx`)
- Spreadsheet Editor → Record Data Sources: uses source settings (evidence: `src/ExcelSpreadsheet.jsx`)
- Record Data Sources → Local Storage: reads and writes
- Record Data Sources → Google Sheets: reads and writes (evidence: `src/dataSources.js`)
- Record Data Sources → Custom REST API: calls REST API (evidence: `src/dataSources.js`)
- CASE Workspace → Spreadsheet Editor: opens editor (evidence: `src/App.jsx`)
- CASE Workspace → Document Scanner: opens scanner (evidence: `src/App.jsx`)
- CASE Workspace → Photo Capture: opens capture (evidence: `src/App.jsx`)
- CASE Workspace → Database AI: uses (evidence: `src/App.jsx`)
- Police Intelligence → Investigator Bot: renders (evidence: `src/features/PoliceIntelligenceEngine.jsx`)
- Police Intelligence → Case Records: analyzes records (evidence: `src/features/PoliceIntelligenceEngine.jsx`)
- Advanced Analytics → CASE Workspace: provides analytics (evidence: `src/App.jsx`)
- CASE Workspace → Audit Notifications: writes and polls (evidence: `src/App.jsx`)
- Audit Notifications → Record Data Sources: writes audit logs (evidence: `src/App.jsx`)
- Audit Notifications → Local Notification API: triggers local alert
- Other Officers → Audit Notifications: receives polled alerts
- Officer → Operations Room: joins room
- Operations Room → PeerJS Messaging: sends ephemeral messages
- Operations Room → Firebase Auth and Profiles: uses profiles (evidence: `src/OperationsRoom.jsx`)
- CASE Workspace → Sheets API Server: uses REST backend
- Sheets API Server → Sheets OAuth Handler: routes Sheets requests (evidence: `backend/server.js`)
- Sheets API Server → Drive Upload Service: uploads images (evidence: `backend/server.js`)
- Sheets OAuth Handler → Google Sheets: reads and writes (evidence: `backend/google-sheets-handler.js`)
