# ivanmercado0998/aerotrace architecture

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

- Interactive diagram: https://gitdiagram.com/ivanmercado0998/aerotrace
- Repository: https://github.com/ivanmercado0998/aerotrace

## Overview

AeroTrace is an admin-facing air-quality monitoring dashboard for a multi-node deposition network. The intended workflow is to sign in, inspect monitoring nodes and pollution sources on a map, review readings and history, manage nodes, and use source-identification and reporting capabilities described on the landing page. Sampled source confirms the map, location search, and authentication wiring; dashboard composition and several advertised capabilities are not shown, so their implementation links are omitted. PostgreSQL is configured through the shared database module.

Main entry points: [`app/dashboard/page.tsx`](https://github.com/ivanmercado0998/aerotrace/blob/master/app/dashboard/page.tsx) (Dashboard page), [`app/page.tsx`](https://github.com/ivanmercado0998/aerotrace/blob/master/app/page.tsx) (Landing page), [`lib/db/index.ts`](https://github.com/ivanmercado0998/aerotrace/blob/master/lib/db/index.ts) (Drizzle database), [`components/auth-form.tsx`](https://github.com/ivanmercado0998/aerotrace/blob/master/components/auth-form.tsx) (Admin login form)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_access["Access and sessions"]
  node_landing["Landing page<br/>[page.tsx]"]
  node_loginform["Admin login form<br/>[auth-form.tsx]"]
  node_adminlogin["Admin login endpoint<br/>[route.ts]"]
  node_adminlogout["Admin logout endpoint<br/>[route.ts]"]
  node_adminauth["Admin session helpers<br/>[admin-auth.ts]"]
  node_authroute["Auth API route<br/>[route.ts]"]
  node_authconfig["Auth configuration<br/>[auth.ts]"]
  node_authclient["Auth client<br/>[auth-client.ts]"]
end

subgraph group_dashboard["Monitoring dashboard"]
  node_dashboardpage["Dashboard page<br/>[page.tsx]"]
  node_map["Pollution map<br/>[pollution-map.tsx]"]
  node_nodes["Node management"]
  node_history["Reading history<br/>[history-panel.tsx]"]
  node_monitoring["Monitoring actions<br/>[monitoring.ts]"]
end

subgraph group_analysis["Environmental analysis"]
  node_search["Location search"]
  node_sourceid["ML source identification"]
  node_reports["Governance reports"]
end

subgraph group_persistence["Persistence"]
  node_db["Drizzle database<br/>[index.ts]"]
  node_schema["Database schema<br/>[schema.ts]"]
end

node_admin(("Administrator"))
node_postgres[("PostgreSQL")]

node_admin -->|"visits"| node_landing
node_landing -->|"checks session"| node_adminauth
node_landing -->|"opens sign-in"| node_loginform
node_admin -->|"submits credentials"| node_loginform
node_loginform -->|"POSTs credentials"| node_adminlogin
node_adminlogin -->|"validates and creates session"| node_adminauth
node_admin -->|"requests logout"| node_adminlogout
node_adminlogout -->|"clears session"| node_adminauth
node_authclient -->|"calls auth API"| node_authroute
node_authroute -->|"dispatches handlers"| node_authconfig
node_authconfig -->|"uses pool"| node_db
node_dashboardpage -->|"renders map"| node_map
node_dashboardpage -->|"renders node controls"| node_nodes
node_dashboardpage -->|"renders history"| node_history
node_dashboardpage -->|"renders search"| node_search
node_dashboardpage -->|"uses actions"| node_monitoring
node_db -->|"uses schema"| node_schema
node_db -->|"queries"| node_postgres

click node_landing "https://github.com/ivanmercado0998/aerotrace/blob/master/app/page.tsx"
click node_loginform "https://github.com/ivanmercado0998/aerotrace/blob/master/components/auth-form.tsx"
click node_adminlogin "https://github.com/ivanmercado0998/aerotrace/blob/master/app/api/admin/login/route.ts"
click node_adminlogout "https://github.com/ivanmercado0998/aerotrace/blob/master/app/api/admin/logout/route.ts"
click node_adminauth "https://github.com/ivanmercado0998/aerotrace/blob/master/lib/admin-auth.ts"
click node_authroute "https://github.com/ivanmercado0998/aerotrace/blob/master/app/api/auth/%5B...all%5D/route.ts"
click node_authconfig "https://github.com/ivanmercado0998/aerotrace/blob/master/lib/auth.ts"
click node_authclient "https://github.com/ivanmercado0998/aerotrace/blob/master/lib/auth-client.ts"
click node_dashboardpage "https://github.com/ivanmercado0998/aerotrace/blob/master/app/dashboard/page.tsx"
click node_map "https://github.com/ivanmercado0998/aerotrace/blob/master/components/map/pollution-map.tsx"
click node_nodes "https://github.com/ivanmercado0998/aerotrace/blob/master/components/dashboard/node-management-panel.tsx"
click node_history "https://github.com/ivanmercado0998/aerotrace/blob/master/components/dashboard/history-panel.tsx"
click node_monitoring "https://github.com/ivanmercado0998/aerotrace/blob/master/app/actions/monitoring.ts"
click node_search "https://github.com/ivanmercado0998/aerotrace/blob/master/components/dashboard/location-search.tsx"
click node_sourceid "https://github.com/ivanmercado0998/aerotrace/tree/master/app/dashboard"
click node_reports "https://github.com/ivanmercado0998/aerotrace/tree/master/app/dashboard"
click node_db "https://github.com/ivanmercado0998/aerotrace/blob/master/lib/db/index.ts"
click node_schema "https://github.com/ivanmercado0998/aerotrace/blob/master/lib/db/schema.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_landing,node_loginform,node_adminlogin,node_adminlogout,node_adminauth,node_authroute,node_authconfig,node_authclient toneBlue
class node_dashboardpage,node_map,node_nodes,node_history,node_monitoring,node_postgres toneAmber
class node_search,node_sourceid,node_reports toneMint
class node_db,node_schema toneRose
class node_admin toneIndigo
```

## Components

### Access and sessions

- [Landing page](https://github.com/ivanmercado0998/aerotrace/blob/master/app/page.tsx): `app/page.tsx`
- [Admin login form](https://github.com/ivanmercado0998/aerotrace/blob/master/components/auth-form.tsx): `components/auth-form.tsx`
- [Admin login endpoint](https://github.com/ivanmercado0998/aerotrace/blob/master/app/api/admin/login/route.ts): `app/api/admin/login/route.ts`
- [Admin logout endpoint](https://github.com/ivanmercado0998/aerotrace/blob/master/app/api/admin/logout/route.ts): `app/api/admin/logout/route.ts`
- [Admin session helpers](https://github.com/ivanmercado0998/aerotrace/blob/master/lib/admin-auth.ts): `lib/admin-auth.ts`
- [Auth API route](https://github.com/ivanmercado0998/aerotrace/blob/master/app/api/auth/%5B...all%5D/route.ts): `app/api/auth/[...all]/route.ts`
- [Auth configuration](https://github.com/ivanmercado0998/aerotrace/blob/master/lib/auth.ts): `lib/auth.ts`
- [Auth client](https://github.com/ivanmercado0998/aerotrace/blob/master/lib/auth-client.ts): `lib/auth-client.ts`

### Monitoring dashboard

- [Dashboard page](https://github.com/ivanmercado0998/aerotrace/blob/master/app/dashboard/page.tsx): `app/dashboard/page.tsx`
- [Pollution map](https://github.com/ivanmercado0998/aerotrace/blob/master/components/map/pollution-map.tsx): `components/map/pollution-map.tsx`
- [Node management](https://github.com/ivanmercado0998/aerotrace/blob/master/components/dashboard/node-management-panel.tsx): `components/dashboard/node-management-panel.tsx`
- [Reading history](https://github.com/ivanmercado0998/aerotrace/blob/master/components/dashboard/history-panel.tsx): `components/dashboard/history-panel.tsx`
- [Monitoring actions](https://github.com/ivanmercado0998/aerotrace/blob/master/app/actions/monitoring.ts): `app/actions/monitoring.ts`

### Environmental analysis

- [Location search](https://github.com/ivanmercado0998/aerotrace/blob/master/components/dashboard/location-search.tsx): `components/dashboard/location-search.tsx`
- [ML source identification](https://github.com/ivanmercado0998/aerotrace/tree/master/app/dashboard): `app/dashboard`
- [Governance reports](https://github.com/ivanmercado0998/aerotrace/tree/master/app/dashboard): `app/dashboard`

### Persistence

- [Drizzle database](https://github.com/ivanmercado0998/aerotrace/blob/master/lib/db/index.ts): `lib/db/index.ts`
- [Database schema](https://github.com/ivanmercado0998/aerotrace/blob/master/lib/db/schema.ts): `lib/db/schema.ts`

### Other components

- **Administrator**
- **PostgreSQL**

## Connections

- Administrator → Landing page: visits
- Landing page → Admin session helpers: checks session
- Landing page → Admin login form: opens sign-in
- Administrator → Admin login form: submits credentials
- Admin login form → Admin login endpoint: POSTs credentials
- Admin login endpoint → Admin session helpers: validates and creates session
- Administrator → Admin logout endpoint: requests logout
- Admin logout endpoint → Admin session helpers: clears session
- Auth client → Auth API route: calls auth API
- Auth API route → Auth configuration: dispatches handlers
- Auth configuration → Drizzle database: uses pool
- Dashboard page → Pollution map: renders map
- Dashboard page → Node management: renders node controls
- Dashboard page → Reading history: renders history
- Dashboard page → Location search: renders search
- Dashboard page → Monitoring actions: uses actions
- Drizzle database → Database schema: uses schema
- Drizzle database → PostgreSQL: queries
