# jojofunjourney/safecityweb architecture

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

- Interactive diagram: https://gitdiagram.com/jojofunjourney/safecityweb
- Repository: https://github.com/jojofunjourney/safecityweb

## Overview

Crime Tracker is a Next.js application for selecting a location and time range, then fetching and displaying local crime statistics. The main flow runs from the home page through location controls and the app’s fetch action to its crime API, which queries city open-data services and returns aggregate results for dashboard panels. Separate routes support historical crime, total-crime, safety-score and map operations. The README describes maps as a placeholder; sampled code confirms address lookup and a map component, but does not establish map rendering or all unsampled route behavior.

Main entry points: [`src/components/layout/CrimeTrackerApp.tsx`](https://github.com/jojofunjourney/safecityweb/blob/main/src/components/layout/CrimeTrackerApp.tsx) (Tracker Workflow), [`src/components/containers/LocationContainer.tsx`](https://github.com/jojofunjourney/safecityweb/blob/main/src/components/containers/LocationContainer.tsx) (Location Controls), [`src/lib/api.ts`](https://github.com/jojofunjourney/safecityweb/blob/main/src/lib/api.ts) (Client API), [`src/components/inputs/AddressInput.tsx`](https://github.com/jojofunjourney/safecityweb/blob/main/src/components/inputs/AddressInput.tsx) (Address Input)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_presentation["Application UI"]
  node_home["Home Page<br/>[page.tsx]"]
  node_tracker["Tracker Workflow"]
  node_location["Location Controls"]
  node_address["Address Input<br/>[AddressInput.tsx]"]
  node_ranges["Time Range"]
  node_map["Crime Map<br/>[CrimeMap.tsx]"]
  node_panels["Summary Panels"]
  node_historypage["History Page<br/>[page.tsx]"]
  node_totalpage["Total Crimes Page<br/>[page.tsx]"]
  node_safetypage["Safety Page<br/>[page.tsx]"]
end

subgraph group_domain["Crime Analysis"]
  node_history["Crime History<br/>[CrimeHistory.tsx]"]
  node_total["Total Crime View<br/>[TotalCrime.tsx]"]
  node_safety["Safety Score View<br/>[SafetyScore.tsx]"]
  node_types["Crime Data Types<br/>[crimeData.ts]"]
end

subgraph group_backend["API and Services"]
  node_crimeapi["Crime API<br/>[route.ts]"]
  node_homeapi["Home API<br/>[route.ts]"]
  node_coordapi["Coordinates API<br/>[route.ts]"]
  node_routeapi["Map Route API<br/>[route.ts]"]
  node_crimesvc["Crime Data Service<br/>[crimeService.ts]"]
  node_mapsvc["Geocoding Service<br/>[mapService.ts]"]
  node_apiutil["Client API<br/>[api.ts]"]
end

subgraph group_integration["External Data"]
  node_citydata[("City Open Data")]
  node_google["Google Geocoding"]
end

node_user(("User"))

node_user -->|"opens"| node_home
node_home -->|"renders"| node_tracker
node_tracker -->|"renders"| node_location
node_location -->|"renders"| node_address
node_location -->|"renders"| node_ranges
node_location -->|"renders"| node_map
node_address -->|"selects location"| node_tracker
node_tracker -->|"requests data"| node_apiutil
node_apiutil -->|"HTTP request"| node_crimeapi
node_crimeapi -->|"fetches crime data"| node_crimesvc
node_crimesvc -->|"queries"| node_citydata
node_crimeapi -->|"uses response types"| node_types
node_tracker -->|"renders results"| node_panels
node_historypage -->|"renders"| node_history
node_totalpage -->|"renders"| node_total
node_safetypage -->|"renders"| node_safety
node_address -->|"requests coordinates lookup"| node_apiutil
node_apiutil -->|"HTTP request"| node_coordapi
node_coordapi -->|"geocodes coordinates"| node_mapsvc
node_mapsvc -->|"geocoding request"| node_google

click node_home "https://github.com/jojofunjourney/safecityweb/blob/main/src/app/page.tsx"
click node_tracker "https://github.com/jojofunjourney/safecityweb/blob/main/src/components/layout/CrimeTrackerApp.tsx"
click node_location "https://github.com/jojofunjourney/safecityweb/blob/main/src/components/containers/LocationContainer.tsx"
click node_address "https://github.com/jojofunjourney/safecityweb/blob/main/src/components/inputs/AddressInput.tsx"
click node_ranges "https://github.com/jojofunjourney/safecityweb/blob/main/src/components/inputs/TimeRangeSelector.tsx"
click node_map "https://github.com/jojofunjourney/safecityweb/blob/main/src/components/crime/CrimeMap.tsx"
click node_panels "https://github.com/jojofunjourney/safecityweb/tree/main/src/components/panels"
click node_historypage "https://github.com/jojofunjourney/safecityweb/blob/main/src/app/crime-history/page.tsx"
click node_history "https://github.com/jojofunjourney/safecityweb/blob/main/src/components/crime/CrimeHistory.tsx"
click node_totalpage "https://github.com/jojofunjourney/safecityweb/blob/main/src/app/total-crimes/page.tsx"
click node_total "https://github.com/jojofunjourney/safecityweb/blob/main/src/components/crime/TotalCrime.tsx"
click node_safetypage "https://github.com/jojofunjourney/safecityweb/blob/main/src/app/safety-score/page.tsx"
click node_safety "https://github.com/jojofunjourney/safecityweb/blob/main/src/components/safety/SafetyScore.tsx"
click node_crimeapi "https://github.com/jojofunjourney/safecityweb/blob/main/src/app/api/crime/route.ts"
click node_homeapi "https://github.com/jojofunjourney/safecityweb/blob/main/src/app/api/home/route.ts"
click node_coordapi "https://github.com/jojofunjourney/safecityweb/blob/main/src/app/api/map/coordinates/route.ts"
click node_routeapi "https://github.com/jojofunjourney/safecityweb/blob/main/src/app/api/map/route/route.ts"
click node_crimesvc "https://github.com/jojofunjourney/safecityweb/blob/main/src/services/crimeService.ts"
click node_mapsvc "https://github.com/jojofunjourney/safecityweb/blob/main/src/services/mapService.ts"
click node_apiutil "https://github.com/jojofunjourney/safecityweb/blob/main/src/lib/api.ts"
click node_types "https://github.com/jojofunjourney/safecityweb/blob/main/src/types/crimeData.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_home,node_tracker,node_location,node_address,node_ranges,node_map,node_panels,node_historypage,node_totalpage,node_safetypage,node_user toneBlue
class node_history,node_total,node_safety,node_types toneAmber
class node_crimeapi,node_homeapi,node_coordapi,node_routeapi,node_crimesvc,node_mapsvc,node_apiutil toneMint
class node_citydata,node_google toneRose
```

## Components

### Application UI

- [Home Page](https://github.com/jojofunjourney/safecityweb/blob/main/src/app/page.tsx): `src/app/page.tsx`
- [Tracker Workflow](https://github.com/jojofunjourney/safecityweb/blob/main/src/components/layout/CrimeTrackerApp.tsx): `src/components/layout/CrimeTrackerApp.tsx`
- [Location Controls](https://github.com/jojofunjourney/safecityweb/blob/main/src/components/containers/LocationContainer.tsx): `src/components/containers/LocationContainer.tsx`
- [Address Input](https://github.com/jojofunjourney/safecityweb/blob/main/src/components/inputs/AddressInput.tsx): `src/components/inputs/AddressInput.tsx`
- [Time Range](https://github.com/jojofunjourney/safecityweb/blob/main/src/components/inputs/TimeRangeSelector.tsx): `src/components/inputs/TimeRangeSelector.tsx`
- [Crime Map](https://github.com/jojofunjourney/safecityweb/blob/main/src/components/crime/CrimeMap.tsx): `src/components/crime/CrimeMap.tsx`
- [Summary Panels](https://github.com/jojofunjourney/safecityweb/tree/main/src/components/panels): `src/components/panels`
- [History Page](https://github.com/jojofunjourney/safecityweb/blob/main/src/app/crime-history/page.tsx): `src/app/crime-history/page.tsx`
- [Total Crimes Page](https://github.com/jojofunjourney/safecityweb/blob/main/src/app/total-crimes/page.tsx): `src/app/total-crimes/page.tsx`
- [Safety Page](https://github.com/jojofunjourney/safecityweb/blob/main/src/app/safety-score/page.tsx): `src/app/safety-score/page.tsx`

### Crime Analysis

- [Crime History](https://github.com/jojofunjourney/safecityweb/blob/main/src/components/crime/CrimeHistory.tsx): `src/components/crime/CrimeHistory.tsx`
- [Total Crime View](https://github.com/jojofunjourney/safecityweb/blob/main/src/components/crime/TotalCrime.tsx): `src/components/crime/TotalCrime.tsx`
- [Safety Score View](https://github.com/jojofunjourney/safecityweb/blob/main/src/components/safety/SafetyScore.tsx): `src/components/safety/SafetyScore.tsx`
- [Crime Data Types](https://github.com/jojofunjourney/safecityweb/blob/main/src/types/crimeData.ts): `src/types/crimeData.ts`

### API and Services

- [Crime API](https://github.com/jojofunjourney/safecityweb/blob/main/src/app/api/crime/route.ts): `src/app/api/crime/route.ts`
- [Home API](https://github.com/jojofunjourney/safecityweb/blob/main/src/app/api/home/route.ts): `src/app/api/home/route.ts`
- [Coordinates API](https://github.com/jojofunjourney/safecityweb/blob/main/src/app/api/map/coordinates/route.ts): `src/app/api/map/coordinates/route.ts`
- [Map Route API](https://github.com/jojofunjourney/safecityweb/blob/main/src/app/api/map/route/route.ts): `src/app/api/map/route/route.ts`
- [Crime Data Service](https://github.com/jojofunjourney/safecityweb/blob/main/src/services/crimeService.ts): `src/services/crimeService.ts`
- [Geocoding Service](https://github.com/jojofunjourney/safecityweb/blob/main/src/services/mapService.ts): `src/services/mapService.ts`
- [Client API](https://github.com/jojofunjourney/safecityweb/blob/main/src/lib/api.ts): `src/lib/api.ts`

### External Data

- **City Open Data**
- **Google Geocoding**

### Other components

- **User**

## Connections

- User → Home Page: opens (evidence: `README.md`)
- Home Page → Tracker Workflow: renders (evidence: `src/app/page.tsx`)
- Tracker Workflow → Location Controls: renders (evidence: `src/components/layout/CrimeTrackerApp.tsx`)
- Location Controls → Address Input: renders (evidence: `src/components/containers/LocationContainer.tsx`)
- Location Controls → Time Range: renders (evidence: `src/components/containers/LocationContainer.tsx`)
- Location Controls → Crime Map: renders (evidence: `src/components/containers/LocationContainer.tsx`)
- Address Input → Tracker Workflow: selects location (evidence: `src/components/layout/CrimeTrackerApp.tsx`)
- Tracker Workflow → Client API: requests data (evidence: `src/components/layout/CrimeTrackerApp.tsx`)
- Client API → Crime API: HTTP request (evidence: `src/lib/api.ts`)
- Crime API → Crime Data Service: fetches crime data (evidence: `src/app/api/crime/route.ts`)
- Crime Data Service → City Open Data: queries (evidence: `src/services/crimeService.ts`)
- Crime API → Crime Data Types: uses response types (evidence: `src/app/api/crime/route.ts`)
- Tracker Workflow → Summary Panels: renders results (evidence: `src/components/layout/CrimeTrackerApp.tsx`)
- History Page → Crime History: renders (evidence: `src/app/crime-history/page.tsx`)
- Total Crimes Page → Total Crime View: renders (evidence: `src/app/total-crimes/page.tsx`)
- Safety Page → Safety Score View: renders (evidence: `src/app/safety-score/page.tsx`)
- Address Input → Client API: requests coordinates lookup (evidence: `src/components/inputs/AddressInput.tsx`)
- Client API → Coordinates API: HTTP request (evidence: `src/lib/api.ts`)
- Coordinates API → Geocoding Service: geocodes coordinates (evidence: `src/app/api/map/coordinates/route.ts`)
- Geocoding Service → Google Geocoding: geocoding request (evidence: `src/services/mapService.ts`)
