# arkan41554001/probando001 architecture

> Architecture diagram of the GitHub repository arkan41554001/probando001, 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/arkan41554001/probando001
- Repository: https://github.com/arkan41554001/probando001

## Overview

1. **Overall shape**
   - This repository is a two-part system: a **FastAPI backend** under `backend/` and a **static frontend** under `frontend/`.
   - The backend exposes versioned HTTP endpoints; the frontend is a browser-based UI built from HTML, CSS, and modular JavaScript.

2. **Backend entry points and runtime**
   - `backend/main.py` is the application entry point for FastAPI.
   - `backend/database.py` is a separate bootstrap script used to create or initialize database tables.
   - There is also `backend/test_db_connection.py` and `backend/seed_servicios.py`, which suggests operational scripts for validation and initial data seeding.

3. **API surface**
   - Routes are organized in `backend/api/v1/routes/` and split by domain:
     - `auth_routes.py`
     - `producto_routes.py`
     - `servicio_routes.py`
     - `venta_routes.py`
     - `orden_routes.py`
     - `empleado_routes.py`
     - `autoparte_routes.py`
     - `status_routes.py`
   - This indicates a clean resource-based API where each business area has its own controller layer.

4. **Backend layered architecture**
   - The backend follows a classic **route → service → repository → model** flow.
   - Routes handle HTTP concerns.
   - Services contain business rules.
   - Repositories encapsulate persistence queries.
   - SQLAlchemy models under `backend/db/models/` define the data schema.

5. **Domain modules**
   - The core business entities are:
     - **productos**
     - **servicios**
     - **ventas**
     - **órdenes**
     - **empleados**
     - **autopartes**
   - The presence of `orden_empleado.py`, `orden_servicio.py`, and `venta_producto.py` shows that the system manages **many-to-many or association relationships** between business objects, not just flat CRUD tables.

6. **Data validation and contract layer**
   - `backend/schemas/` contains Pydantic schemas for each domain.
   - These schemas are the boundary between the external API and internal business logic, handling request validation and response serialization.
   - There is a dedicated `auth_schema.py`, which implies a separate contract for login/token flows.

7. **Persistence and configuration**
   - `backend/core/config.py` centralizes environment-based configuration.
   - The README shows environment variables for `DATABASE_URL`, `SUPABASE_URL`, `SUPABASE_ANON_KEY`, and `JWT_SECRET`, so the backend is designed to be configured externally rather than hardcoded.
   - `backend/core/cache.py` suggests some shared caching or in-memory optimization layer, though it is not the primary persistence store.

8. **Authentication and security**
   - Authentication is implemented in `backend/core/auth.py` and `backend/services/auth_service.py`, with route-level exposure in `auth_routes.py`.
   - The frontend includes `frontend/scripts/utils/auth-guard.js`, meaning protected pages are gated on the client side as well.
   - There is also a backend security note `backend/SEGURIDAD_XSS.md` and frontend sanitization utilities, indicating explicit attention to XSS and input hygiene.

9. **Frontend structure**
   - The frontend is organized as a modular static app:
     - `views/` contains the page shells: `login.html`, `inventory.html`, `orden.html`, `service.html`, `status.html`, `index.html`
     - `scripts/` contains the application logic
     - `styles/` contains page-specific CSS/SCSS
     - `assets/` contains fonts, icons, and images
   - This is not a server-rendered frontend; it behaves more like a static SPA-style UI layered on top of the API.

10. **Frontend UI composition**
    - The UI is split into reusable components in `frontend/scripts/componets/`:
      - header, sidebar, mobile menu
      - product list and product modal components
      - confirmation and PDF/barcode modals
      - product filtering components
    - This suggests the frontend assembles larger screens from smaller UI modules rather than keeping logic in page files.

11. **Frontend state and data flow**
    - `frontend/scripts/data-manager.js`, `state-manager.js`, and `frontend/scripts/utils/store/*` indicate shared client-side state management.
    - `frontend/scripts/utils/component-loader.js` and `frontend/scripts/utils/error-handlers.js` support dynamic UI composition and consistent error handling.
    - The frontend likely loads data from the backend API, stores temporary UI state locally, and updates views without full page reloads.

12. **Feature-specific flows**
    - **Login flow:** user submits credentials on `login.html` → frontend auth logic calls the backend auth route → token/session is enforced by client-side auth guard.
    - **Inventory/product flow:** product screens use filtering, modal editing, and list rendering tied to the producto API.
    - **Orders and sales flow:** order/venta screens likely combine multiple entities and association tables, reflecting the relational structure in the backend models.

