# anselmoneto/be-the-hero architecture

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

## Overview

Be The Hero helps NGOs register and manage incident cases, while the web and mobile clients let people find cases and contact NGOs to offer help. The main flow runs from a client screen through its API service to backend routes and controllers, which query or update the database. The web client also supports NGO login, profiles, and incident creation; the mobile client lists paginated incidents and opens their details. Backend route and controller links are shown where the excerpts support them; client-to-server links are dashed because the shown sources do not establish that wiring.

Main entry points: [`frontend/src/routes.js`](https://github.com/anselmoneto/be-the-hero/blob/master/frontend/src/routes.js) (Web routes), [`backend/src/routes.js`](https://github.com/anselmoneto/be-the-hero/blob/master/backend/src/routes.js) (API routes), [`frontend/src/services/api.js`](https://github.com/anselmoneto/be-the-hero/blob/master/frontend/src/services/api.js) (Web API client), [`backend/src/database/connection.js`](https://github.com/anselmoneto/be-the-hero/blob/master/backend/src/database/connection.js) (Query connection)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web client"]
  node_webapp["Web app<br/>[App.js]"]
  node_webroutes["Web routes<br/>[routes.js]"]
  node_webregister["NGO registration<br/>[index.js]"]
  node_weblogon["NGO login<br/>[index.js]"]
  node_webprofile["NGO profile<br/>[index.js]"]
  node_webnewincident["Create incident<br/>[index.js]"]
  node_webapi["Web API client<br/>[api.js]"]
end

subgraph group_mobile["Mobile client"]
  node_mobileapp["Mobile app<br/>[App.js]"]
  node_mobileroutes["Mobile routes<br/>[routes.js]"]
  node_mobileincidents["Incident list<br/>[index.js]"]
  node_mobiledetails["Incident details<br/>[index.js]"]
  node_mobileapi["Mobile API client<br/>[api.js]"]
end

subgraph group_backend["Backend API"]
  node_server["HTTP app<br/>[app.js]"]
  node_routes["API routes<br/>[routes.js]"]
  node_ongcontroller["NGO accounts<br/>[OngController.js]"]
  node_sessioncontroller["Session lookup"]
  node_profilecontroller["Profile lookup"]
  node_incidentcontroller["Incident management"]
  node_uniqueid["ID generation"]
end

subgraph group_storage["Persistence"]
  node_connection["Query connection<br/>[connection.js]"]
  node_database[("Relational database<br/>[knexfile.js]")]
end

node_visitor(("NGO / visitor"))

node_visitor -->|"uses"| node_webapp
node_webapp -->|"renders"| node_webroutes
node_webroutes -->|"routes to"| node_webregister
node_webroutes -->|"routes to"| node_weblogon
node_webroutes -->|"routes to"| node_webprofile
node_webroutes -->|"routes to"| node_webnewincident
node_webregister -->|"submits via"| node_webapi
node_weblogon -->|"requests via"| node_webapi
node_webprofile -->|"requests via"| node_webapi
node_webnewincident -->|"submits via"| node_webapi
node_webapi -.->|"HTTP requests"| node_server
node_visitor -->|"uses"| node_mobileapp
node_mobileapp -->|"renders"| node_mobileroutes
node_mobileroutes -->|"routes to"| node_mobileincidents
node_mobileroutes -->|"routes to"| node_mobiledetails
node_mobileincidents -->|"loads cases via"| node_mobileapi
node_mobileincidents -->|"navigates to"| node_mobiledetails
node_mobileapi -.->|"HTTP requests"| node_server
node_server -->|"mounts"| node_routes
node_routes -->|"dispatches"| node_ongcontroller
node_routes -->|"dispatches"| node_sessioncontroller
node_routes -->|"dispatches"| node_profilecontroller
node_routes -->|"dispatches"| node_incidentcontroller
node_ongcontroller -->|"queries"| node_connection
node_ongcontroller -->|"generates ID"| node_uniqueid
node_sessioncontroller -->|"queries"| node_connection
node_profilecontroller -->|"queries"| node_connection
node_incidentcontroller -->|"queries"| node_connection
node_connection -->|"configures"| node_database

click node_webapp "https://github.com/anselmoneto/be-the-hero/blob/master/frontend/src/App.js"
click node_webroutes "https://github.com/anselmoneto/be-the-hero/blob/master/frontend/src/routes.js"
click node_webregister "https://github.com/anselmoneto/be-the-hero/blob/master/frontend/src/pages/Register/index.js"
click node_weblogon "https://github.com/anselmoneto/be-the-hero/blob/master/frontend/src/pages/Logon/index.js"
click node_webprofile "https://github.com/anselmoneto/be-the-hero/blob/master/frontend/src/pages/Profile/index.js"
click node_webnewincident "https://github.com/anselmoneto/be-the-hero/blob/master/frontend/src/pages/NewIncident/index.js"
click node_webapi "https://github.com/anselmoneto/be-the-hero/blob/master/frontend/src/services/api.js"
click node_mobileapp "https://github.com/anselmoneto/be-the-hero/blob/master/mobile/App.js"
click node_mobileroutes "https://github.com/anselmoneto/be-the-hero/blob/master/mobile/src/routes.js"
click node_mobileincidents "https://github.com/anselmoneto/be-the-hero/blob/master/mobile/src/pages/Incidents/index.js"
click node_mobiledetails "https://github.com/anselmoneto/be-the-hero/blob/master/mobile/src/pages/Details/index.js"
click node_mobileapi "https://github.com/anselmoneto/be-the-hero/blob/master/mobile/src/services/api.js"
click node_server "https://github.com/anselmoneto/be-the-hero/blob/master/backend/src/app.js"
click node_routes "https://github.com/anselmoneto/be-the-hero/blob/master/backend/src/routes.js"
click node_ongcontroller "https://github.com/anselmoneto/be-the-hero/blob/master/backend/src/controllers/OngController.js"
click node_sessioncontroller "https://github.com/anselmoneto/be-the-hero/blob/master/backend/src/controllers/SessionController.js"
click node_profilecontroller "https://github.com/anselmoneto/be-the-hero/blob/master/backend/src/controllers/ProfileController.js"
click node_incidentcontroller "https://github.com/anselmoneto/be-the-hero/blob/master/backend/src/controllers/IncidentController.js"
click node_uniqueid "https://github.com/anselmoneto/be-the-hero/blob/master/backend/src/utils/generateUniqueId.js"
click node_connection "https://github.com/anselmoneto/be-the-hero/blob/master/backend/src/database/connection.js"
click node_database "https://github.com/anselmoneto/be-the-hero/blob/master/backend/knexfile.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_webapp,node_webroutes,node_webregister,node_weblogon,node_webprofile,node_webnewincident,node_webapi toneBlue
class node_mobileapp,node_mobileroutes,node_mobileincidents,node_mobiledetails,node_mobileapi toneAmber
class node_server,node_routes,node_ongcontroller,node_sessioncontroller,node_profilecontroller,node_incidentcontroller,node_uniqueid toneMint
class node_connection,node_database toneRose
class node_visitor toneIndigo
```

## Components

### Web client

- [Web app](https://github.com/anselmoneto/be-the-hero/blob/master/frontend/src/App.js): `frontend/src/App.js`
- [Web routes](https://github.com/anselmoneto/be-the-hero/blob/master/frontend/src/routes.js): `frontend/src/routes.js`
- [NGO registration](https://github.com/anselmoneto/be-the-hero/blob/master/frontend/src/pages/Register/index.js): `frontend/src/pages/Register/index.js`
- [NGO login](https://github.com/anselmoneto/be-the-hero/blob/master/frontend/src/pages/Logon/index.js): `frontend/src/pages/Logon/index.js`
- [NGO profile](https://github.com/anselmoneto/be-the-hero/blob/master/frontend/src/pages/Profile/index.js): `frontend/src/pages/Profile/index.js`
- [Create incident](https://github.com/anselmoneto/be-the-hero/blob/master/frontend/src/pages/NewIncident/index.js): `frontend/src/pages/NewIncident/index.js`
- [Web API client](https://github.com/anselmoneto/be-the-hero/blob/master/frontend/src/services/api.js): `frontend/src/services/api.js`

### Mobile client

- [Mobile app](https://github.com/anselmoneto/be-the-hero/blob/master/mobile/App.js): `mobile/App.js`
- [Mobile routes](https://github.com/anselmoneto/be-the-hero/blob/master/mobile/src/routes.js): `mobile/src/routes.js`
- [Incident list](https://github.com/anselmoneto/be-the-hero/blob/master/mobile/src/pages/Incidents/index.js): `mobile/src/pages/Incidents/index.js`
- [Incident details](https://github.com/anselmoneto/be-the-hero/blob/master/mobile/src/pages/Details/index.js): `mobile/src/pages/Details/index.js`
- [Mobile API client](https://github.com/anselmoneto/be-the-hero/blob/master/mobile/src/services/api.js): `mobile/src/services/api.js`

### Backend API

- [HTTP app](https://github.com/anselmoneto/be-the-hero/blob/master/backend/src/app.js): `backend/src/app.js`
- [API routes](https://github.com/anselmoneto/be-the-hero/blob/master/backend/src/routes.js): `backend/src/routes.js`
- [NGO accounts](https://github.com/anselmoneto/be-the-hero/blob/master/backend/src/controllers/OngController.js): `backend/src/controllers/OngController.js`
- [Session lookup](https://github.com/anselmoneto/be-the-hero/blob/master/backend/src/controllers/SessionController.js): `backend/src/controllers/SessionController.js`
- [Profile lookup](https://github.com/anselmoneto/be-the-hero/blob/master/backend/src/controllers/ProfileController.js): `backend/src/controllers/ProfileController.js`
- [Incident management](https://github.com/anselmoneto/be-the-hero/blob/master/backend/src/controllers/IncidentController.js): `backend/src/controllers/IncidentController.js`
- [ID generation](https://github.com/anselmoneto/be-the-hero/blob/master/backend/src/utils/generateUniqueId.js): `backend/src/utils/generateUniqueId.js`

### Persistence

- [Query connection](https://github.com/anselmoneto/be-the-hero/blob/master/backend/src/database/connection.js): `backend/src/database/connection.js`
- [Relational database](https://github.com/anselmoneto/be-the-hero/blob/master/backend/knexfile.js): `backend/knexfile.js`

### Other components

- **NGO / visitor**

## Connections

- NGO / visitor → Web app: uses
- Web app → Web routes: renders (evidence: `frontend/src/App.js`)
- Web routes → NGO registration: routes to (evidence: `frontend/src/routes.js`)
- Web routes → NGO login: routes to (evidence: `frontend/src/routes.js`)
- Web routes → NGO profile: routes to (evidence: `frontend/src/routes.js`)
- Web routes → Create incident: routes to (evidence: `frontend/src/routes.js`)
- NGO registration → Web API client: submits via (evidence: `frontend/src/pages/Register/index.js`)
- NGO login → Web API client: requests via (evidence: `frontend/src/pages/Logon/index.js`)
- NGO profile → Web API client: requests via (evidence: `frontend/src/pages/Profile/index.js`)
- Create incident → Web API client: submits via (evidence: `frontend/src/pages/NewIncident/index.js`)
- Web API client → HTTP app: HTTP requests
- NGO / visitor → Mobile app: uses
- Mobile app → Mobile routes: renders (evidence: `mobile/App.js`)
- Mobile routes → Incident list: routes to (evidence: `mobile/src/routes.js`)
- Mobile routes → Incident details: routes to (evidence: `mobile/src/routes.js`)
- Incident list → Mobile API client: loads cases via (evidence: `mobile/src/pages/Incidents/index.js`)
- Incident list → Incident details: navigates to (evidence: `mobile/src/pages/Incidents/index.js`)
- Mobile API client → HTTP app: HTTP requests
- HTTP app → API routes: mounts (evidence: `backend/src/app.js`)
- API routes → NGO accounts: dispatches (evidence: `backend/src/routes.js`)
- API routes → Session lookup: dispatches (evidence: `backend/src/routes.js`)
- API routes → Profile lookup: dispatches (evidence: `backend/src/routes.js`)
- API routes → Incident management: dispatches (evidence: `backend/src/routes.js`)
- NGO accounts → Query connection: queries (evidence: `backend/src/controllers/OngController.js`)
- NGO accounts → ID generation: generates ID (evidence: `backend/src/controllers/OngController.js`)
- Session lookup → Query connection: queries (evidence: `backend/src/controllers/SessionController.js`)
- Profile lookup → Query connection: queries (evidence: `backend/src/controllers/ProfileController.js`)
- Incident management → Query connection: queries (evidence: `backend/src/controllers/IncidentController.js`)
- Query connection → Relational database: configures (evidence: `backend/src/database/connection.js`)
