# thejuanjo1/fluxdata architecture

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

- Interactive diagram: https://gitdiagram.com/thejuanjo1/fluxdata
- Repository: https://github.com/thejuanjo1/fluxdata

## Overview

1. **Repo shape**
   - This is a split **frontend / backend** application.
   - The frontend is a React app in `frontend/`.
   - The backend is a Node.js API in `backend/`, using **Express** and **Prisma**.

2. **Backend entrypoint and routing boundary**
   - `backend/src/server.js` is the API composition point.
   - It likely wires middleware plus route modules under `backend/src/routes/`.
   - Each route file maps to a business area: `auth`, `login`, `clientes`, `empresas`, `registros`, `estadisticas`, `dashboardAdmin`, `xmldashboard`, `ultimos`, `filtrar`, `configuracion`, and password recovery flows.

3. **Authentication and authorization**
   - Auth is centralized in `backend/src/middleware/auth.js`.
   - The presence of `login`, `token`, `forgotPassword`, and `resetPassword` routes indicates a token-based auth flow with password reset support.
   - Admin-specific screens and routes suggest role separation between normal users and administrators.

4. **Core domain: empresas, clientes, registros, configuración**
   - The main application data appears to revolve around **companies (`empresas`)**, **clients (`clientes`)**, and **records/documents (`registros`)**.
   - `configuracion` and `configuracion tecnica` on the frontend imply per-company operational settings.
   - `registros` likely stores issued or processed documents and their metadata, including numbering and status.

5. **Document / XML / signing workflow**
   - The repo contains `xmldashboard` and a sample `FacturaSimulada (1).xml`, which points to XML-based document handling.
   - Upload folders such as `backend/uploads/firmas` and `backend/uploads/certificados` show that **digital certificates / signing keys** are stored and used by the backend.
   - Prisma migrations mention `xml_json`, `estado_dian`, `prefijo`, `numero_serie`, and `rangos`, suggesting document numbering, XML persistence, and external validation/status tracking, likely around electronic invoicing.

6. **Persistence layer**
   - Data access is centralized through Prisma (`backend/src/lib/prisma.js`) with schema in `backend/prisma/schema.prisma`.
   - The migration history shows schema evolution for:
     - numbering and prefixes,
     - time/date fields,
     - system records,
     - ranges/series,
     - user status,
     - created/registration timestamps,
     - XML JSON storage,
     - DIAN status.
   - This indicates the DB is the system of record for users, companies, document records, and operational metadata.

7. **File storage boundary**
   - The backend uses the local filesystem under `backend/uploads/`.
   - There are subfolders for **firmas** and **certificados**, plus many hashed upload artifacts.
   - This means binary assets are not stored in the database; the app persists file references in the DB and file contents on disk.

8. **Frontend application structure**
   - The frontend is a React SPA built from `frontend/src/App.js` and `frontend/src/index.js`.
   - UI is split into reusable components in `frontend/src/components/`.
   - Layout composition is separated into `MainLayout`, `AdminLayout`, `TopBar`, and `TopBarAdmin`, which reflects distinct user experiences for regular users vs admins.

9. **User-facing feature areas**
   - Regular-user screens include `Inicio`, `Dashboard`, `Documentos`, `Historial`, `Reportes`, `ConfiguracionTecnica`, `Ayuda`, and `FAQ`.
   - Account access flows are handled by `LoginForm`, `RegisterForm`, `ForgotPassword`, and `ResetPassword`.
   - `LoadingScreen` suggests asynchronous bootstrapping or session validation before rendering the app.

10. **Admin-facing feature areas**
   - Admin components include `DashboardAdmin`, `EmpresasAdmin`, `RegistrosAdmin`, and `FormularioEmpresa`.
   - That implies administrators can manage companies, inspect document records, and review platform-wide metrics.
   - The backend route set mirrors this with admin-oriented endpoints such as `dashboardAdmin`, `estadisticas`, and `ultimos`.

11. **Data flow across the system**
   - The frontend gathers user input and sends API requests to the backend routes.
   - The backend validates auth, reads/writes Prisma-managed database records, and manages file uploads on disk.
   - For document-related operations, the backend also handles XML/signature artifacts and status fields that appear to track external processing.

12. **Operational/tooling signals**
   - The project uses **npm** in both frontend and backend.
   - The frontend uses **Tailwind CSS** (`tailwind.config.js`, `postcss.config.js`, `src/styles/tailwind.css`).
   - Prisma migrations are a major architectural artifact here: schema changes are versioned and likely required for deployment coordination.

