# jabesinhoo/software_alquiler architecture

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

- Interactive diagram: https://gitdiagram.com/jabesinhoo/software_alquiler
- Repository: https://github.com/jabesinhoo/software_alquiler

## Overview

1. **Overall shape**
   - This is a **single Django project** named `proyecto_alquiler` with one primary business app, `alquiler`.
   - The codebase is organized as a conventional server-rendered Django application, not a split frontend/backend system.

2. **Core business domain**
   - The main domain appears to be a **rental management system**: equipment, clients, rental contracts/alquileres, payments, users/roles, and related documents.
   - The repository also includes operational concerns typical of this domain: renewals, due-date alerts, overdue payment tracking, and invoice/contract generation.

3. **Request handling layer**
   - The main HTTP entry points are split by domain in `alquiler/views/`:
     - `cliente_views.py`
     - `equipo_views.py`
     - `alquiler_views.py`
     - `contrato_views.py`
     - `pago_views.py`
     - `usuario_views.py`
     - `base_views.py`, `error_views.py`
   - This suggests a clear MVC-style separation where each domain owns its own user-facing workflows.

4. **Data model and persistence**
   - Persistent business state lives in `alquiler/models.py` with the initial schema in `migrations/0001_initial.py`.
   - The generated PDFs, signatures, photos, contracts, invoices, and related files are stored under `alquiler/static/media/` and likely also in the project-level `media/` directory during runtime.
   - `utils/audit_log.py` indicates that audit history is handled as a reusable cross-cutting utility rather than embedded directly in views.

5. **Forms and validation boundary**
   - The `alquiler/forms/` package contains dedicated forms per domain: clients, equipment, rentals, contracts, payments, and users.
   - This is the main validation boundary for user input before it reaches model writes, which is typical for a form-driven Django app.

6. **API boundary**
   - The presence of `alquiler/api_views.py` and `alquiler/serializers.py` indicates a secondary API layer, likely for AJAX or programmatic access.
   - This is separate from the template-rendered pages and probably exposes selected rental/business data without replacing the main server-rendered UI.

7. **Background and scheduled work**
   - The `management/commands/` directory includes operational jobs:
     - `assign_factura_numbers.py`
     - `renovar_alquileres.py`
     - `tareas_cron.py`
     - `tasks.py`
   - These imply scheduled or manually invoked maintenance workflows for invoice numbering, automatic renewals, and periodic housekeeping. They form the async/cron side of the architecture.

8. **Signals, middleware, permissions, and context**
   - `signals.py` suggests model-triggered side effects such as notifications, file generation, or audit actions.
   - `middleware.py`, `permissions.py`, and `context_processors.py` indicate cross-cutting request concerns: access control, request enrichment, and shared template context.
   - `templatetags/` contains custom presentation helpers for permissions, roles, and dictionary lookups.

9. **Document generation and media outputs**
   - The app produces a large amount of business documentation: contracts, invoices, delivery/return acts, payment confirmations, and signed files.
   - Evidence is in templates like `contrato_pdf.html`, `factura_pdf.html`, `acta_entrega.html`, `acta_devolucion.html`, plus stored PDFs in `static/media/...`.
   - JavaScript helpers like `generar_pdf.js` and `firma1.js` reinforce that document signing/export is a major workflow.

10. **Presentation layer**
   - The UI is template-driven with many feature-specific templates under `alquiler/templates/`.
   - Static assets are organized by function in `alquiler/static/css/` and `alquiler/static/js/`, which suggests page-specific interaction logic and styling rather than a single SPA frontend.
   - Templates cover the main user journeys: dashboard, lists, detail pages, create/edit/delete flows, renewals, payments, reports, and search results.

11. **Reporting and operational views**
   - The app includes several reporting screens and supporting scripts: `estadisticas`, `reportes_pagos`, `clientes_morosos`, `pagos_vencidos`, `pagos_proximos`, `alquileres_a_vencer`, and `proxima_disponibilidad`.
   - This indicates the system is not only transactional; it also serves as an operational console for monitoring business state.

12. **Auth and administration**
   - User, role, and permission management is a first-class subsystem, with templates and forms for creating/editing roles and users, plus custom permission tags.
   - `admin.py` exposes the models in the Django admin as an additional management surface.

13. **Deployment/runtime**
   - The project is a standard Django deployment with `manage.py`, `settings.py`, `wsgi.py`, and `asgi.py`.
   - `.github/workflows/deploy.yml` indicates CI/CD automation for deployment.
   - `cert.crt` and `cert.key` show the repo includes TLS artifacts or deployment configuration that depends on HTTPS.

