# chechu1981/recambios architecture

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

- Interactive diagram: https://gitdiagram.com/chechu1981/recambios
- Repository: https://github.com/chechu1981/recambios

## Overview

1. **What this repository is**
   - A small **PHP-based administrative app** for managing **contacts, schedules, internal records, links, passwords, and documents** for “recambios” work.
   - The app is organized as a classic server-rendered CRUD system, with a mix of PHP pages, form handlers, and static assets.

2. **Primary runtime and UI model**
   - The application is built around **PHP on the server** and **HTML/CSS/JavaScript in the browser**.
   - The UI is mostly page-based rather than API-driven: users load PHP pages that render tables, modals, and forms, then submit back to PHP endpoints.

3. **Entry points and navigation**
   - `index.php` is the main top-level entry point.
   - `login.html` is the authentication page.
   - `users.php` and `main/cards.php` appear to be higher-level application views or landing pages after login.
   - The app likely routes authenticated users into the various table modules from these entry pages.

4. **Authentication boundary**
   - `connection/login_controller.php` handles login logic.
   - `js/login.js` supports client-side login interactions.
   - This forms a clear boundary between unauthenticated access and the CRUD/admin area.

5. **Shared persistence layer**
   - `connection/bbdd.php` is the shared database connection layer, likely centralizing MySQL/MariaDB access.
   - The `connection/controller_*.php` files act as domain-specific controllers for each data area:
     - `controller_address.php`
     - `controller_documents.php`
     - `controller_int.php`
     - `controller_int_table.php`
     - `controller_links.php`
     - `controller_pass.php`
     - `controller_proveedores.php`
   - These controllers are the main server-side abstraction between the UI pages and the database.

6. **CRUD modules by domain**
   - Each entity has its own module under `tables/`, with a consistent CRUD structure:
     - `index.php` for listing
     - `nuevo.php` for creating
     - `insert.php` for persisting new records
     - `modificar.php` for editing
     - `update.php` for saving edits
     - `eliminar.php` for deletion
   - This pattern exists for:
     - `tables/address`
     - `tables/documents`
     - `tables/internas`
     - `tables/links`
     - `tables/pass`
     - `tables/schedule`
   - This makes the application modular and easy to diagram as separate bounded data domains sharing the same DB and controller layer.

7. **Document management and file storage**
   - The `docs/` directory contains many PDFs, a DOCX, and other files, indicating that the app manages or distributes **reference documents/catalogs**.
   - `tables/documents/` plus `connection/controller_documents.php` likely link database rows to these physical files.
   - `tables/documents/modal.php` suggests document selection or preview is handled with modal UI interactions.

8. **Schedule and contact data flow**
   - The app’s main functional focus appears to be **schedules and contact/address data**, supported by document and link management.
   - `tables/schedule/` and `tables/address/` are likely core operational datasets.
   - `tables/links/` probably stores quick-reference URLs or related resources.
   - `tables/internas/` and `tables/pass/` suggest internal notes and credentials-like records, though the exact semantics depend on the database schema.

9. **Client-side behavior and presentation**
   - Styling is split across `css/main.css`, `css/cssown.css`, and `css/cssMobile.css`, indicating responsive or device-specific presentation.
   - JavaScript is split by concern:
     - `js/jsown.js` for general UI behavior
     - `js/jsfrm.js` for form handling
     - `js/calc.js` for calculator logic
     - `js/login.js` for authentication interactions
   - The `tables/*/modal.php` files imply the UI uses modal dialogs for create/edit flows.

10. **Auxiliary calculation feature**
   - `calc/calc.php` and `calc/newLine.php`, supported by `js/calc.js`, indicate a separate calculator/subtool inside the app.
   - This is a side subsystem, not the core data-management path, but it likely supports the work process for parts selection or service calculations.

11. **Assets and static content**
   - `img/` holds image assets.
   - `docs/pdf` may be a document subfolder or a special file collection.
   - These are part of the presentation and document-distribution layer, not the application logic.

12. **Overall architectural shape**
   - The system is a **monolithic PHP CRUD application** with:
     - browser UI pages,
     - a shared DB connection layer,
     - per-domain controllers,
     - per-entity table modules,
     - and file-based document storage.
   - For an architecture diagram, the main flows are:
     - user login → authenticated page shell → domain CRUD pages → shared controllers → database,
     - and document-related pages → file references in `docs/` plus database metadata.

