# luke2905/projeto-portaria-backend architecture

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

- Interactive diagram: https://gitdiagram.com/luke2905/projeto-portaria-backend
- Repository: https://github.com/luke2905/projeto-portaria-backend

## Overview

This is an Express backend for a gatehouse/portaria system. A client sends requests to the server, which mounts public login, transportadora, collaborator, and user routes; those handlers return JSON and use Prisma for persistence. Login verifies stored credentials and issues a JWT, while the server applies authentication middleware to user-management routes. The route excerpts also show collaborator attendance records and transportadora entry, exit, active-list, alert, and report operations. The Prisma schema is present but unsampled, so its model details are not inferred.

Main entry points: [`server.js`](https://github.com/luke2905/projeto-portaria-backend/blob/main/server.js) (Express server), [`routes/public.js`](https://github.com/luke2905/projeto-portaria-backend/blob/main/routes/public.js) (Login), [`prisma/schema.prisma`](https://github.com/luke2905/projeto-portaria-backend/blob/main/prisma/schema.prisma) (Application database), [`routes/UsuariosRoute.js`](https://github.com/luke2905/projeto-portaria-backend/blob/main/routes/UsuariosRoute.js) (User management)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["HTTP entry"]
  node_server["Express server<br/>[server.js]"]
end

subgraph group_identity["Identity and access"]
  node_login["Login<br/>[public.js]"]
  node_auth["JWT middleware<br/>[auth.js]"]
  node_users["User management<br/>[UsuariosRoute.js]"]
end

subgraph group_gatehouse["Gatehouse operations"]
  node_collaborators["Collaborator records"]
  node_transportadoras["Transportadora records"]
end

subgraph group_data["Persistence"]
  node_database[("Application database<br/>[schema.prisma]")]
end

node_client(("HTTP client"))
node_bcrypt["Password hashing"]
node_jwt["JWT library"]

node_client -->|"sends requests"| node_server
node_server -->|"mounts routes"| node_login
node_server -->|"mounts routes"| node_transportadoras
node_server -->|"mounts routes"| node_collaborators
node_server -->|"applies middleware"| node_auth
node_server -->|"mounts protected routes"| node_users
node_login -->|"looks up users"| node_database
node_login -->|"checks password"| node_bcrypt
node_login -->|"signs token"| node_jwt
node_auth -->|"verifies token"| node_jwt
node_users -->|"hashes password"| node_bcrypt
node_users -->|"creates and lists users"| node_database
node_collaborators -->|"reads and writes records"| node_database
node_transportadoras -->|"reads and writes records"| node_database

click node_server "https://github.com/luke2905/projeto-portaria-backend/blob/main/server.js"
click node_login "https://github.com/luke2905/projeto-portaria-backend/blob/main/routes/public.js"
click node_auth "https://github.com/luke2905/projeto-portaria-backend/blob/main/middlewares/auth.js"
click node_users "https://github.com/luke2905/projeto-portaria-backend/blob/main/routes/UsuariosRoute.js"
click node_collaborators "https://github.com/luke2905/projeto-portaria-backend/blob/main/routes/ColaboradoresRoutes.js"
click node_transportadoras "https://github.com/luke2905/projeto-portaria-backend/blob/main/routes/TransportadorasRoutes.js"
click node_database "https://github.com/luke2905/projeto-portaria-backend/blob/main/prisma/schema.prisma"

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_server,node_client toneBlue
class node_login,node_auth,node_users toneAmber
class node_collaborators,node_transportadoras toneMint
class node_database toneRose
class node_bcrypt,node_jwt toneIndigo
```

## Components

### HTTP entry

- [Express server](https://github.com/luke2905/projeto-portaria-backend/blob/main/server.js): `server.js`

### Identity and access

- [Login](https://github.com/luke2905/projeto-portaria-backend/blob/main/routes/public.js): `routes/public.js`
- [JWT middleware](https://github.com/luke2905/projeto-portaria-backend/blob/main/middlewares/auth.js): `middlewares/auth.js`
- [User management](https://github.com/luke2905/projeto-portaria-backend/blob/main/routes/UsuariosRoute.js): `routes/UsuariosRoute.js`

### Gatehouse operations

- [Collaborator records](https://github.com/luke2905/projeto-portaria-backend/blob/main/routes/ColaboradoresRoutes.js): `routes/ColaboradoresRoutes.js`
- [Transportadora records](https://github.com/luke2905/projeto-portaria-backend/blob/main/routes/TransportadorasRoutes.js): `routes/TransportadorasRoutes.js`

### Persistence

- [Application database](https://github.com/luke2905/projeto-portaria-backend/blob/main/prisma/schema.prisma): `prisma/schema.prisma`

### Other components

- **HTTP client**
- **Password hashing**
- **JWT library**

## Connections

- HTTP client → Express server: sends requests (evidence: `server.js`)
- Express server → Login: mounts routes (evidence: `server.js`)
- Express server → Transportadora records: mounts routes (evidence: `server.js`)
- Express server → Collaborator records: mounts routes (evidence: `server.js`)
- Express server → JWT middleware: applies middleware (evidence: `server.js`)
- Express server → User management: mounts protected routes (evidence: `server.js`)
- Login → Application database: looks up users (evidence: `routes/public.js`)
- Login → Password hashing: checks password (evidence: `routes/public.js`)
- Login → JWT library: signs token (evidence: `routes/public.js`)
- JWT middleware → JWT library: verifies token (evidence: `middlewares/auth.js`)
- User management → Password hashing: hashes password (evidence: `routes/UsuariosRoute.js`)
- User management → Application database: creates and lists users (evidence: `routes/UsuariosRoute.js`)
- Collaborator records → Application database: reads and writes records (evidence: `routes/ColaboradoresRoutes.js`)
- Transportadora records → Application database: reads and writes records (evidence: `routes/TransportadorasRoutes.js`)
