# nicolas-glith/controle-equipamentos architecture

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

- Interactive diagram: https://gitdiagram.com/nicolas-glith/controle-equipamentos
- Repository: https://github.com/nicolas-glith/controle-equipamentos

## Overview

This is a school equipment checkout and inventory web app. Staff select equipment, quantity, responsible teacher, period and lesson; the browser submits a withdrawal or return, and the API validates stock and records the movement in PostgreSQL. The UI also refreshes availability, active loans and history; administrators can log in and manage records. The excerpts show the main server’s transaction and query behavior, plus a separate, smaller Express app and database-pool configuration. Some routes and database schema details are unsampled, so the graph focuses on documented capabilities and visible calls.

Main entry points: [`server.js`](https://github.com/nicolas-glith/controle-equipamentos/blob/main/server.js) (Main API server), [`database/database.sql`](https://github.com/nicolas-glith/controle-equipamentos/blob/main/database/database.sql) (PostgreSQL data), [`public/index.html`](https://github.com/nicolas-glith/controle-equipamentos/blob/main/public/index.html) (Web page), [`public/js/script.js`](https://github.com/nicolas-glith/controle-equipamentos/blob/main/public/js/script.js) (UI interactions)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["Browser interface"]
  node_page["Web page<br/>[index.html]"]
  node_browser["UI interactions<br/>[script.js]"]
end

subgraph group_api["HTTP application"]
  node_main_api["Main API server<br/>[server.js]"]
  node_inventory["Inventory availability<br/>[server.js]"]
  node_active["Active withdrawals<br/>[server.js]"]
  node_history["Movement history<br/>[server.js]"]
  node_alternate_app["Alternate Express app<br/>[app.js]"]
end

subgraph group_rules["Movement and administration"]
  node_movement["Movement registration<br/>[server.js]"]
  node_validation["Stock validation<br/>[server.js]"]
  node_admin_ops["Admin operations<br/>[server.js]"]
end

subgraph group_storage["Persistence"]
  node_pg_store[("PostgreSQL data<br/>[database.sql]")]
  node_db_pool["Configured DB pool<br/>[database.js]"]
end

node_staff(("School staff"))
node_admin(("Administrator"))

node_staff -->|"uses"| node_page
node_admin -->|"manages records"| node_browser
node_page -.->|"loads script"| node_browser
node_browser -->|"calls API"| node_main_api
node_main_api -->|"routes inventory"| node_inventory
node_main_api -->|"routes active loans"| node_active
node_main_api -->|"routes history"| node_history
node_main_api -->|"routes movements"| node_movement
node_main_api -->|"routes admin actions"| node_admin_ops
node_movement -->|"validates stock"| node_validation
node_movement -->|"writes records"| node_pg_store
node_validation -->|"checks balances"| node_pg_store
node_inventory -->|"queries availability"| node_pg_store
node_active -->|"queries balances"| node_pg_store
node_history -->|"queries history"| node_pg_store
node_admin_ops -->|"edits records"| node_pg_store
node_alternate_app -->|"queries through"| node_db_pool
node_alternate_app -->|"serves fallback page"| node_page
node_db_pool -.->|"connects to"| node_pg_store

click node_page "https://github.com/nicolas-glith/controle-equipamentos/blob/main/public/index.html"
click node_browser "https://github.com/nicolas-glith/controle-equipamentos/blob/main/public/js/script.js"
click node_main_api "https://github.com/nicolas-glith/controle-equipamentos/blob/main/server.js"
click node_inventory "https://github.com/nicolas-glith/controle-equipamentos/blob/main/server.js"
click node_active "https://github.com/nicolas-glith/controle-equipamentos/blob/main/server.js"
click node_history "https://github.com/nicolas-glith/controle-equipamentos/blob/main/server.js"
click node_movement "https://github.com/nicolas-glith/controle-equipamentos/blob/main/server.js"
click node_validation "https://github.com/nicolas-glith/controle-equipamentos/blob/main/server.js"
click node_admin_ops "https://github.com/nicolas-glith/controle-equipamentos/blob/main/server.js"
click node_pg_store "https://github.com/nicolas-glith/controle-equipamentos/blob/main/database/database.sql"
click node_alternate_app "https://github.com/nicolas-glith/controle-equipamentos/blob/main/src/app.js"
click node_db_pool "https://github.com/nicolas-glith/controle-equipamentos/blob/main/src/config/database.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_page,node_browser toneBlue
class node_main_api,node_inventory,node_active,node_history,node_alternate_app toneAmber
class node_movement,node_validation,node_admin_ops toneMint
class node_pg_store,node_db_pool toneRose
class node_staff,node_admin toneIndigo
```

## Components

### Browser interface

- [Web page](https://github.com/nicolas-glith/controle-equipamentos/blob/main/public/index.html): `public/index.html`
- [UI interactions](https://github.com/nicolas-glith/controle-equipamentos/blob/main/public/js/script.js): `public/js/script.js`

### HTTP application

- [Main API server](https://github.com/nicolas-glith/controle-equipamentos/blob/main/server.js): `server.js`
- [Inventory availability](https://github.com/nicolas-glith/controle-equipamentos/blob/main/server.js): `server.js`
- [Active withdrawals](https://github.com/nicolas-glith/controle-equipamentos/blob/main/server.js): `server.js`
- [Movement history](https://github.com/nicolas-glith/controle-equipamentos/blob/main/server.js): `server.js`
- [Alternate Express app](https://github.com/nicolas-glith/controle-equipamentos/blob/main/src/app.js): `src/app.js`

### Movement and administration

- [Movement registration](https://github.com/nicolas-glith/controle-equipamentos/blob/main/server.js): `server.js`
- [Stock validation](https://github.com/nicolas-glith/controle-equipamentos/blob/main/server.js): `server.js`
- [Admin operations](https://github.com/nicolas-glith/controle-equipamentos/blob/main/server.js): `server.js`

### Persistence

- [PostgreSQL data](https://github.com/nicolas-glith/controle-equipamentos/blob/main/database/database.sql): `database/database.sql`
- [Configured DB pool](https://github.com/nicolas-glith/controle-equipamentos/blob/main/src/config/database.js): `src/config/database.js`

### Other components

- **School staff**
- **Administrator**

## Connections

- School staff → Web page: uses (evidence: `README.md`)
- Administrator → UI interactions: manages records (evidence: `README.md`)
- Web page → UI interactions: loads script
- UI interactions → Main API server: calls API (evidence: `public/js/script.js`)
- Main API server → Inventory availability: routes inventory (evidence: `server.js`)
- Main API server → Active withdrawals: routes active loans (evidence: `server.js`)
- Main API server → Movement history: routes history (evidence: `server.js`)
- Main API server → Movement registration: routes movements (evidence: `server.js`)
- Main API server → Admin operations: routes admin actions (evidence: `server.js`)
- Movement registration → Stock validation: validates stock (evidence: `server.js`)
- Movement registration → PostgreSQL data: writes records (evidence: `server.js`)
- Stock validation → PostgreSQL data: checks balances (evidence: `server.js`)
- Inventory availability → PostgreSQL data: queries availability (evidence: `server.js`)
- Active withdrawals → PostgreSQL data: queries balances (evidence: `server.js`)
- Movement history → PostgreSQL data: queries history (evidence: `server.js`)
- Admin operations → PostgreSQL data: edits records (evidence: `server.js`)
- Alternate Express app → Configured DB pool: queries through (evidence: `src/app.js`)
- Alternate Express app → Web page: serves fallback page (evidence: `src/app.js`)
- Configured DB pool → PostgreSQL data: connects to