13. **What to draw in an architecture diagram**
   - Show a React SPA split into user and admin layouts.
   - Show a Node/Express API layer with route modules and auth middleware.
   - Show Prisma as the database access layer connected to a relational database.
   - Show local file storage for uploads/certificates/signatures as a separate boundary.
   - Show document/XML/status processing as a distinct backend subsystem tied to `registros` and `xmldashboard`.

Main entry points: [`backend/src/server.js`](https://github.com/thejuanjo1/fluxdata/blob/main/backend/src/server.js) (API server), [`backend/src/lib/prisma.js`](https://github.com/thejuanjo1/fluxdata/blob/main/backend/src/lib/prisma.js) (Prisma client), [`frontend/src/layouts/MainLayout.js`](https://github.com/thejuanjo1/fluxdata/blob/main/frontend/src/layouts/MainLayout.js) (Main layout), [`frontend/src/App.js`](https://github.com/thejuanjo1/fluxdata/blob/main/frontend/src/App.js) (App shell)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Frontend"]
  node_frontend_app["App shell<br/>React SPA<br/>[App.js]"]
  node_frontend_main_layout["Main layout<br/>user layout<br/>[MainLayout.js]"]
  node_frontend_admin_layout["Admin layout<br/>[AdminLayout.js]"]
  node_frontend_user_screens["User screens<br/>feature screens<br/>[Dashboard.js]"]
  node_frontend_auth_screens["Auth screens<br/>access flows<br/>[LoginForm.js]"]
  node_frontend_admin_screens["Admin screens<br/>admin features<br/>[DashboardAdmin.js]"]
  node_frontend_ui_chrome["Top bars<br/>navigation chrome<br/>[TopBar.js]"]
  node_frontend_bootstrap["Client boot<br/>entrypoint<br/>[index.js]"]
end

subgraph group_backend["Backend"]
  node_backend_server["API server<br/>Express composition<br/>[server.js]"]
  node_backend_auth["Auth middleware<br/>token guard<br/>[auth.js]"]
  node_backend_auth_routes["Auth routes<br/>session api<br/>[auth.js]"]
  node_backend_domain_routes["Domain routes<br/>business api<br/>[registros.js]"]
  node_backend_admin_routes["Admin routes<br/>admin api<br/>[dashboardAdmin.js]"]
  node_backend_xml_routes["XML flow<br/>document workflow<br/>[xmldashboard.js]"]
  node_backend_prisma["Prisma client<br/>data access<br/>[prisma.js]"]
  node_backend_schema["Schema<br/>[schema.prisma]"]
  node_backend_migrations["Migrations<br/>schema history"]
end

subgraph group_storage["Storage"]
  node_storage_db[("Relational DB<br/>system of record<br/>[schema.prisma]")]
  node_storage_uploads[("Uploads<br/>filesystem")]
end

node_frontend_bootstrap -->|"mounts"| node_frontend_app
node_frontend_app -->|"regular UI"| node_frontend_main_layout
node_frontend_app -->|"admin UI"| node_frontend_admin_layout
node_frontend_main_layout -->|"uses"| node_frontend_ui_chrome
node_frontend_admin_layout -->|"uses"| node_frontend_ui_chrome
node_frontend_main_layout -->|"hosts"| node_frontend_user_screens
node_frontend_main_layout -->|"hosts"| node_frontend_auth_screens
node_frontend_admin_layout -->|"hosts"| node_frontend_admin_screens
node_frontend_user_screens -->|"API calls"| node_backend_server
node_frontend_auth_screens -->|"auth calls"| node_backend_auth_routes
node_frontend_admin_screens -->|"admin calls"| node_backend_admin_routes
node_backend_server -->|"protects"| node_backend_auth
node_backend_server -->|"maps"| node_backend_auth_routes
node_backend_server -->|"maps"| node_backend_domain_routes
node_backend_server -->|"maps"| node_backend_admin_routes
node_backend_server -->|"maps"| node_backend_xml_routes
node_backend_domain_routes -->|"reads/writes"| node_backend_prisma
node_backend_admin_routes -->|"reads"| node_backend_prisma
node_backend_xml_routes -->|"reads/writes"| node_backend_prisma
node_backend_prisma -->|"implements"| node_backend_schema
node_backend_schema -->|"evolves via"| node_backend_migrations
node_backend_prisma -->|"persists to"| node_storage_db
node_backend_xml_routes -->|"stores artifacts"| node_storage_uploads
node_backend_domain_routes -->|"stores files"| node_storage_uploads

click node_frontend_app "https://github.com/thejuanjo1/fluxdata/blob/main/frontend/src/App.js"
click node_frontend_main_layout "https://github.com/thejuanjo1/fluxdata/blob/main/frontend/src/layouts/MainLayout.js"
click node_frontend_admin_layout "https://github.com/thejuanjo1/fluxdata/blob/main/frontend/src/layouts/AdminLayout.js"
click node_frontend_user_screens "https://github.com/thejuanjo1/fluxdata/blob/main/frontend/src/components/Dashboard.js"
click node_frontend_auth_screens "https://github.com/thejuanjo1/fluxdata/blob/main/frontend/src/components/LoginForm.js"
click node_frontend_admin_screens "https://github.com/thejuanjo1/fluxdata/blob/main/frontend/src/components/DashboardAdmin.js"
click node_frontend_ui_chrome "https://github.com/thejuanjo1/fluxdata/blob/main/frontend/src/layouts/TopBar.js"
click node_frontend_bootstrap "https://github.com/thejuanjo1/fluxdata/blob/main/frontend/src/index.js"
click node_backend_server "https://github.com/thejuanjo1/fluxdata/blob/main/backend/src/server.js"
click node_backend_auth "https://github.com/thejuanjo1/fluxdata/blob/main/backend/src/middleware/auth.js"
click node_backend_auth_routes "https://github.com/thejuanjo1/fluxdata/blob/main/backend/src/routes/auth.js"
click node_backend_domain_routes "https://github.com/thejuanjo1/fluxdata/blob/main/backend/src/routes/registros.js"
click node_backend_admin_routes "https://github.com/thejuanjo1/fluxdata/blob/main/backend/src/routes/dashboardAdmin.js"
click node_backend_xml_routes "https://github.com/thejuanjo1/fluxdata/blob/main/backend/src/routes/xmldashboard.js"
click node_backend_prisma "https://github.com/thejuanjo1/fluxdata/blob/main/backend/src/lib/prisma.js"
click node_backend_schema "https://github.com/thejuanjo1/fluxdata/blob/main/backend/prisma/schema.prisma"
click node_backend_migrations "https://github.com/thejuanjo1/fluxdata/tree/main/backend/prisma/migrations"
click node_storage_db "https://github.com/thejuanjo1/fluxdata/blob/main/backend/prisma/schema.prisma"
click node_storage_uploads "https://github.com/thejuanjo1/fluxdata/tree/main/backend/uploads"

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_frontend_app,node_frontend_main_layout,node_frontend_admin_layout,node_frontend_user_screens,node_frontend_auth_screens,node_frontend_admin_screens,node_frontend_ui_chrome,node_frontend_bootstrap toneBlue
class node_backend_server,node_backend_auth,node_backend_auth_routes,node_backend_domain_routes,node_backend_admin_routes,node_backend_xml_routes,node_backend_prisma,node_backend_schema,node_backend_migrations toneAmber
class node_storage_db,node_storage_uploads toneMint
```

## Components

### Frontend

React single-page app and UI composition

- [App shell](https://github.com/thejuanjo1/fluxdata/blob/main/frontend/src/App.js): React SPA · Bootstraps the client app and switches between major layouts and screens. · `frontend/src/App.js`
- [Main layout](https://github.com/thejuanjo1/fluxdata/blob/main/frontend/src/layouts/MainLayout.js): user layout · Primary layout for regular users. · `frontend/src/layouts/MainLayout.js`
- [Admin layout](https://github.com/thejuanjo1/fluxdata/blob/main/frontend/src/layouts/AdminLayout.js): admin layout · Dedicated layout for administrator workflows. · `frontend/src/layouts/AdminLayout.js`
- [User screens](https://github.com/thejuanjo1/fluxdata/blob/main/frontend/src/components/Dashboard.js): feature screens · Regular-user areas such as dashboard, documents, history, reports, help, and technical configuration. · `frontend/src/components/Dashboard.js`
- [Auth screens](https://github.com/thejuanjo1/fluxdata/blob/main/frontend/src/components/LoginForm.js): access flows · Login, registration, password recovery, and session bootstrap screens. · `frontend/src/components/LoginForm.js`
- [Admin screens](https://github.com/thejuanjo1/fluxdata/blob/main/frontend/src/components/DashboardAdmin.js): admin features · Company, record, and admin dashboard management screens. · `frontend/src/components/DashboardAdmin.js`
- [Top bars](https://github.com/thejuanjo1/fluxdata/blob/main/frontend/src/layouts/TopBar.js): navigation chrome · Shared top-bar components that frame the user and admin experiences. · `frontend/src/layouts/TopBar.js`
- [Client boot](https://github.com/thejuanjo1/fluxdata/blob/main/frontend/src/index.js): entrypoint · Browser entrypoint that mounts the React app. · `frontend/src/index.js`

### Backend

Express API, auth, domain routes, and persistence

- [API server](https://github.com/thejuanjo1/fluxdata/blob/main/backend/src/server.js): Express composition · Backend entrypoint that composes middleware and routes. · `backend/src/server.js`
- [Auth middleware](https://github.com/thejuanjo1/fluxdata/blob/main/backend/src/middleware/auth.js): token guard · Central request authentication and authorization boundary. · `backend/src/middleware/auth.js`
- [Auth routes](https://github.com/thejuanjo1/fluxdata/blob/main/backend/src/routes/auth.js): session api · Login, token validation, and password recovery endpoints. · `backend/src/routes/auth.js`
- [Domain routes](https://github.com/thejuanjo1/fluxdata/blob/main/backend/src/routes/registros.js): business api · Core business endpoints for companies, clients, records, configuration, filtering, and recent items. · `backend/src/routes/registros.js`
- [Admin routes](https://github.com/thejuanjo1/fluxdata/blob/main/backend/src/routes/dashboardAdmin.js): admin api · Administrator endpoints for dashboards, analytics, and platform-wide views. · `backend/src/routes/dashboardAdmin.js`
- [XML flow](https://github.com/thejuanjo1/fluxdata/blob/main/backend/src/routes/xmldashboard.js): document workflow · XML dashboard and record-processing endpoints tied to document lifecycle and status tracking. · `backend/src/routes/xmldashboard.js`
- [Prisma client](https://github.com/thejuanjo1/fluxdata/blob/main/backend/src/lib/prisma.js): data access · Shared Prisma entrypoint used by backend route handlers. · `backend/src/lib/prisma.js`
- [Schema](https://github.com/thejuanjo1/fluxdata/blob/main/backend/prisma/schema.prisma): prisma schema · Database schema definition and migration source of truth. · `backend/prisma/schema.prisma`
- [Migrations](https://github.com/thejuanjo1/fluxdata/tree/main/backend/prisma/migrations): schema history · Versioned schema evolution for numbering, timestamps, XML storage, and DIAN status fields. · `backend/prisma/migrations`

### Storage

Database and local upload artifacts

- [Relational DB](https://github.com/thejuanjo1/fluxdata/blob/main/backend/prisma/schema.prisma): system of record · Persistent store for users, companies, records, numbering, status, and operational metadata. · `backend/prisma/schema.prisma`
- [Uploads](https://github.com/thejuanjo1/fluxdata/tree/main/backend/uploads): filesystem · Local file storage for signatures, certificates, and upload artifacts. · `backend/uploads`

## Connections

- Client boot → App shell: mounts · Browser startup loads the React application.
- App shell → Main layout: regular UI · Routes regular users into the main experience.
- App shell → Admin layout: admin UI · Routes administrators into the admin experience.
- Main layout → Top bars: uses · User layout is framed by shared navigation chrome.
- Admin layout → Top bars: uses · Admin layout is framed by admin navigation chrome.
- Main layout → User screens: hosts · Main layout renders the user-facing feature areas.
- Main layout → Auth screens: hosts · Main layout includes access and recovery screens.
- Admin layout → Admin screens: hosts · Admin layout renders company and record management screens.
- User screens → API server: API calls · User features fetch and mutate backend data.
- Auth screens → Auth routes: auth calls · Login and recovery screens talk to the authentication endpoints.
- Admin screens → Admin routes: admin calls · Admin screens request platform-wide data from admin endpoints.
- API server → Auth middleware: protects · Request handling passes through auth validation.
- API server → Auth routes: maps · Server composes authentication-related routes.
- API server → Domain routes: maps · Server composes the main business routes.
- API server → Admin routes: maps · Server composes administrator routes.
- API server → XML flow: maps · Server composes XML and document workflow routes.
- Domain routes → Prisma client: reads/writes · Domain handlers persist and query business entities through Prisma.
- Admin routes → Prisma client: reads · Admin views aggregate data through Prisma.
- XML flow → Prisma client: reads/writes · Document workflow stores XML, status, and numbering data through Prisma.
- Prisma client → Schema: implements · Prisma client is generated from the schema.
- Schema → Migrations: evolves via · Schema changes are captured in migration history.
- Prisma client → Relational DB: persists to · Application data is stored in the relational database.
- XML flow → Uploads: stores artifacts · XML-related flows use local files for certificates and signatures.
- Domain routes → Uploads: stores files · Business operations may reference uploaded assets on disk.