14. **How data flows through the system**
   - Typical flow is: browser request → Django view → form validation → model/database write → optional signal or background command → document/email/file output → template response or downloaded PDF.
   - The main architectural boundary is between **interactive UI requests** and **side-effect-heavy operations** like document generation, scheduled renewals, email notifications, and audit logging.

Main entry points: [`proyecto_alquiler/urls.py`](https://github.com/jabesinhoo/software_alquiler/blob/main/proyecto_alquiler/urls.py) (URL routes), [`alquiler/templates/base.html`](https://github.com/jabesinhoo/software_alquiler/blob/main/alquiler/templates/base.html) (Templates), [`alquiler/views/pago_views.py`](https://github.com/jabesinhoo/software_alquiler/blob/main/alquiler/views/pago_views.py) (Payment views), [`alquiler/forms/__init__.py`](https://github.com/jabesinhoo/software_alquiler/blob/main/alquiler/forms/__init__.py) (Forms)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_project["Django project"]
  node_manage_py["manage.py<br/>django entrypoint<br/>[manage.py]"]
  node_settings["Settings<br/>django config<br/>[settings.py]"]
  node_urls["URL routes<br/>routing<br/>[urls.py]"]
  node_wsgi_asgi["WSGI/ASGI<br/>runtime adapters<br/>[wsgi.py]"]
end

subgraph group_core["Business app"]
  node_apps["App config<br/>django app<br/>[apps.py]"]
  node_models[("Domain models<br/>persistence<br/>[models.py]")]
  node_migrations["Schema init<br/>migration<br/>[0001_initial.py]"]
  node_forms["Forms<br/>validation layer<br/>[__init__.py]"]
  node_views_clients["Client views<br/>http views<br/>[cliente_views.py]"]
  node_views_equipment["Equipment views<br/>http views<br/>[equipo_views.py]"]
  node_views_rentals["Rental views<br/>http views<br/>[alquiler_views.py]"]
  node_views_contracts["Contract views<br/>http views<br/>[contrato_views.py]"]
  node_views_payments["Payment views<br/>http views<br/>[pago_views.py]"]
  node_views_users["User views<br/>http views<br/>[usuario_views.py]"]
  node_views_base["Base views<br/>http views<br/>[base_views.py]"]
  node_views_errors["Error views<br/>http views<br/>[error_views.py]"]
end

subgraph group_presentation["UI and assets"]
  node_templates["Templates<br/>server-rendered UI<br/>[base.html]"]
  node_static["Static assets<br/>css/js/media<br/>[generar_pdf.js]"]
  node_docs_out["Generated docs<br/>business documents"]
end

subgraph group_crosscutting["Cross-cutting"]
  node_api["API layer<br/>api views<br/>[api_views.py]"]
  node_serializers["Serializers<br/>data shaping<br/>[serializers.py]"]
  node_permissions["Permissions<br/>access control<br/>[permissions.py]"]
  node_middleware["Middleware<br/>request hooks<br/>[middleware.py]"]
  node_context["Context proc<br/>template context"]
  node_signals["Signals<br/>event hooks<br/>[signals.py]"]
  node_audit["Audit log<br/>[audit_log.py]"]
end

subgraph group_ops["Operational jobs"]
  node_commands["Maintenance jobs<br/>management commands<br/>[tareas_cron.py]"]
end

node_manage_py -->|"loads"| node_settings
node_settings -->|"wires"| node_urls
node_settings -->|"enables"| node_middleware
node_urls -->|"routes"| node_views_base
node_urls -->|"routes"| node_views_clients
node_urls -->|"routes"| node_views_equipment
node_urls -->|"routes"| node_views_rentals
node_urls -->|"routes"| node_views_contracts
node_urls -->|"routes"| node_views_payments
node_urls -->|"routes"| node_views_users
node_urls -->|"routes"| node_views_errors
node_views_clients -->|"validates"| node_forms
node_views_equipment -->|"validates"| node_forms
node_views_rentals -->|"validates"| node_forms
node_views_contracts -->|"validates"| node_forms
node_views_payments -->|"validates"| node_forms
node_forms -->|"writes"| node_models
node_models -->|"schema"| node_migrations
node_models -->|"emits"| node_signals
node_signals -->|"logs"| node_audit
node_views_rentals -->|"operates with"| node_commands
node_views_payments -->|"operates with"| node_commands
node_commands -->|"generates"| node_docs_out
node_views_contracts -->|"outputs"| node_docs_out
node_views_payments -->|"outputs"| node_docs_out
node_views_base -->|"renders"| node_templates
node_views_clients -->|"renders"| node_templates
node_views_equipment -->|"renders"| node_templates
node_views_rentals -->|"renders"| node_templates
node_views_contracts -->|"renders"| node_templates
node_views_payments -->|"renders"| node_templates
node_views_users -->|"renders"| node_templates
node_templates -->|"uses"| node_static
node_static -->|"stores"| node_docs_out
node_api -->|"uses"| node_serializers
node_api -->|"reads"| node_models
node_views_users -->|"checks"| node_permissions
node_views_rentals -->|"checks"| node_permissions
node_views_payments -->|"checks"| node_permissions
node_middleware -.->|"supports"| node_context
node_context -->|"enriches"| node_templates
node_apps -->|"registers"| node_models

click node_manage_py "https://github.com/jabesinhoo/software_alquiler/blob/main/manage.py"
click node_settings "https://github.com/jabesinhoo/software_alquiler/blob/main/proyecto_alquiler/settings.py"
click node_urls "https://github.com/jabesinhoo/software_alquiler/blob/main/proyecto_alquiler/urls.py"
click node_wsgi_asgi "https://github.com/jabesinhoo/software_alquiler/blob/main/proyecto_alquiler/wsgi.py"
click node_apps "https://github.com/jabesinhoo/software_alquiler/blob/main/alquiler/apps.py"
click node_models "https://github.com/jabesinhoo/software_alquiler/blob/main/alquiler/models.py"
click node_migrations "https://github.com/jabesinhoo/software_alquiler/blob/main/alquiler/migrations/0001_initial.py"
click node_forms "https://github.com/jabesinhoo/software_alquiler/blob/main/alquiler/forms/__init__.py"
click node_views_clients "https://github.com/jabesinhoo/software_alquiler/blob/main/alquiler/views/cliente_views.py"
click node_views_equipment "https://github.com/jabesinhoo/software_alquiler/blob/main/alquiler/views/equipo_views.py"
click node_views_rentals "https://github.com/jabesinhoo/software_alquiler/blob/main/alquiler/views/alquiler_views.py"
click node_views_contracts "https://github.com/jabesinhoo/software_alquiler/blob/main/alquiler/views/contrato_views.py"
click node_views_payments "https://github.com/jabesinhoo/software_alquiler/blob/main/alquiler/views/pago_views.py"
click node_views_users "https://github.com/jabesinhoo/software_alquiler/blob/main/alquiler/views/usuario_views.py"
click node_views_base "https://github.com/jabesinhoo/software_alquiler/blob/main/alquiler/views/base_views.py"
click node_views_errors "https://github.com/jabesinhoo/software_alquiler/blob/main/alquiler/views/error_views.py"
click node_api "https://github.com/jabesinhoo/software_alquiler/blob/main/alquiler/api_views.py"
click node_serializers "https://github.com/jabesinhoo/software_alquiler/blob/main/alquiler/serializers.py"
click node_permissions "https://github.com/jabesinhoo/software_alquiler/blob/main/alquiler/permissions.py"
click node_middleware "https://github.com/jabesinhoo/software_alquiler/blob/main/alquiler/middleware.py"
click node_context "https://github.com/jabesinhoo/software_alquiler/blob/main/alquiler/context_processors.py"
click node_signals "https://github.com/jabesinhoo/software_alquiler/blob/main/alquiler/signals.py"
click node_audit "https://github.com/jabesinhoo/software_alquiler/blob/main/utils/audit_log.py"
click node_commands "https://github.com/jabesinhoo/software_alquiler/blob/main/alquiler/management/commands/tareas_cron.py"
click node_templates "https://github.com/jabesinhoo/software_alquiler/blob/main/alquiler/templates/base.html"
click node_static "https://github.com/jabesinhoo/software_alquiler/blob/main/alquiler/static/js/generar_pdf.js"
click node_docs_out "https://github.com/jabesinhoo/software_alquiler/blob/main/alquiler/static/media/contratos/contrato_1_2025-09-19.pdf"

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_manage_py,node_settings,node_urls,node_wsgi_asgi toneBlue
class node_apps,node_models,node_migrations,node_forms,node_views_clients,node_views_equipment,node_views_rentals,node_views_contracts,node_views_payments,node_views_users,node_views_base,node_views_errors toneAmber
class node_templates,node_static,node_docs_out toneMint
class node_api,node_serializers,node_permissions,node_middleware,node_context,node_signals,node_audit toneRose
class node_commands toneIndigo
```

## Components

### Django project

Project bootstrap, routing, deployment, and runtime settings.

- [manage.py](https://github.com/jabesinhoo/software_alquiler/blob/main/manage.py): django entrypoint · Command-line entrypoint for running the project and management tasks. · `manage.py`
- [Settings](https://github.com/jabesinhoo/software_alquiler/blob/main/proyecto_alquiler/settings.py): django config · Project configuration, installed apps, middleware, database, and static/media setup. · `proyecto_alquiler/settings.py`
- [URL routes](https://github.com/jabesinhoo/software_alquiler/blob/main/proyecto_alquiler/urls.py): routing · Top-level URL dispatcher that connects requests to app views. · `proyecto_alquiler/urls.py`
- [WSGI/ASGI](https://github.com/jabesinhoo/software_alquiler/blob/main/proyecto_alquiler/wsgi.py): runtime adapters · Deployment entrypoints for synchronous and asynchronous servers. · `proyecto_alquiler/wsgi.py`

### Business app

Primary rental-management domain logic in the alquiler app.

- [App config](https://github.com/jabesinhoo/software_alquiler/blob/main/alquiler/apps.py): django app · Django application registration for the rental domain. · `alquiler/apps.py`
- [Domain models](https://github.com/jabesinhoo/software_alquiler/blob/main/alquiler/models.py): persistence · Core rental entities and business state stored in the database. · `alquiler/models.py`
- [Schema init](https://github.com/jabesinhoo/software_alquiler/blob/main/alquiler/migrations/0001_initial.py): migration · Initial database schema for the business app. · `alquiler/migrations/0001_initial.py`
- [Forms](https://github.com/jabesinhoo/software_alquiler/blob/main/alquiler/forms/__init__.py): validation layer · Domain-specific form validation for clients, equipment, rentals, contracts, payments, and users. · `alquiler/forms/__init__.py`
- [Client views](https://github.com/jabesinhoo/software_alquiler/blob/main/alquiler/views/cliente_views.py): http views · Client CRUD and client-centric workflows. · `alquiler/views/cliente_views.py`
- [Equipment views](https://github.com/jabesinhoo/software_alquiler/blob/main/alquiler/views/equipo_views.py): http views · Equipment CRUD, availability, and related workflows. · `alquiler/views/equipo_views.py`
- [Rental views](https://github.com/jabesinhoo/software_alquiler/blob/main/alquiler/views/alquiler_views.py): http views · Rental creation, renewal, reservation, and lifecycle handling. · `alquiler/views/alquiler_views.py`
- [Contract views](https://github.com/jabesinhoo/software_alquiler/blob/main/alquiler/views/contrato_views.py): http views · Contract generation, signing, and document-centric flows. · `alquiler/views/contrato_views.py`
- [Payment views](https://github.com/jabesinhoo/software_alquiler/blob/main/alquiler/views/pago_views.py): http views · Payment capture, partial payments, receipts, and overdue workflows. · `alquiler/views/pago_views.py`
- [User views](https://github.com/jabesinhoo/software_alquiler/blob/main/alquiler/views/usuario_views.py): http views · Authentication-adjacent user, role, and profile management screens. · `alquiler/views/usuario_views.py`
- [Base views](https://github.com/jabesinhoo/software_alquiler/blob/main/alquiler/views/base_views.py): http views · Landing pages, shared pages, and generic navigation endpoints. · `alquiler/views/base_views.py`
- [Error views](https://github.com/jabesinhoo/software_alquiler/blob/main/alquiler/views/error_views.py): http views · Custom error pages and failure handling. · `alquiler/views/error_views.py`

### UI and assets

Templates, static assets, and generated business documents.

- [Templates](https://github.com/jabesinhoo/software_alquiler/blob/main/alquiler/templates/base.html): server-rendered UI · Feature-specific HTML pages for dashboards, CRUD flows, reports, and documents. · `alquiler/templates/base.html`
- [Static assets](https://github.com/jabesinhoo/software_alquiler/blob/main/alquiler/static/js/generar_pdf.js): css/js/media · Styles, scripts, and generated media used by the UI and document workflows. · `alquiler/static/js/generar_pdf.js`
- [Generated docs](https://github.com/jabesinhoo/software_alquiler/blob/main/alquiler/static/media/contratos/contrato_1_2025-09-19.pdf): business documents · Stored PDFs and signed outputs for contracts, invoices, acts, and receipts. · `alquiler/static/media/contratos/contrato_1_2025-09-19.pdf`

### Cross-cutting

Shared request, permission, API, and audit concerns.

- [API layer](https://github.com/jabesinhoo/software_alquiler/blob/main/alquiler/api_views.py): api views · Secondary API surface for programmatic or asynchronous client access. · `alquiler/api_views.py`
- [Serializers](https://github.com/jabesinhoo/software_alquiler/blob/main/alquiler/serializers.py): data shaping · Structured API serialization for rental-domain data. · `alquiler/serializers.py`
- [Permissions](https://github.com/jabesinhoo/software_alquiler/blob/main/alquiler/permissions.py): access control · Custom authorization rules used across views and templates. · `alquiler/permissions.py`
- [Middleware](https://github.com/jabesinhoo/software_alquiler/blob/main/alquiler/middleware.py): request hooks · Request/response interception for cross-cutting behavior. · `alquiler/middleware.py`
- [Context proc](https://github.com/jabesinhoo/software_alquiler/blob/main/alquiler/context_processors.py): template context · Shared template context injection for the presentation layer. · `alquiler/context_processors.py`
- [Signals](https://github.com/jabesinhoo/software_alquiler/blob/main/alquiler/signals.py): event hooks · Model-driven side effects such as notifications, file generation, or audit actions. · `alquiler/signals.py`
- [Audit log](https://github.com/jabesinhoo/software_alquiler/blob/main/utils/audit_log.py): utility · Reusable audit/history logging helper used by the app. · `utils/audit_log.py`

### Operational jobs

Scheduled and manually run maintenance workflows.

- [Maintenance jobs](https://github.com/jabesinhoo/software_alquiler/blob/main/alquiler/management/commands/tareas_cron.py): management commands · Cron-like and manually invoked maintenance workflows. · `alquiler/management/commands/tareas_cron.py`

## Connections

- manage.py → Settings: loads · Bootstraps the Django project using settings.
- Settings → URL routes: wires · Configures the root URL dispatcher.
- Settings → Middleware: enables · Registers request-processing hooks.
- URL routes → Base views: routes · Connects browser entry pages.
- URL routes → Client views: routes · Connects client workflows.
- URL routes → Equipment views: routes · Connects equipment workflows.
- URL routes → Rental views: routes · Connects rental workflows.
- URL routes → Contract views: routes · Connects contract workflows.
- URL routes → Payment views: routes · Connects payment workflows.
- URL routes → User views: routes · Connects user management workflows.
- URL routes → Error views: routes · Connects custom error handlers.
- Client views → Forms: validates · Uses forms to validate client input.
- Equipment views → Forms: validates · Uses forms to validate equipment input.
- Rental views → Forms: validates · Uses forms to validate rental input.
- Contract views → Forms: validates · Uses forms to validate contract input.
- Payment views → Forms: validates · Uses forms to validate payment input.
- Forms → Domain models: writes · Persists validated business data.
- Domain models → Schema init: schema · Initial schema defines the model structure.
- Domain models → Signals: emits · Model changes can trigger side effects.
- Signals → Audit log: logs · Records notable business events.
- Rental views → Maintenance jobs: operates with · Renewals and periodic workflows complement interactive rental handling.
- Payment views → Maintenance jobs: operates with · Invoice numbering and overdue payment tasks complement payment screens.
- Maintenance jobs → Generated docs: generates · Scheduled jobs can create or update business documents.
- Contract views → Generated docs: outputs · Contract flows produce signed PDFs and acts.
- Payment views → Generated docs: outputs · Payment flows produce receipts and invoices.
- Base views → Templates: renders · Server-rendered pages are composed from templates.
- Client views → Templates: renders · Client screens are template-driven.
- Equipment views → Templates: renders · Equipment screens are template-driven.
- Rental views → Templates: renders · Rental screens are template-driven.
- Contract views → Templates: renders · Contract screens and document pages are template-driven.
- Payment views → Templates: renders · Payment screens and reports are template-driven.
- User views → Templates: renders · User and role management screens are template-driven.
- Templates → Static assets: uses · Pages rely on CSS, JS, and media assets.
- Static assets → Generated docs: stores · Generated PDFs and uploaded files live with the media outputs.
- API layer → Serializers: uses · API endpoints serialize business objects.
- API layer → Domain models: reads · API reads from the shared domain model.
- User views → Permissions: checks · User and role flows enforce access rules.
- Rental views → Permissions: checks · Rental workflows are permissioned.
- Payment views → Permissions: checks · Payment workflows are permissioned.
- Middleware → Context proc: supports · Shared request state feeds template context.
- Context proc → Templates: enriches · Provides common variables for rendering.
- App config → Domain models: registers · Declares the app containing the domain models.
