# trajetto-pi/trajetto-backend architecture

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

- Interactive diagram: https://gitdiagram.com/trajetto-pi/trajetto-backend
- Repository: https://github.com/trajetto-pi/trajetto-backend

## Overview

Trajetto is a small Express backend with user registration, login, and type lookup represented in the source tree. The README also lists messaging and user editing, but describes chat as pending and the tree contains no implementation for those capabilities. Several sampled imports reference paths that do not match the tree, so those call relationships are omitted; the graph shows only route-to-controller links visible in excerpts and the database connection behavior shown in source.

Main entry points: [`backend/routes/cadastro.js`](https://github.com/trajetto-pi/trajetto-backend/blob/main/backend/routes/cadastro.js) (Registration route), [`backend/database/database.js`](https://github.com/trajetto-pi/trajetto-backend/blob/main/backend/database/database.js) (Postgres connection check), [`backend/routes/login.js`](https://github.com/trajetto-pi/trajetto-backend/blob/main/backend/routes/login.js) (Login route), [`backend/routes/type.js`](https://github.com/trajetto-pi/trajetto-backend/blob/main/backend/routes/type.js) (Type route)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["HTTP API"]
  node_register_route["Registration route<br/>[cadastro.js]"]
  node_login_route["Login route<br/>[login.js]"]
  node_config_route["Config route<br/>[config.js]"]
  node_type_route["Type route<br/>[type.js]"]
  node_register_controller["Registration handler<br/>[cadastro.js]"]
  node_login_controller["Login handler<br/>[login.js]"]
  node_config_controller["Config handler<br/>[config.js]"]
  node_type_controller["Type handler<br/>[type.js]"]
  node_planned_messaging["Messaging endpoints &#40;listed; pending&#41;<br/>[readme.md]"]
end

subgraph group_users["User Operations"]
  node_register_service["Registration logic<br/>[cadastro.js]"]
  node_login_service["Login logic<br/>[login.js]"]
  node_config_service["Config logic<br/>[config.js]"]
  node_type_service["Type lookup<br/>[type.js]"]
  node_user_model["User model<br/>[usuario.js]"]
  node_driver_model["Driver model<br/>[motorista.js]"]
  node_company_model["Company model<br/>[empresa.js]"]
  node_planned_edit["User editing &#40;listed&#41;<br/>[readme.md]"]
end

subgraph group_data["Data Layer"]
  node_db_config["Database settings<br/>[config.js]"]
  node_db_connection["Postgres connection check<br/>[database.js]"]
end

node_client(("API client"))
node_postgres[("PostgreSQL")]

node_client -.->|"requests"| node_register_route
node_register_route -->|"routes to"| node_register_controller
node_client -.->|"requests"| node_login_route
node_client -.->|"requests"| node_type_route
node_db_connection -->|"connects to"| node_postgres

click node_register_route "https://github.com/trajetto-pi/trajetto-backend/blob/main/backend/routes/cadastro.js"
click node_login_route "https://github.com/trajetto-pi/trajetto-backend/blob/main/backend/routes/login.js"
click node_config_route "https://github.com/trajetto-pi/trajetto-backend/blob/main/backend/routes/config.js"
click node_type_route "https://github.com/trajetto-pi/trajetto-backend/blob/main/backend/routes/type.js"
click node_register_controller "https://github.com/trajetto-pi/trajetto-backend/blob/main/backend/controllers/Users/cadastro.js"
click node_login_controller "https://github.com/trajetto-pi/trajetto-backend/blob/main/backend/controllers/Users/login.js"
click node_config_controller "https://github.com/trajetto-pi/trajetto-backend/blob/main/backend/controllers/Users/config.js"
click node_type_controller "https://github.com/trajetto-pi/trajetto-backend/blob/main/backend/controllers/Users/type.js"
click node_register_service "https://github.com/trajetto-pi/trajetto-backend/blob/main/backend/services/cadastro.js"
click node_login_service "https://github.com/trajetto-pi/trajetto-backend/blob/main/backend/services/login.js"
click node_config_service "https://github.com/trajetto-pi/trajetto-backend/blob/main/backend/services/config.js"
click node_type_service "https://github.com/trajetto-pi/trajetto-backend/blob/main/backend/services/type.js"
click node_user_model "https://github.com/trajetto-pi/trajetto-backend/blob/main/backend/model/usuario.js"
click node_driver_model "https://github.com/trajetto-pi/trajetto-backend/blob/main/backend/model/motorista.js"
click node_company_model "https://github.com/trajetto-pi/trajetto-backend/blob/main/backend/model/empresa.js"
click node_db_config "https://github.com/trajetto-pi/trajetto-backend/blob/main/backend/database/config.js"
click node_db_connection "https://github.com/trajetto-pi/trajetto-backend/blob/main/backend/database/database.js"
click node_planned_messaging "https://github.com/trajetto-pi/trajetto-backend/blob/main/readme.md"
click node_planned_edit "https://github.com/trajetto-pi/trajetto-backend/blob/main/readme.md"

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_register_route,node_login_route,node_config_route,node_type_route,node_register_controller,node_login_controller,node_config_controller,node_type_controller,node_planned_messaging,node_client toneBlue
class node_register_service,node_login_service,node_config_service,node_type_service,node_user_model,node_driver_model,node_company_model,node_planned_edit,node_postgres toneAmber
class node_db_config,node_db_connection toneMint
```

## Components

### HTTP API

- [Registration route](https://github.com/trajetto-pi/trajetto-backend/blob/main/backend/routes/cadastro.js): `backend/routes/cadastro.js`
- [Login route](https://github.com/trajetto-pi/trajetto-backend/blob/main/backend/routes/login.js): `backend/routes/login.js`
- [Config route](https://github.com/trajetto-pi/trajetto-backend/blob/main/backend/routes/config.js): `backend/routes/config.js`
- [Type route](https://github.com/trajetto-pi/trajetto-backend/blob/main/backend/routes/type.js): `backend/routes/type.js`
- [Registration handler](https://github.com/trajetto-pi/trajetto-backend/blob/main/backend/controllers/Users/cadastro.js): `backend/controllers/Users/cadastro.js`
- [Login handler](https://github.com/trajetto-pi/trajetto-backend/blob/main/backend/controllers/Users/login.js): `backend/controllers/Users/login.js`
- [Config handler](https://github.com/trajetto-pi/trajetto-backend/blob/main/backend/controllers/Users/config.js): `backend/controllers/Users/config.js`
- [Type handler](https://github.com/trajetto-pi/trajetto-backend/blob/main/backend/controllers/Users/type.js): `backend/controllers/Users/type.js`
- [Messaging endpoints (listed; pending)](https://github.com/trajetto-pi/trajetto-backend/blob/main/readme.md): `readme.md`

### User Operations

- [Registration logic](https://github.com/trajetto-pi/trajetto-backend/blob/main/backend/services/cadastro.js): `backend/services/cadastro.js`
- [Login logic](https://github.com/trajetto-pi/trajetto-backend/blob/main/backend/services/login.js): `backend/services/login.js`
- [Config logic](https://github.com/trajetto-pi/trajetto-backend/blob/main/backend/services/config.js): `backend/services/config.js`
- [Type lookup](https://github.com/trajetto-pi/trajetto-backend/blob/main/backend/services/type.js): `backend/services/type.js`
- [User model](https://github.com/trajetto-pi/trajetto-backend/blob/main/backend/model/usuario.js): `backend/model/usuario.js`
- [Driver model](https://github.com/trajetto-pi/trajetto-backend/blob/main/backend/model/motorista.js): `backend/model/motorista.js`
- [Company model](https://github.com/trajetto-pi/trajetto-backend/blob/main/backend/model/empresa.js): `backend/model/empresa.js`
- [User editing (listed)](https://github.com/trajetto-pi/trajetto-backend/blob/main/readme.md): `readme.md`

### Data Layer

- [Database settings](https://github.com/trajetto-pi/trajetto-backend/blob/main/backend/database/config.js): `backend/database/config.js`
- [Postgres connection check](https://github.com/trajetto-pi/trajetto-backend/blob/main/backend/database/database.js): `backend/database/database.js`

### Other components

- **API client**
- **PostgreSQL**

## Connections

- API client → Registration route: requests
- Registration route → Registration handler: routes to (evidence: `backend/routes/cadastro.js`)
- API client → Login route: requests
- API client → Type route: requests
- Postgres connection check → PostgreSQL: connects to (evidence: `backend/database/database.js`)