13. **Supporting client features**
    - `frontend/scripts/utils/codbarra.js` and `modal-pdfcod.js` show barcode-related functionality, likely for products or labels.
    - `frontend/service-worker.js` indicates offline/resource caching behavior or progressive-enhancement support.
    - `frontend/scripts/lib/fuse.js` provides fuzzy search/filtering in the UI.

14. **Documentation and deployment**
    - `docs/_build/html/` contains generated Sphinx docs, including architecture and module documentation.
    - `DEPLOYMENT_GUIDE.md` and `.agent/workflows/deploy.md` suggest deployment is a documented concern.
    - `nginx-optimization.conf` indicates the frontend or app may be deployed behind Nginx for static delivery and performance tuning.

15. **What an architecture diagram should show**
    - A browser/client layer with static pages and modular JS.
    - A FastAPI service layer exposing versioned routes.
    - A service/repository/model backend pipeline.
    - A relational database layer accessed through SQLAlchemy.
    - Cross-cutting auth/security utilities and operational scripts for setup, seeding, and validation.

Main entry points: [`frontend/scripts`](https://github.com/arkan41554001/probando001/tree/main/frontend/scripts) (App scripts), [`backend/main.py`](https://github.com/arkan41554001/probando001/blob/main/backend/main.py) (FastAPI app), [`backend/api/v1/routes`](https://github.com/arkan41554001/probando001/tree/main/backend/api/v1/routes) (API routes), [`backend/services`](https://github.com/arkan41554001/probando001/tree/main/backend/services) (Services)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_backend["Backend"]
  node_backend_main["FastAPI app<br/>entrypoint<br/>[main.py]"]
  node_backend_routes["API routes<br/>http controllers"]
  node_backend_services["Services<br/>business logic"]
  node_backend_repos["Repositories<br/>data access"]
  node_backend_models[("DB models<br/>sqlalchemy models")]
  node_backend_schemas["Schemas<br/>pydantic contracts"]
  node_backend_auth["Auth core<br/>security<br/>[auth.py]"]
  node_backend_config["Config<br/>settings<br/>[config.py]"]
  node_backend_cache["Cache<br/>[cache.py]"]
  node_backend_db_bootstrap["DB bootstrap<br/>setup script<br/>[database.py]"]
  node_backend_seed["Seed data<br/>ops script<br/>[seed_servicios.py]"]
  node_backend_db_check["DB check<br/>validation script"]
end

subgraph group_frontend["Frontend"]
  node_frontend_views["Views<br/>static pages"]
  node_frontend_scripts["App scripts<br/>ui logic"]
  node_frontend_components["Components"]
  node_frontend_state["State utils<br/>client state"]
  node_frontend_styles["Styles<br/>css/scss"]
  node_frontend_assets["Assets"]
  node_frontend_sw["Service worker<br/>pwa support<br/>[service-worker.js]"]
end

subgraph group_ops["Ops & docs"]
  node_ops_docs["Docs"]
  node_ops_deploy["Deploy guide<br/>deployment docs"]
  node_ops_nginx["Nginx config<br/>deployment config"]
  node_ops_xss["XSS notes<br/>security notes<br/>[SEGURIDAD_XSS.md]"]
end

node_backend_main -->|"registers"| node_backend_routes
node_backend_routes -->|"calls"| node_backend_services
node_backend_services -->|"uses"| node_backend_repos
node_backend_repos -->|"maps to"| node_backend_models
node_backend_routes -->|"validates"| node_backend_schemas
node_backend_services -->|"serializes"| node_backend_schemas
node_backend_main -->|"loads"| node_backend_config
node_backend_main -->|"secures"| node_backend_auth
node_backend_main -.->|"shares"| node_backend_cache
node_backend_db_bootstrap -->|"creates"| node_backend_models
node_backend_seed -.->|"seeds"| node_backend_services
node_backend_db_check -.->|"reads"| node_backend_config
node_frontend_views -->|"loads"| node_frontend_scripts
node_frontend_scripts -->|"assembles"| node_frontend_components
node_frontend_scripts -->|"shares"| node_frontend_state
node_frontend_components -->|"uses"| node_frontend_state
node_frontend_scripts -->|"calls API"| node_backend_routes
node_frontend_views -->|"styled by"| node_frontend_styles
node_frontend_scripts -.->|"uses"| node_frontend_assets
node_frontend_sw -.->|"caches"| node_frontend_views
node_ops_docs -.->|"documents"| node_backend_routes
node_ops_docs -.->|"documents"| node_frontend_scripts
node_ops_deploy -.->|"deploys"| node_backend_main
node_ops_nginx -.->|"serves"| node_frontend_views
node_ops_xss -.->|"hardens"| node_backend_auth
node_ops_xss -.->|"sanitizes"| node_frontend_state

click node_backend_main "https://github.com/arkan41554001/probando001/blob/main/backend/main.py"
click node_backend_routes "https://github.com/arkan41554001/probando001/tree/main/backend/api/v1/routes"
click node_backend_services "https://github.com/arkan41554001/probando001/tree/main/backend/services"
click node_backend_repos "https://github.com/arkan41554001/probando001/tree/main/backend/repositories"
click node_backend_models "https://github.com/arkan41554001/probando001/tree/main/backend/db/models"
click node_backend_schemas "https://github.com/arkan41554001/probando001/tree/main/backend/schemas"
click node_backend_auth "https://github.com/arkan41554001/probando001/blob/main/backend/core/auth.py"
click node_backend_config "https://github.com/arkan41554001/probando001/blob/main/backend/core/config.py"
click node_backend_cache "https://github.com/arkan41554001/probando001/blob/main/backend/core/cache.py"
click node_backend_db_bootstrap "https://github.com/arkan41554001/probando001/blob/main/backend/database.py"
click node_backend_seed "https://github.com/arkan41554001/probando001/blob/main/backend/seed_servicios.py"
click node_backend_db_check "https://github.com/arkan41554001/probando001/blob/main/backend/test_db_connection.py"
click node_frontend_views "https://github.com/arkan41554001/probando001/tree/main/frontend/views"
click node_frontend_scripts "https://github.com/arkan41554001/probando001/tree/main/frontend/scripts"
click node_frontend_components "https://github.com/arkan41554001/probando001/tree/main/frontend/scripts/componets"
click node_frontend_state "https://github.com/arkan41554001/probando001/tree/main/frontend/scripts/utils"
click node_frontend_styles "https://github.com/arkan41554001/probando001/tree/main/frontend/styles"
click node_frontend_assets "https://github.com/arkan41554001/probando001/tree/main/frontend/assets"
click node_frontend_sw "https://github.com/arkan41554001/probando001/blob/main/frontend/service-worker.js"
click node_ops_docs "https://github.com/arkan41554001/probando001/tree/main/docs/_build/html"
click node_ops_deploy "https://github.com/arkan41554001/probando001/blob/main/DEPLOYMENT_GUIDE.md"
click node_ops_nginx "https://github.com/arkan41554001/probando001/blob/main/nginx-optimization.conf"
click node_ops_xss "https://github.com/arkan41554001/probando001/blob/main/backend/SEGURIDAD_XSS.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_backend_main,node_backend_routes,node_backend_services,node_backend_repos,node_backend_models,node_backend_schemas,node_backend_auth,node_backend_config,node_backend_cache,node_backend_db_bootstrap,node_backend_seed,node_backend_db_check toneBlue
class node_frontend_views,node_frontend_scripts,node_frontend_components,node_frontend_state,node_frontend_styles,node_frontend_assets,node_frontend_sw toneAmber
class node_ops_docs,node_ops_deploy,node_ops_nginx,node_ops_xss toneMint
```

## Components

### Backend

FastAPI API, domain logic, persistence, and operational scripts.

- [FastAPI app](https://github.com/arkan41554001/probando001/blob/main/backend/main.py): entrypoint · Application bootstrap and API wiring. · `backend/main.py`
- [API routes](https://github.com/arkan41554001/probando001/tree/main/backend/api/v1/routes): http controllers · Versioned resource routes for auth and business domains. · `backend/api/v1/routes`
- [Services](https://github.com/arkan41554001/probando001/tree/main/backend/services): business logic · Orchestrates domain rules and application workflows. · `backend/services`
- [Repositories](https://github.com/arkan41554001/probando001/tree/main/backend/repositories): data access · Persistence layer for domain queries and mutations. · `backend/repositories`
- [DB models](https://github.com/arkan41554001/probando001/tree/main/backend/db/models): sqlalchemy models · Relational schema and association tables. · `backend/db/models`
- [Schemas](https://github.com/arkan41554001/probando001/tree/main/backend/schemas): pydantic contracts · Request and response validation layer. · `backend/schemas`
- [Auth core](https://github.com/arkan41554001/probando001/blob/main/backend/core/auth.py): security · JWT/authentication helpers and shared security logic. · `backend/core/auth.py`
- [Config](https://github.com/arkan41554001/probando001/blob/main/backend/core/config.py): settings · Environment-based runtime configuration. · `backend/core/config.py`
- [Cache](https://github.com/arkan41554001/probando001/blob/main/backend/core/cache.py): shared cache · Shared caching or in-memory optimization support. · `backend/core/cache.py`
- [DB bootstrap](https://github.com/arkan41554001/probando001/blob/main/backend/database.py): setup script · Database initialization and table creation. · `backend/database.py`
- [Seed data](https://github.com/arkan41554001/probando001/blob/main/backend/seed_servicios.py): ops script · Initial data seeding for services. · `backend/seed_servicios.py`
- [DB check](https://github.com/arkan41554001/probando001/blob/main/backend/test_db_connection.py): validation script · Connection validation utility. · `backend/test_db_connection.py`

### Frontend

Static browser UI with modular JavaScript and styles.

- [Views](https://github.com/arkan41554001/probando001/tree/main/frontend/views): static pages · HTML page shells for login and main workflows. · `frontend/views`
- [App scripts](https://github.com/arkan41554001/probando001/tree/main/frontend/scripts): ui logic · Client-side application logic and page coordination. · `frontend/scripts`
- [Components](https://github.com/arkan41554001/probando001/tree/main/frontend/scripts/componets): ui components · Reusable UI pieces for headers, menus, lists, and modals. · `frontend/scripts/componets`
- [State utils](https://github.com/arkan41554001/probando001/tree/main/frontend/scripts/utils): client state · Shared state, storage, notifications, and loaders. · `frontend/scripts/utils`
- [Styles](https://github.com/arkan41554001/probando001/tree/main/frontend/styles): css/scss · Page and component styling. · `frontend/styles`
- [Assets](https://github.com/arkan41554001/probando001/tree/main/frontend/assets): static assets · Fonts, icons, and images. · `frontend/assets`
- [Service worker](https://github.com/arkan41554001/probando001/blob/main/frontend/service-worker.js): pwa support · Offline/resource caching support. · `frontend/service-worker.js`

### Ops & docs

Deployment, security, and generated documentation artifacts.

- [Docs](https://github.com/arkan41554001/probando001/tree/main/docs/_build/html): generated docs · Built architecture and API documentation. · `docs/_build/html`
- [Deploy guide](https://github.com/arkan41554001/probando001/blob/main/DEPLOYMENT_GUIDE.md): deployment docs · Deployment notes and workflow guidance. · `DEPLOYMENT_GUIDE.md`
- [Nginx config](https://github.com/arkan41554001/probando001/blob/main/nginx-optimization.conf): deployment config · Reverse proxy and static delivery tuning. · `nginx-optimization.conf`
- [XSS notes](https://github.com/arkan41554001/probando001/blob/main/backend/SEGURIDAD_XSS.md): security notes · Backend security guidance for input hygiene. · `backend/SEGURIDAD_XSS.md`

## Connections

- FastAPI app → API routes: registers · FastAPI mounts the versioned route layer.
- API routes → Services: calls · HTTP handlers delegate domain work to services.
- Services → Repositories: uses · Services rely on repositories for persistence.
- Repositories → DB models: maps to · Repositories operate on SQLAlchemy models.
- API routes → Schemas: validates · Routes exchange data through Pydantic schemas.
- Services → Schemas: serializes · Services return structured domain payloads.
- FastAPI app → Config: loads · Application startup reads environment configuration.
- FastAPI app → Auth core: secures · Core auth utilities support application security.
- FastAPI app → Cache: shares · Runtime can use shared cache helpers.
- DB bootstrap → DB models: creates · Bootstrap script initializes tables from models.
- Seed data → Services: seeds · Seed script populates domain data.
- DB check → Config: reads · Connection test uses configured database settings.
- Views → App scripts: loads · Pages attach page-specific client logic.
- App scripts → Components: assembles · Page scripts compose reusable UI components.
- App scripts → State utils: shares · Scripts coordinate through shared client utilities and state.
- Components → State utils: uses · Components depend on common loaders, notifications, and storage.
- App scripts → API routes: calls API · Client logic consumes the versioned backend endpoints.
- Views → Styles: styled by · Static pages use the compiled CSS bundle.
- App scripts → Assets: uses · UI code references icons, fonts, and images.
- Service worker → Views: caches · Service worker supports offline/resource caching.
- Docs → API routes: documents · Built docs include route/module references.
- Docs → App scripts: documents · Generated docs also cover client structure indirectly.
- Deploy guide → FastAPI app: deploys · Deployment guide targets the backend runtime and API.
- Nginx config → Views: serves · Nginx config supports static frontend delivery.
- XSS notes → Auth core: hardens · Security notes reinforce auth and input handling.
- XSS notes → State utils: sanitizes · Client utilities support input sanitization.
