# feedutia/portprime architecture

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

- Interactive diagram: https://gitdiagram.com/feedutia/portprime
- Repository: https://github.com/feedutia/portprime

## Overview

PortPrime CRM manages the user workflow for consignado-credit portability: users sign in, reach the CRM dashboard, and work with client, convenio, and error-catalog data. The Express server serves the frontend and protects data APIs with session authentication; data routes delegate reads and writes to the database module. The README documents role-based access and the dashboard, while sampled source confirms TOTP-capable authentication and Cosmos DB persistence. Some frontend-to-API wiring is not shown, so those connections are omitted; duplicate GitHub/ copies are not mapped separately.

Main entry points: [`backend/server.js`](https://github.com/feedutia/portprime/blob/master/backend/server.js) (Express server), [`backend/database.js`](https://github.com/feedutia/portprime/blob/master/backend/database.js) (Database adapter), [`backend/dataRoutes.js`](https://github.com/feedutia/portprime/blob/master/backend/dataRoutes.js) (Data API), [`frontend/index.html`](https://github.com/feedutia/portprime/blob/master/frontend/index.html) (Login screen)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["CRM interface"]
  node_login["Login screen<br/>[index.html]"]
  node_dashboard["CRM dashboard<br/>[app.html]"]
  node_client_auth["Auth helper<br/>[auth.js]"]
end

subgraph group_access["Access and sessions"]
  node_auth_routes["Auth routes<br/>[auth.js]"]
end

subgraph group_data["CRM data"]
  node_data_routes["Data API<br/>[dataRoutes.js]"]
  node_database["Database adapter<br/>[database.js]"]
end

subgraph group_runtime["Application runtime"]
  node_server["Express server<br/>[server.js]"]
end

node_user(("CRM user"))
node_cosmos[("Azure Cosmos DB")]

node_user -->|"opens"| node_login
node_server -->|"serves"| node_login
node_server -->|"serves"| node_dashboard
node_user -->|"uses"| node_dashboard
node_client_auth -->|"checks session"| node_auth_routes
node_server -.->|"registers routes"| node_auth_routes
node_server -->|"protects and mounts"| node_data_routes
node_data_routes -->|"reads and writes"| node_database
node_server -->|"initializes"| node_database
node_database -.->|"persists data"| node_cosmos

click node_login "https://github.com/feedutia/portprime/blob/master/frontend/index.html"
click node_dashboard "https://github.com/feedutia/portprime/blob/master/frontend/app.html"
click node_client_auth "https://github.com/feedutia/portprime/blob/master/frontend/js/auth.js"
click node_server "https://github.com/feedutia/portprime/blob/master/backend/server.js"
click node_auth_routes "https://github.com/feedutia/portprime/blob/master/backend/auth.js"
click node_data_routes "https://github.com/feedutia/portprime/blob/master/backend/dataRoutes.js"
click node_database "https://github.com/feedutia/portprime/blob/master/backend/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_login,node_dashboard,node_client_auth,node_user toneBlue
class node_auth_routes,node_cosmos toneAmber
class node_data_routes,node_database toneMint
class node_server toneRose
```

## Components

### CRM interface

- [Login screen](https://github.com/feedutia/portprime/blob/master/frontend/index.html): `frontend/index.html`
- [CRM dashboard](https://github.com/feedutia/portprime/blob/master/frontend/app.html): `frontend/app.html`
- [Auth helper](https://github.com/feedutia/portprime/blob/master/frontend/js/auth.js): `frontend/js/auth.js`

### Access and sessions

- [Auth routes](https://github.com/feedutia/portprime/blob/master/backend/auth.js): `backend/auth.js`

### CRM data

- [Data API](https://github.com/feedutia/portprime/blob/master/backend/dataRoutes.js): `backend/dataRoutes.js`
- [Database adapter](https://github.com/feedutia/portprime/blob/master/backend/database.js): `backend/database.js`

### Application runtime

- [Express server](https://github.com/feedutia/portprime/blob/master/backend/server.js): `backend/server.js`

### Other components

- **CRM user**
- **Azure Cosmos DB**

## Connections

- CRM user → Login screen: opens (evidence: `README.md`)
- Express server → Login screen: serves (evidence: `backend/server.js`)
- Express server → CRM dashboard: serves (evidence: `backend/server.js`)
- CRM user → CRM dashboard: uses (evidence: `README.md`)
- Auth helper → Auth routes: checks session (evidence: `frontend/js/auth.js`)
- Express server → Auth routes: registers routes (evidence: `backend/server.js`)
- Express server → Data API: protects and mounts (evidence: `backend/server.js`)
- Data API → Database adapter: reads and writes (evidence: `backend/dataRoutes.js`)
- Express server → Database adapter: initializes (evidence: `backend/server.js`)
- Database adapter → Azure Cosmos DB: persists data
