# dbstkdgh/cpt4 architecture

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

- Interactive diagram: https://gitdiagram.com/dbstkdgh/cpt4
- Repository: https://github.com/dbstkdgh/cpt4

## Overview

This repository contains Streamlit dashboards for mapping anomalous-motive crime locations and regional risk. The user selects an all-time, yearly, daily, or prediction view; the app loads crime, indicator, prediction, and province-boundary data, then renders a map and (in some versions) regional risk summaries. The four scripts are standalone variants rather than a shared package. The excerpts show their loading, map, and risk behavior, but the README gives no implementation detail; only the visible calls and data paths are represented.

Main entry points: [`real.py`](https://github.com/dbstkdgh/cpt4/blob/main/real.py) (Deployed map variant), [`app2.py`](https://github.com/dbstkdgh/cpt4/blob/main/app2.py) (Dashboard variant), [`lab5.py`](https://github.com/dbstkdgh/cpt4/blob/main/lab5.py) (Alert map variant), [`data/15~25년도 이상동기(도단위추가)_with_coords_openai.csv`](https://github.com/dbstkdgh/cpt4/blob/main/data/15~25%EB%85%84%EB%8F%84%20%EC%9D%B4%EC%83%81%EB%8F%99%EA%B8%B0(%EB%8F%84%EB%8B%A8%EC%9C%84%EC%B6%94%EA%B0%80)_with_coords_openai.csv) (Crime locations)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_dashboards["Dashboard variants"]
  node_app["Dashboard app<br/>[app.py]"]
  node_app2["Dashboard variant<br/>[app2.py]"]
  node_lab5["Alert map variant<br/>[lab5.py]"]
  node_real["Deployed map variant<br/>[real.py]"]
end

subgraph group_inputs["Data inputs"]
  node_crime_csv["Crime locations"]
  node_indicator_csv["Risk indicators"]
  node_prediction_csv["Prediction data<br/>[predict.csv]"]
  node_prediction_csv_app["Prediction data path"]
  node_province_geo["Province boundaries"]
end

subgraph group_mapping["Mapping and risk"]
  node_data_loading["Load and prepare data<br/>[real.py]"]
  node_risk_scoring["Regional risk scoring<br/>[real.py]"]
  node_map_rendering["Interactive map<br/>[real.py]"]
  node_risk_table["Regional risk table<br/>[real.py]"]
end

node_user(("Dashboard user"))
node_geo_service["GeoJSON source"]

node_user -->|"selects view"| node_real
node_real -->|"loads data"| node_data_loading
node_data_loading -->|"reads locations"| node_crime_csv
node_data_loading -->|"reads indicators"| node_indicator_csv
node_data_loading -->|"reads predictions"| node_prediction_csv
node_real -->|"fetches boundaries"| node_geo_service
node_geo_service -->|"returns GeoJSON"| node_province_geo
node_real -->|"creates map"| node_map_rendering
node_real -->|"builds summary"| node_risk_table
node_map_rendering -->|"calculates scores"| node_risk_scoring
node_map_rendering -->|"renders regions"| node_province_geo
node_user -->|"selects view"| node_app
node_app -->|"uses prediction path"| node_prediction_csv_app
node_user -->|"selects view"| node_app2
node_app2 -->|"loads locations"| node_crime_csv
node_app2 -->|"loads indicators"| node_indicator_csv
node_app2 -->|"uses prediction path"| node_prediction_csv_app
node_user -->|"selects view"| node_lab5
node_lab5 -->|"loads locations"| node_crime_csv
node_lab5 -->|"loads indicators"| node_indicator_csv
node_lab5 -->|"uses prediction path"| node_prediction_csv_app

click node_app "https://github.com/dbstkdgh/cpt4/blob/main/app.py"
click node_app2 "https://github.com/dbstkdgh/cpt4/blob/main/app2.py"
click node_lab5 "https://github.com/dbstkdgh/cpt4/blob/main/lab5.py"
click node_real "https://github.com/dbstkdgh/cpt4/blob/main/real.py"
click node_crime_csv "https://github.com/dbstkdgh/cpt4/blob/main/data/15~25%EB%85%84%EB%8F%84%20%EC%9D%B4%EC%83%81%EB%8F%99%EA%B8%B0(%EB%8F%84%EB%8B%A8%EC%9C%84%EC%B6%94%EA%B0%80)_with_coords_openai.csv"
click node_indicator_csv "https://github.com/dbstkdgh/cpt4/blob/main/data/%EC%A7%80%ED%91%9C%EB%8D%B0%EC%9D%B4%ED%84%B0(4%EB%8C%80%EB%B2%94%EC%A3%84%EC%B6%94%EA%B0%80%EA%B3%84%EC%82%B0).csv"
click node_prediction_csv "https://github.com/dbstkdgh/cpt4/blob/main/data/predict.csv"
click node_data_loading "https://github.com/dbstkdgh/cpt4/blob/main/real.py"
click node_risk_scoring "https://github.com/dbstkdgh/cpt4/blob/main/real.py"
click node_map_rendering "https://github.com/dbstkdgh/cpt4/blob/main/real.py"
click node_risk_table "https://github.com/dbstkdgh/cpt4/blob/main/real.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_app2,node_lab5,node_real,node_user toneBlue
class node_crime_csv,node_indicator_csv,node_prediction_csv,node_prediction_csv_app,node_province_geo toneAmber
class node_data_loading,node_risk_scoring,node_map_rendering,node_risk_table toneMint
class node_geo_service toneIndigo
```

## Components

### Dashboard variants

- [Dashboard app](https://github.com/dbstkdgh/cpt4/blob/main/app.py): `app.py`
- [Dashboard variant](https://github.com/dbstkdgh/cpt4/blob/main/app2.py): `app2.py`
- [Alert map variant](https://github.com/dbstkdgh/cpt4/blob/main/lab5.py): `lab5.py`
- [Deployed map variant](https://github.com/dbstkdgh/cpt4/blob/main/real.py): `real.py`

### Data inputs

- [Crime locations](https://github.com/dbstkdgh/cpt4/blob/main/data/15~25%EB%85%84%EB%8F%84%20%EC%9D%B4%EC%83%81%EB%8F%99%EA%B8%B0(%EB%8F%84%EB%8B%A8%EC%9C%84%EC%B6%94%EA%B0%80)_with_coords_openai.csv): `data/15~25년도 이상동기(도단위추가)_with_coords_openai.csv`
- [Risk indicators](https://github.com/dbstkdgh/cpt4/blob/main/data/%EC%A7%80%ED%91%9C%EB%8D%B0%EC%9D%B4%ED%84%B0(4%EB%8C%80%EB%B2%94%EC%A3%84%EC%B6%94%EA%B0%80%EA%B3%84%EC%82%B0).csv): `data/지표데이터(4대범죄추가계산).csv`
- [Prediction data](https://github.com/dbstkdgh/cpt4/blob/main/data/predict.csv): `data/predict.csv`
- **Prediction data path**
- **Province boundaries**

### Mapping and risk

- [Load and prepare data](https://github.com/dbstkdgh/cpt4/blob/main/real.py): `real.py`
- [Regional risk scoring](https://github.com/dbstkdgh/cpt4/blob/main/real.py): `real.py`
- [Interactive map](https://github.com/dbstkdgh/cpt4/blob/main/real.py): `real.py`
- [Regional risk table](https://github.com/dbstkdgh/cpt4/blob/main/real.py): `real.py`

### Other components

- **Dashboard user**
- **GeoJSON source**

## Connections

- Dashboard user → Deployed map variant: selects view (evidence: `real.py`)
- Deployed map variant → Load and prepare data: loads data (evidence: `real.py`)
- Load and prepare data → Crime locations: reads locations (evidence: `real.py`)
- Load and prepare data → Risk indicators: reads indicators (evidence: `real.py`)
- Load and prepare data → Prediction data: reads predictions (evidence: `real.py`)
- Deployed map variant → GeoJSON source: fetches boundaries (evidence: `real.py`)
- GeoJSON source → Province boundaries: returns GeoJSON
- Deployed map variant → Interactive map: creates map (evidence: `real.py`)
- Deployed map variant → Regional risk table: builds summary (evidence: `real.py`)
- Interactive map → Regional risk scoring: calculates scores (evidence: `real.py`)
- Interactive map → Province boundaries: renders regions (evidence: `real.py`)
- Dashboard user → Dashboard app: selects view (evidence: `app.py`)
- Dashboard app → Prediction data path: uses prediction path (evidence: `app.py`)
- Dashboard user → Dashboard variant: selects view (evidence: `app2.py`)
- Dashboard variant → Crime locations: loads locations (evidence: `app2.py`)
- Dashboard variant → Risk indicators: loads indicators (evidence: `app2.py`)
- Dashboard variant → Prediction data path: uses prediction path (evidence: `app2.py`)
- Dashboard user → Alert map variant: selects view (evidence: `lab5.py`)
- Alert map variant → Crime locations: loads locations (evidence: `lab5.py`)
- Alert map variant → Risk indicators: loads indicators (evidence: `lab5.py`)
- Alert map variant → Prediction data path: uses prediction path (evidence: `lab5.py`)
