# peixotinho-md/ewaste-tracker architecture

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

- Interactive diagram: https://gitdiagram.com/peixotinho-md/ewaste-tracker
- Repository: https://github.com/peixotinho-md/ewaste-tracker

## Overview

e-Trilha MS is a QR-based electronic-waste custody tracker. A user registers a device at a collection point, then authorized operators record its successive custody stages; anyone can consult the public trace and final-destination certificate by code. The server validates roles, stage transitions, and point competence before persisting records in SQLite. The README also describes account administration, dashboards, device-data erasure attestations, and QR scanning. Some page-to-API wiring and the certificate implementation were not sampled, so those links are documented or marked unverified rather than inferred as direct calls.

Main entry points: [`js/store.js`](https://github.com/peixotinho-md/ewaste-tracker/blob/main/js/store.js) (API data access), [`backend/banco.py`](https://github.com/peixotinho-md/ewaste-tracker/blob/main/backend/banco.py) (Custody records), [`rastrear.html`](https://github.com/peixotinho-md/ewaste-tracker/blob/main/rastrear.html) (Public tracking), [`backend/app.py`](https://github.com/peixotinho-md/ewaste-tracker/blob/main/backend/app.py) (HTTP API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["User experience"]
  node_entry["Entry and registration<br/>[index.html]"]
  node_scanner["QR scanner<br/>[qr.js]"]
  node_tracking["Public tracking<br/>[rastrear.html]"]
  node_account_pages["Account screens<br/>[conta.html]"]
  node_operator_pages["Operator screens<br/>[registrar.html]"]
  node_dashboard["Dashboard<br/>[painel.html]"]
  node_admin_screen["Administration<br/>[admin.html]"]
  node_shared_ui["Shared interface<br/>[ui.js]"]
end

subgraph group_custody["Custody workflow"]
  node_client_rules["Client rules<br/>[model.js]"]
  node_server_rules["Server rules<br/>[modelo.py]"]
  node_custody_store["Custody records<br/>[banco.py]"]
  node_points["Collection points<br/>[pontos.json]"]
  node_demo_items["Demo custody data<br/>[itens-demo.json]"]
  node_certificate["Final destination certificate<br/>[app.py]"]
end

subgraph group_accounts["Accounts and access"]
end

subgraph group_platform["Server and data"]
  node_api["HTTP API<br/>[app.py]"]
  node_database[("SQLite database<br/>[schema.sql]")]
  node_data_access["API data access<br/>[store.js]"]
end

node_public(("Public user"))
node_operator(("Collection operator"))
node_admin(("Administrator"))

node_public -->|"chooses access"| node_entry
node_public -->|"consults code"| node_tracking
node_operator -->|"signs in"| node_account_pages
node_operator -.->|"records stages"| node_operator_pages
node_admin -.->|"manages accounts"| node_admin_screen
node_scanner -->|"normalizes code"| node_client_rules
node_shared_ui -->|"uses definitions"| node_client_rules
node_shared_ui -->|"loads session"| node_data_access
node_entry -.->|"uses interface"| node_shared_ui
node_tracking -.->|"requests trace"| node_data_access
node_operator_pages -.->|"submits records"| node_data_access
node_dashboard -.->|"requests indicators"| node_data_access
node_admin_screen -.->|"requests administration"| node_data_access
node_account_pages -.->|"requests session"| node_data_access
node_data_access -.->|"calls API"| node_api
node_api -->|"validates requests"| node_server_rules
node_api -->|"handles records"| node_custody_store
node_custody_store -->|"checks business rules"| node_server_rules
node_custody_store -.->|"reads and writes"| node_database
node_points -.->|"seeds points"| node_custody_store
node_demo_items -.->|"seeds examples"| node_custody_store
node_tracking -.->|"consults certificate"| node_certificate

click node_entry "https://github.com/peixotinho-md/ewaste-tracker/blob/main/index.html"
click node_scanner "https://github.com/peixotinho-md/ewaste-tracker/blob/main/js/qr.js"
click node_tracking "https://github.com/peixotinho-md/ewaste-tracker/blob/main/rastrear.html"
click node_account_pages "https://github.com/peixotinho-md/ewaste-tracker/blob/main/conta.html"
click node_operator_pages "https://github.com/peixotinho-md/ewaste-tracker/blob/main/registrar.html"
click node_dashboard "https://github.com/peixotinho-md/ewaste-tracker/blob/main/painel.html"
click node_admin_screen "https://github.com/peixotinho-md/ewaste-tracker/blob/main/admin.html"
click node_shared_ui "https://github.com/peixotinho-md/ewaste-tracker/blob/main/js/ui.js"
click node_client_rules "https://github.com/peixotinho-md/ewaste-tracker/blob/main/js/model.js"
click node_api "https://github.com/peixotinho-md/ewaste-tracker/blob/main/backend/app.py"
click node_server_rules "https://github.com/peixotinho-md/ewaste-tracker/blob/main/backend/modelo.py"
click node_custody_store "https://github.com/peixotinho-md/ewaste-tracker/blob/main/backend/banco.py"
click node_database "https://github.com/peixotinho-md/ewaste-tracker/blob/main/backend/schema.sql"
click node_data_access "https://github.com/peixotinho-md/ewaste-tracker/blob/main/js/store.js"
click node_points "https://github.com/peixotinho-md/ewaste-tracker/blob/main/dados/pontos.json"
click node_demo_items "https://github.com/peixotinho-md/ewaste-tracker/blob/main/dados/itens-demo.json"
click node_certificate "https://github.com/peixotinho-md/ewaste-tracker/blob/main/backend/app.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_entry,node_scanner,node_tracking,node_account_pages,node_operator_pages,node_dashboard,node_admin_screen,node_shared_ui,node_public toneBlue
class node_client_rules,node_server_rules,node_custody_store,node_points,node_demo_items,node_certificate toneAmber
class node_api,node_database,node_data_access toneRose
class node_operator,node_admin toneIndigo
```

## Components

### User experience

- [Entry and registration](https://github.com/peixotinho-md/ewaste-tracker/blob/main/index.html): `index.html`
- [QR scanner](https://github.com/peixotinho-md/ewaste-tracker/blob/main/js/qr.js): `js/qr.js`
- [Public tracking](https://github.com/peixotinho-md/ewaste-tracker/blob/main/rastrear.html): `rastrear.html`
- [Account screens](https://github.com/peixotinho-md/ewaste-tracker/blob/main/conta.html): `conta.html`
- [Operator screens](https://github.com/peixotinho-md/ewaste-tracker/blob/main/registrar.html): `registrar.html`
- [Dashboard](https://github.com/peixotinho-md/ewaste-tracker/blob/main/painel.html): `painel.html`
- [Administration](https://github.com/peixotinho-md/ewaste-tracker/blob/main/admin.html): `admin.html`
- [Shared interface](https://github.com/peixotinho-md/ewaste-tracker/blob/main/js/ui.js): `js/ui.js`

### Custody workflow

- [Client rules](https://github.com/peixotinho-md/ewaste-tracker/blob/main/js/model.js): `js/model.js`
- [Server rules](https://github.com/peixotinho-md/ewaste-tracker/blob/main/backend/modelo.py): `backend/modelo.py`
- [Custody records](https://github.com/peixotinho-md/ewaste-tracker/blob/main/backend/banco.py): `backend/banco.py`
- [Collection points](https://github.com/peixotinho-md/ewaste-tracker/blob/main/dados/pontos.json): `dados/pontos.json`
- [Demo custody data](https://github.com/peixotinho-md/ewaste-tracker/blob/main/dados/itens-demo.json): `dados/itens-demo.json`
- [Final destination certificate](https://github.com/peixotinho-md/ewaste-tracker/blob/main/backend/app.py): `backend/app.py`

### Server and data

- [HTTP API](https://github.com/peixotinho-md/ewaste-tracker/blob/main/backend/app.py): `backend/app.py`
- [SQLite database](https://github.com/peixotinho-md/ewaste-tracker/blob/main/backend/schema.sql): `backend/schema.sql`
- [API data access](https://github.com/peixotinho-md/ewaste-tracker/blob/main/js/store.js): `js/store.js`

### Other components

- **Public user**
- **Collection operator**
- **Administrator**

## Connections

- Public user → Entry and registration: chooses access (evidence: `README.md`)
- Public user → Public tracking: consults code (evidence: `README.md`)
- Collection operator → Account screens: signs in (evidence: `README.md`)
- Collection operator → Operator screens: records stages
- Administrator → Administration: manages accounts
- QR scanner → Client rules: normalizes code (evidence: `js/qr.js`)
- Shared interface → Client rules: uses definitions (evidence: `js/ui.js`)
- Shared interface → API data access: loads session (evidence: `js/ui.js`)
- Entry and registration → Shared interface: uses interface
- Public tracking → API data access: requests trace
- Operator screens → API data access: submits records
- Dashboard → API data access: requests indicators
- Administration → API data access: requests administration
- Account screens → API data access: requests session
- API data access → HTTP API: calls API
- HTTP API → Server rules: validates requests (evidence: `backend/app.py`)
- HTTP API → Custody records: handles records (evidence: `backend/app.py`)
- Custody records → Server rules: checks business rules (evidence: `backend/banco.py`)
- Custody records → SQLite database: reads and writes
- Collection points → Custody records: seeds points
- Demo custody data → Custody records: seeds examples
- Public tracking → Final destination certificate: consults certificate (evidence: `README.md`)
