# guangfuhero/optimized-version architecture

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

- Interactive diagram: https://gitdiagram.com/guangfuhero/optimized-version
- Repository: https://github.com/guangfuhero/optimized-version

## Overview

This repository implements a disaster-relief and resource-coordination platform. A user enters through the API or GraphQL surface; the backend provides authentication and authorization, then exposes ticket, station/geospatial, and supporting operational capabilities backed by repositories and models. The README additionally documents task matching, point sharing, briefings, announcements, analytics, work zones, duplicate checking, and floor-level markers. Several of these are represented by modules in the tree, but their runtime wiring was not sampled; those links are omitted rather than inferred. The design and system-design directories are not part of this runtime map.

Main entry points: [`Backend/app/graphql/tickets/mutations.py`](https://github.com/guangfuhero/optimized-version/blob/main/Backend/app/graphql/tickets/mutations.py) (Task reports and matching), [`Backend/app/graphql/schema.py`](https://github.com/guangfuhero/optimized-version/blob/main/Backend/app/graphql/schema.py) (GraphQL schema), [`Backend/app/main.py`](https://github.com/guangfuhero/optimized-version/blob/main/Backend/app/main.py) (FastAPI application), [`Backend/app/core/security.py`](https://github.com/guangfuhero/optimized-version/blob/main/Backend/app/core/security.py) (Authentication and RBAC)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Platform entry"]
  node_api_app["FastAPI application<br/>[main.py]"]
  node_rest_api["REST API routes<br/>[api.py]"]
  node_graphql_api["GraphQL router<br/>[router.py]"]
  node_graphql_schema["GraphQL schema<br/>[schema.py]"]
end

subgraph group_identity["Identity and access"]
  node_auth_routes["Authentication routes"]
  node_auth_security["Authentication and RBAC<br/>[security.py]"]
  node_auth_repo["Identity repository<br/>[auth_repository.py]"]
  node_session_repo["Session storage"]
  node_identity_models[("Identity models<br/>[auth.py]")]
end

subgraph group_relief["Relief operations"]
  node_tickets["Task reports and matching<br/>[mutations.py]"]
  node_ticket_repo["Ticket data access"]
  node_geo["Maps and stations<br/>[queries.py]"]
  node_work_zones["Work-zone assignment"]
end

subgraph group_support["Operational services"]
  node_briefings["Volunteer briefings<br/>[queries.py]"]
  node_announcements["Emergency announcements<br/>[queries.py]"]
  node_analytics["Analytics dashboard<br/>[analytics.py]"]
  node_duplicate_check["Duplicate checking<br/>[suggestion.py]"]
  node_floor_markers["Floor-level markers"]
end

subgraph group_client["Client experience"]
  node_point_share["Point sharing"]
  node_map_client["Interactive map"]
  node_client_data["API data access<br/>[urql.ts]"]
end

node_users(("Platform users"))

node_users -->|"use platform"| node_api_app
node_api_app -->|"mounts routes"| node_rest_api
node_api_app -->|"mounts GraphQL"| node_graphql_api
node_graphql_api -->|"serves schema"| node_graphql_schema
node_rest_api -->|"registers routes"| node_auth_routes
node_users -->|"authenticate"| node_auth_routes
node_auth_routes -.->|"validates identity"| node_auth_security
node_auth_security -->|"checks sessions"| node_session_repo
node_auth_security -->|"loads identity"| node_auth_repo
node_auth_repo -->|"queries identity"| node_identity_models
node_graphql_schema -->|"registers resolvers"| node_tickets
node_tickets -->|"accesses tickets"| node_ticket_repo
node_graphql_schema -->|"registers resolvers"| node_geo
node_graphql_schema -->|"registers resolvers"| node_work_zones
node_users -->|"view relief map"| node_map_client
node_map_client -.->|"loads map data"| node_client_data
node_users -->|"share page"| node_point_share
node_users -->|"report task"| node_tickets
node_tickets -.->|"uses map context"| node_geo
node_users -.->|"view briefings"| node_briefings
node_users -.->|"view announcements"| node_announcements
node_tickets -->|"feeds analysis"| node_analytics
node_tickets -->|"checks duplicates"| node_duplicate_check
node_tickets -->|"supports floor rescue"| node_floor_markers
node_work_zones -->|"shows assigned areas"| node_map_client

click node_api_app "https://github.com/guangfuhero/optimized-version/blob/main/Backend/app/main.py"
click node_rest_api "https://github.com/guangfuhero/optimized-version/blob/main/Backend/app/api/v1/api.py"
click node_graphql_api "https://github.com/guangfuhero/optimized-version/blob/main/Backend/app/graphql/router.py"
click node_graphql_schema "https://github.com/guangfuhero/optimized-version/blob/main/Backend/app/graphql/schema.py"
click node_auth_routes "https://github.com/guangfuhero/optimized-version/tree/main/Backend/app/api/v1/endpoints/auth"
click node_auth_security "https://github.com/guangfuhero/optimized-version/blob/main/Backend/app/core/security.py"
click node_auth_repo "https://github.com/guangfuhero/optimized-version/blob/main/Backend/app/repositories/auth_repository.py"
click node_session_repo "https://github.com/guangfuhero/optimized-version/blob/main/Backend/app/repositories/session_repository.py"
click node_identity_models "https://github.com/guangfuhero/optimized-version/blob/main/Backend/app/models/auth.py"
click node_tickets "https://github.com/guangfuhero/optimized-version/blob/main/Backend/app/graphql/tickets/mutations.py"
click node_ticket_repo "https://github.com/guangfuhero/optimized-version/blob/main/Backend/app/repositories/tickets_repository.py"
click node_geo "https://github.com/guangfuhero/optimized-version/blob/main/Backend/app/graphql/geo/queries.py"
click node_work_zones "https://github.com/guangfuhero/optimized-version/tree/main/Backend/app/graphql/work_zone"
click node_point_share "https://github.com/guangfuhero/optimized-version/blob/main/Frontend/libs/modules/src/point-share/point-share-drawer.tsx"
click node_map_client "https://github.com/guangfuhero/optimized-version/blob/main/Frontend/libs/modules/src/map/hooks/use-rescue-map-controller.ts"
click node_client_data "https://github.com/guangfuhero/optimized-version/blob/main/Frontend/libs/data-access/src/graphql/client/urql.ts"
click node_briefings "https://github.com/guangfuhero/optimized-version/blob/main/Backend/app/graphql/briefings/queries.py"
click node_announcements "https://github.com/guangfuhero/optimized-version/blob/main/Backend/app/graphql/announcements/queries.py"
click node_analytics "https://github.com/guangfuhero/optimized-version/blob/main/Backend/app/api/v1/endpoints/analytics.py"
click node_duplicate_check "https://github.com/guangfuhero/optimized-version/blob/main/Backend/app/services/suggestion.py"
click node_floor_markers "https://github.com/guangfuhero/optimized-version/tree/main/Frontend/libs/modules/src/map"

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_api_app,node_rest_api,node_graphql_api,node_graphql_schema,node_users toneBlue
class node_auth_routes,node_auth_security,node_auth_repo,node_session_repo,node_identity_models toneAmber
class node_tickets,node_ticket_repo,node_geo,node_work_zones toneMint
class node_briefings,node_announcements,node_analytics,node_duplicate_check,node_floor_markers toneRose
class node_point_share,node_map_client,node_client_data toneIndigo
```

## Components

### Platform entry

- [FastAPI application](https://github.com/guangfuhero/optimized-version/blob/main/Backend/app/main.py): `Backend/app/main.py`
- [REST API routes](https://github.com/guangfuhero/optimized-version/blob/main/Backend/app/api/v1/api.py): `Backend/app/api/v1/api.py`
- [GraphQL router](https://github.com/guangfuhero/optimized-version/blob/main/Backend/app/graphql/router.py): `Backend/app/graphql/router.py`
- [GraphQL schema](https://github.com/guangfuhero/optimized-version/blob/main/Backend/app/graphql/schema.py): `Backend/app/graphql/schema.py`

### Identity and access

- [Authentication routes](https://github.com/guangfuhero/optimized-version/tree/main/Backend/app/api/v1/endpoints/auth): `Backend/app/api/v1/endpoints/auth`
- [Authentication and RBAC](https://github.com/guangfuhero/optimized-version/blob/main/Backend/app/core/security.py): `Backend/app/core/security.py`
- [Identity repository](https://github.com/guangfuhero/optimized-version/blob/main/Backend/app/repositories/auth_repository.py): `Backend/app/repositories/auth_repository.py`
- [Session storage](https://github.com/guangfuhero/optimized-version/blob/main/Backend/app/repositories/session_repository.py): `Backend/app/repositories/session_repository.py`
- [Identity models](https://github.com/guangfuhero/optimized-version/blob/main/Backend/app/models/auth.py): `Backend/app/models/auth.py`

### Relief operations

- [Task reports and matching](https://github.com/guangfuhero/optimized-version/blob/main/Backend/app/graphql/tickets/mutations.py): `Backend/app/graphql/tickets/mutations.py`
- [Ticket data access](https://github.com/guangfuhero/optimized-version/blob/main/Backend/app/repositories/tickets_repository.py): `Backend/app/repositories/tickets_repository.py`
- [Maps and stations](https://github.com/guangfuhero/optimized-version/blob/main/Backend/app/graphql/geo/queries.py): `Backend/app/graphql/geo/queries.py`
- [Work-zone assignment](https://github.com/guangfuhero/optimized-version/tree/main/Backend/app/graphql/work_zone): `Backend/app/graphql/work_zone`

### Operational services

- [Volunteer briefings](https://github.com/guangfuhero/optimized-version/blob/main/Backend/app/graphql/briefings/queries.py): `Backend/app/graphql/briefings/queries.py`
- [Emergency announcements](https://github.com/guangfuhero/optimized-version/blob/main/Backend/app/graphql/announcements/queries.py): `Backend/app/graphql/announcements/queries.py`
- [Analytics dashboard](https://github.com/guangfuhero/optimized-version/blob/main/Backend/app/api/v1/endpoints/analytics.py): `Backend/app/api/v1/endpoints/analytics.py`
- [Duplicate checking](https://github.com/guangfuhero/optimized-version/blob/main/Backend/app/services/suggestion.py): `Backend/app/services/suggestion.py`
- [Floor-level markers](https://github.com/guangfuhero/optimized-version/tree/main/Frontend/libs/modules/src/map): `Frontend/libs/modules/src/map`

### Client experience

- [Point sharing](https://github.com/guangfuhero/optimized-version/blob/main/Frontend/libs/modules/src/point-share/point-share-drawer.tsx): `Frontend/libs/modules/src/point-share/point-share-drawer.tsx`
- [Interactive map](https://github.com/guangfuhero/optimized-version/blob/main/Frontend/libs/modules/src/map/hooks/use-rescue-map-controller.ts): `Frontend/libs/modules/src/map/hooks/use-rescue-map-controller.ts`
- [API data access](https://github.com/guangfuhero/optimized-version/blob/main/Frontend/libs/data-access/src/graphql/client/urql.ts): `Frontend/libs/data-access/src/graphql/client/urql.ts`

### Other components

- **Platform users**

## Connections

- Platform users → FastAPI application: use platform (evidence: `Backend/app/main.py`)
- FastAPI application → REST API routes: mounts routes (evidence: `Backend/app/main.py`)
- FastAPI application → GraphQL router: mounts GraphQL (evidence: `Backend/app/main.py`)
- GraphQL router → GraphQL schema: serves schema (evidence: `Backend/app/graphql/router.py`)
- REST API routes → Authentication routes: registers routes (evidence: `Backend/app/api/v1/api.py`)
- Platform users → Authentication routes: authenticate
- Authentication routes → Authentication and RBAC: validates identity
- Authentication and RBAC → Session storage: checks sessions (evidence: `Backend/app/core/security.py`)
- Authentication and RBAC → Identity repository: loads identity (evidence: `Backend/app/core/security.py`)
- Identity repository → Identity models: queries identity (evidence: `Backend/app/repositories/auth_repository.py`)
- GraphQL schema → Task reports and matching: registers resolvers (evidence: `Backend/app/graphql/schema.py`)
- Task reports and matching → Ticket data access: accesses tickets (evidence: `Backend/app/repositories/tickets_repository.py`)
- GraphQL schema → Maps and stations: registers resolvers (evidence: `Backend/app/graphql/schema.py`)
- GraphQL schema → Work-zone assignment: registers resolvers (evidence: `Backend/app/graphql/schema.py`)
- Platform users → Interactive map: view relief map
- Interactive map → API data access: loads map data
- Platform users → Point sharing: share page
- Platform users → Task reports and matching: report task
- Task reports and matching → Maps and stations: uses map context
- Platform users → Volunteer briefings: view briefings
- Platform users → Emergency announcements: view announcements
- Task reports and matching → Analytics dashboard: feeds analysis
- Task reports and matching → Duplicate checking: checks duplicates
- Task reports and matching → Floor-level markers: supports floor rescue
- Work-zone assignment → Interactive map: shows assigned areas