Main entry points: [`main/cards.php`](https://github.com/chechu1981/recambios/blob/master/main/cards.php) (Cards), [`connection/bbdd.php`](https://github.com/chechu1981/recambios/blob/master/connection/bbdd.php) (DB conn), [`tables/documents/index.php`](https://github.com/chechu1981/recambios/blob/master/tables/documents/index.php) (Documents), [`tables/address/index.php`](https://github.com/chechu1981/recambios/blob/master/tables/address/index.php) (Address)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_g_entry["Entry & auth"]
  node_n_index["Home<br/>entry page<br/>[index.php]"]
  node_n_login["Login<br/>auth page<br/>[login.html]"]
end

subgraph group_g_core["Admin UI"]
  node_n_users["Users<br/>admin view<br/>[users.php]"]
  node_n_cards["Cards<br/>dashboard view<br/>[cards.php]"]
end

subgraph group_g_tables["CRUD modules"]
  node_n_addr["Address<br/>CRUD module<br/>[index.php]"]
  node_n_docs["Documents<br/>CRUD module<br/>[index.php]"]
  node_n_int["Internas<br/>CRUD module<br/>[index.php]"]
  node_n_links["Links<br/>CRUD module<br/>[index.php]"]
  node_n_pass["Passwords<br/>CRUD module<br/>[index.php]"]
  node_n_sched["Schedule<br/>CRUD module<br/>[index.php]"]
end

subgraph group_g_conn["Data access"]
  node_n_login_ctl["Login ctl<br/>auth controller"]
  node_n_bbdd[("DB conn<br/>database layer<br/>[bbdd.php]")]
  node_n_addr_ctl["Address ctl<br/>domain controller"]
  node_n_docs_ctl["Docs ctl<br/>domain controller"]
  node_n_int_ctl["Int ctl<br/>domain controller<br/>[controller_int.php]"]
  node_n_links_ctl["Links ctl<br/>domain controller"]
  node_n_pass_ctl["Pass ctl<br/>domain controller"]
  node_n_prov_ctl["Prov ctl<br/>domain controller"]
end

subgraph group_g_calc["Calculator"]
  node_n_calc["Calculator<br/>tool page<br/>[calc.php]"]
  node_n_calc_js["Calc JS<br/>ui script<br/>[calc.js]"]
end

subgraph group_g_assets["Static assets"]
  node_n_main_css["Main CSS<br/>style sheet<br/>[main.css]"]
  node_n_docs_store[("Docs store<br/>file store")]
  node_n_img[("Images<br/>asset folder")]
end

node_n_login -->|"submit credentials"| node_n_login_ctl
node_n_login_ctl -->|"verify user"| node_n_bbdd
node_n_index -->|"route in"| node_n_cards
node_n_users -->|"navigate"| node_n_cards
node_n_cards -->|"open"| node_n_addr
node_n_cards -->|"open"| node_n_docs
node_n_cards -->|"open"| node_n_int
node_n_cards -->|"open"| node_n_links
node_n_cards -->|"open"| node_n_pass
node_n_cards -->|"open"| node_n_sched
node_n_addr -->|"crud ops"| node_n_addr_ctl
node_n_docs -->|"crud ops"| node_n_docs_ctl
node_n_int -->|"crud ops"| node_n_int_ctl
node_n_links -->|"crud ops"| node_n_links_ctl
node_n_pass -->|"crud ops"| node_n_pass_ctl
node_n_sched -->|"shared data"| node_n_prov_ctl
node_n_addr_ctl -->|"query"| node_n_bbdd
node_n_docs_ctl -->|"query"| node_n_bbdd
node_n_int_ctl -->|"query"| node_n_bbdd
node_n_links_ctl -->|"query"| node_n_bbdd
node_n_pass_ctl -->|"query"| node_n_bbdd
node_n_prov_ctl -->|"query"| node_n_bbdd
node_n_docs -->|"reference files"| node_n_docs_store
node_n_calc -->|"client logic"| node_n_calc_js
node_n_cards -->|"style"| node_n_main_css
node_n_cards -->|"assets"| node_n_img

click node_n_index "https://github.com/chechu1981/recambios/blob/master/index.php"
click node_n_login "https://github.com/chechu1981/recambios/blob/master/login.html"
click node_n_login_ctl "https://github.com/chechu1981/recambios/blob/master/connection/login_controller.php"
click node_n_users "https://github.com/chechu1981/recambios/blob/master/users.php"
click node_n_cards "https://github.com/chechu1981/recambios/blob/master/main/cards.php"
click node_n_bbdd "https://github.com/chechu1981/recambios/blob/master/connection/bbdd.php"
click node_n_addr_ctl "https://github.com/chechu1981/recambios/blob/master/connection/controller_address.php"
click node_n_docs_ctl "https://github.com/chechu1981/recambios/blob/master/connection/controller_documents.php"
click node_n_int_ctl "https://github.com/chechu1981/recambios/blob/master/connection/controller_int.php"
click node_n_links_ctl "https://github.com/chechu1981/recambios/blob/master/connection/controller_links.php"
click node_n_pass_ctl "https://github.com/chechu1981/recambios/blob/master/connection/controller_pass.php"
click node_n_prov_ctl "https://github.com/chechu1981/recambios/blob/master/connection/controller_proveedores.php"
click node_n_addr "https://github.com/chechu1981/recambios/blob/master/tables/address/index.php"
click node_n_docs "https://github.com/chechu1981/recambios/blob/master/tables/documents/index.php"
click node_n_int "https://github.com/chechu1981/recambios/blob/master/tables/internas/index.php"
click node_n_links "https://github.com/chechu1981/recambios/blob/master/tables/links/index.php"
click node_n_pass "https://github.com/chechu1981/recambios/blob/master/tables/pass/index.php"
click node_n_sched "https://github.com/chechu1981/recambios/blob/master/tables/schedule/index.php"
click node_n_calc "https://github.com/chechu1981/recambios/blob/master/calc/calc.php"
click node_n_calc_js "https://github.com/chechu1981/recambios/blob/master/js/calc.js"
click node_n_main_css "https://github.com/chechu1981/recambios/blob/master/css/main.css"
click node_n_docs_store "https://github.com/chechu1981/recambios/tree/master/docs"
click node_n_img "https://github.com/chechu1981/recambios/tree/master/img"

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_n_index,node_n_login toneBlue
class node_n_users,node_n_cards toneAmber
class node_n_addr,node_n_docs,node_n_int,node_n_links,node_n_pass,node_n_sched toneMint
class node_n_login_ctl,node_n_bbdd,node_n_addr_ctl,node_n_docs_ctl,node_n_int_ctl,node_n_links_ctl,node_n_pass_ctl,node_n_prov_ctl toneRose
class node_n_calc,node_n_calc_js toneIndigo
class node_n_main_css,node_n_docs_store,node_n_img toneTeal
```

## Components

### Entry & auth

Public entry pages and login boundary.

- [Home](https://github.com/chechu1981/recambios/blob/master/index.php): entry page · Main entry point for the app. · `index.php`
- [Login](https://github.com/chechu1981/recambios/blob/master/login.html): auth page · Public authentication form. · `login.html`

### Admin UI

Authenticated page shell and shared page composition.

- [Users](https://github.com/chechu1981/recambios/blob/master/users.php): admin view · Higher-level application screen after login. · `users.php`
- [Cards](https://github.com/chechu1981/recambios/blob/master/main/cards.php): dashboard view · Main internal landing page or card-based navigation. · `main/cards.php`

### CRUD modules

Domain-specific server-rendered table modules.

- [Address](https://github.com/chechu1981/recambios/blob/master/tables/address/index.php): CRUD module · Address management screens. · `tables/address/index.php`
- [Documents](https://github.com/chechu1981/recambios/blob/master/tables/documents/index.php): CRUD module · Document metadata and file linkage screens. · `tables/documents/index.php`
- [Internas](https://github.com/chechu1981/recambios/blob/master/tables/internas/index.php): CRUD module · Internal records management screens. · `tables/internas/index.php`
- [Links](https://github.com/chechu1981/recambios/blob/master/tables/links/index.php): CRUD module · Quick-reference links management screens. · `tables/links/index.php`
- [Passwords](https://github.com/chechu1981/recambios/blob/master/tables/pass/index.php): CRUD module · Credential-like record management screens. · `tables/pass/index.php`
- [Schedule](https://github.com/chechu1981/recambios/blob/master/tables/schedule/index.php): CRUD module · Scheduling and appointment data screens. · `tables/schedule/index.php`

### Data access

Shared database connection and server-side controllers.

- [Login ctl](https://github.com/chechu1981/recambios/blob/master/connection/login_controller.php): auth controller · Handles credential validation and login flow. · `connection/login_controller.php`
- [DB conn](https://github.com/chechu1981/recambios/blob/master/connection/bbdd.php): database layer · Shared database connection and access setup. · `connection/bbdd.php`
- [Address ctl](https://github.com/chechu1981/recambios/blob/master/connection/controller_address.php): domain controller · Server-side controller for address data. · `connection/controller_address.php`
- [Docs ctl](https://github.com/chechu1981/recambios/blob/master/connection/controller_documents.php): domain controller · Server-side controller for document records. · `connection/controller_documents.php`
- [Int ctl](https://github.com/chechu1981/recambios/blob/master/connection/controller_int.php): domain controller · Server-side controller for internal records. · `connection/controller_int.php`
- [Links ctl](https://github.com/chechu1981/recambios/blob/master/connection/controller_links.php): domain controller · Server-side controller for link records. · `connection/controller_links.php`
- [Pass ctl](https://github.com/chechu1981/recambios/blob/master/connection/controller_pass.php): domain controller · Server-side controller for password-like records. · `connection/controller_pass.php`
- [Prov ctl](https://github.com/chechu1981/recambios/blob/master/connection/controller_proveedores.php): domain controller · Server-side controller for supplier/provider records. · `connection/controller_proveedores.php`

### Calculator

Standalone calculation subtool.

- [Calculator](https://github.com/chechu1981/recambios/blob/master/calc/calc.php): tool page · Standalone calculation tool for the workflow. · `calc/calc.php`
- [Calc JS](https://github.com/chechu1981/recambios/blob/master/js/calc.js): ui script · Client-side logic for calculator interactions. · `js/calc.js`

### Static assets

Styles, scripts, and file-based document storage.

- [Main CSS](https://github.com/chechu1981/recambios/blob/master/css/main.css): style sheet · Primary presentation layer styling. · `css/main.css`
- [Docs store](https://github.com/chechu1981/recambios/tree/master/docs): file store · Physical document repository used by the app. · `docs`
- [Images](https://github.com/chechu1981/recambios/tree/master/img): asset folder · Static image assets. · `img`

## Connections

- Login → Login ctl: submit credentials · Login form posts to authentication logic.
- Login ctl → DB conn: verify user · Authentication checks the shared database.
- Home → Cards: route in · Top-level entry routes into the authenticated shell.
- Users → Cards: navigate · User-facing area leads into the main cards view.
- Cards → Address: open · Authenticated navigation reaches address management.
- Cards → Documents: open · Authenticated navigation reaches document management.
- Cards → Internas: open · Authenticated navigation reaches internal records.
- Cards → Links: open · Authenticated navigation reaches links management.
- Cards → Passwords: open · Authenticated navigation reaches password records.
- Cards → Schedule: open · Authenticated navigation reaches scheduling.
- Address → Address ctl: crud ops · Address pages delegate persistence to the controller.
- Documents → Docs ctl: crud ops · Document pages delegate persistence to the controller.
- Internas → Int ctl: crud ops · Internal records pages delegate to their controller.
- Links → Links ctl: crud ops · Link pages delegate persistence to the controller.
- Passwords → Pass ctl: crud ops · Password pages delegate persistence to the controller.
- Schedule → Prov ctl: shared data · Scheduling-related workflows appear to share provider data access.
- Address ctl → DB conn: query · Controllers use the shared database connection.
- Docs ctl → DB conn: query · Controllers use the shared database connection.
- Int ctl → DB conn: query · Controllers use the shared database connection.
- Links ctl → DB conn: query · Controllers use the shared database connection.
- Pass ctl → DB conn: query · Controllers use the shared database connection.
- Prov ctl → DB conn: query · Controllers use the shared database connection.
- Documents → Docs store: reference files · Document records point to physical files in the docs repository.
- Calculator → Calc JS: client logic · Calculator page is supported by dedicated JavaScript.
- Cards → Main CSS: style · Main application shell uses shared styling.
- Cards → Images: assets · Main UI relies on static image assets.
