# aprendebo-byte/acrecer-actualz architecture

> Architecture diagram of the GitHub repository aprendebo-byte/acrecer-actualz, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/aprendebo-byte/acrecer-actualz
- Repository: https://github.com/aprendebo-byte/acrecer-actualz

## Overview

ACRECER es una API Django para registrar novedades del inventario y consultar su historial, con integraciones para Mobilia, correo y WhatsApp. El flujo principal recibe cambios de disponibilidad, solicitudes de precio o intervenciones; valida el inmueble en Mobilia, persiste el historial y, según el caso, notifica por correo. Ramas adicionales ofrecen historial filtrable, métricas, informes programados y contacto por plantillas de WhatsApp. Las relaciones se apoyan en el README y en los extractos disponibles; la implementación de varias vistas y servicios no fue muestreada.

Main entry points: [`Automations/urls.py`](https://github.com/aprendebo-byte/acrecer-actualz/blob/main/Automations/urls.py) (Rutas API), [`Automations/models.py`](https://github.com/aprendebo-byte/acrecer-actualz/blob/main/Automations/models.py) (Modelos historial), [`Automations/Services/Plantillas.py`](https://github.com/aprendebo-byte/acrecer-actualz/blob/main/Automations/Services/Plantillas.py) (Envío plantilla), [`Automations/views.py`](https://github.com/aprendebo-byte/acrecer-actualz/blob/main/Automations/views.py) (Cambios inventario)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API de inventario"]
  node_routes["Rutas API<br/>[urls.py]"]
  node_write["Cambios inventario<br/>[views.py]"]
end

subgraph group_history["Historial y métricas"]
  node_history_views["Consultas historial<br/>[views_historial.py]"]
  node_dashboard["Dashboard métricas<br/>[views_dashboard.py]"]
  node_report_command["Informe programado<br/>[enviar_informe.py]"]
  node_report_utils["Generador XLSX<br/>[Utils.py]"]
end

subgraph group_contact["Contacto WhatsApp"]
  node_template_command["Disparo plantillas"]
  node_durable_contact["Estado contacto durable<br/>[Contacto.py]"]
  node_selector["Reglas de contacto"]
  node_template_sender["Envío plantilla<br/>[Plantillas.py]"]
  node_conversation_views["Conversación viva"]
  node_memory["Memoria conversación<br/>[Memoria.py]"]
end

subgraph group_integrations["Integraciones"]
  node_mobilia["Adaptador Mobilia<br/>[Mobilia.py]"]
  node_business_email["Notificaciones negocio<br/>[Email.py]"]
  node_report_email["Correo informe<br/>[Email.py]"]
  node_logging["Registro de eventos<br/>[Logging.py]"]
  node_log_handler["Handler PostgreSQL"]
end

subgraph group_state["Persistencia"]
  node_db[("PostgreSQL")]
  node_automation_models["Modelos historial<br/>[models.py]"]
  node_property_model["Estado inmueble<br/>[models.py]"]
end

node_client(("Agente / cliente"))
node_smtp{{"Servidor SMTP"}}
node_whatsapp{{"API WhatsApp"}}
node_n8n{{"Webhook n8n"}}
node_redis[("Cache Redis")]
node_report_client(("Cliente de informes"))

node_client -->|"envía solicitud"| node_routes
node_routes -->|"despacha cambios"| node_write
node_write -->|"consulta / actualiza"| node_mobilia
node_write -->|"registra novedades"| node_automation_models
node_write -->|"notifica cambios"| node_business_email
node_business_email -->|"envía correo"| node_smtp
node_client -->|"solicita consulta"| node_routes
node_routes -->|"despacha historial"| node_history_views
node_routes -->|"despacha métricas"| node_dashboard
node_history_views -->|"consulta historial"| node_automation_models
node_dashboard -->|"agrega métricas"| node_automation_models
node_dashboard -->|"consulta contacto"| node_property_model
node_dashboard -->|"agrega logs"| node_db
node_report_command -->|"genera XLSX"| node_report_utils
node_report_utils -->|"lee historial"| node_automation_models
node_report_command -->|"envía informe"| node_report_email
node_report_email -->|"envía correo"| node_smtp
node_template_command -->|"enriquece intentos"| node_durable_contact
node_durable_contact -->|"lee estado"| node_property_model
node_template_command -->|"selecciona inmuebles"| node_selector
node_selector -->|"despacha elegibles"| node_template_sender
node_template_sender -->|"envía plantilla"| node_whatsapp
node_template_sender -->|"guarda conversación"| node_memory
node_memory -.->|"persiste TTL"| node_redis
node_template_sender -.->|"notifica contacto"| node_n8n
node_template_sender -->|"registra envío"| node_automation_models
node_n8n -->|"consulta conversación"| node_routes
node_routes -->|"despacha conversación"| node_conversation_views
node_conversation_views -->|"consulta memoria"| node_memory
node_logging -->|"emite evento"| node_log_handler
node_log_handler -->|"guarda logs"| node_db
node_automation_models -->|"lee / escribe"| node_db
node_property_model -->|"lee / escribe"| node_db

click node_routes "https://github.com/aprendebo-byte/acrecer-actualz/blob/main/Automations/urls.py"
click node_write "https://github.com/aprendebo-byte/acrecer-actualz/blob/main/Automations/views.py"
click node_mobilia "https://github.com/aprendebo-byte/acrecer-actualz/blob/main/Automations/Services/Mobilia.py"
click node_business_email "https://github.com/aprendebo-byte/acrecer-actualz/blob/main/Automations/Services/Email.py"
click node_history_views "https://github.com/aprendebo-byte/acrecer-actualz/blob/main/Automations/views_historial.py"
click node_dashboard "https://github.com/aprendebo-byte/acrecer-actualz/blob/main/Automations/views_dashboard.py"
click node_report_command "https://github.com/aprendebo-byte/acrecer-actualz/blob/main/Automations/management/commands/enviar_informe.py"
click node_report_utils "https://github.com/aprendebo-byte/acrecer-actualz/blob/main/Automations/Services/Utils.py"
click node_report_email "https://github.com/aprendebo-byte/acrecer-actualz/blob/main/Automations/Services/Email.py"
click node_template_command "https://github.com/aprendebo-byte/acrecer-actualz/blob/main/Automations/management/commands/enviar_plantillas.py"
click node_durable_contact "https://github.com/aprendebo-byte/acrecer-actualz/blob/main/Automations/Services/Contacto.py"
click node_selector "https://github.com/aprendebo-byte/acrecer-actualz/blob/main/contacto_inmuebles.py"
click node_template_sender "https://github.com/aprendebo-byte/acrecer-actualz/blob/main/Automations/Services/Plantillas.py"
click node_conversation_views "https://github.com/aprendebo-byte/acrecer-actualz/blob/main/Automations/views_conversacion.py"
click node_memory "https://github.com/aprendebo-byte/acrecer-actualz/blob/main/Automations/Services/Memoria.py"
click node_logging "https://github.com/aprendebo-byte/acrecer-actualz/blob/main/Automations/Services/Logging.py"
click node_log_handler "https://github.com/aprendebo-byte/acrecer-actualz/blob/main/Automations/logging_handlers.py"
click node_automation_models "https://github.com/aprendebo-byte/acrecer-actualz/blob/main/Automations/models.py"
click node_property_model "https://github.com/aprendebo-byte/acrecer-actualz/blob/main/Inmuebles/models.py"

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_routes,node_write,node_client,node_report_client toneBlue
class node_history_views,node_dashboard,node_report_command,node_report_utils,node_redis toneAmber
class node_template_command,node_durable_contact,node_selector,node_template_sender,node_conversation_views,node_memory,node_whatsapp,node_n8n toneMint
class node_mobilia,node_business_email,node_report_email,node_logging,node_log_handler toneRose
class node_db,node_automation_models,node_property_model,node_smtp toneIndigo
```

## Components

### API de inventario

- [Rutas API](https://github.com/aprendebo-byte/acrecer-actualz/blob/main/Automations/urls.py): `Automations/urls.py`
- [Cambios inventario](https://github.com/aprendebo-byte/acrecer-actualz/blob/main/Automations/views.py): `Automations/views.py`

### Historial y métricas

- [Consultas historial](https://github.com/aprendebo-byte/acrecer-actualz/blob/main/Automations/views_historial.py): `Automations/views_historial.py`
- [Dashboard métricas](https://github.com/aprendebo-byte/acrecer-actualz/blob/main/Automations/views_dashboard.py): `Automations/views_dashboard.py`
- [Informe programado](https://github.com/aprendebo-byte/acrecer-actualz/blob/main/Automations/management/commands/enviar_informe.py): `Automations/management/commands/enviar_informe.py`
- [Generador XLSX](https://github.com/aprendebo-byte/acrecer-actualz/blob/main/Automations/Services/Utils.py): `Automations/Services/Utils.py`

### Contacto WhatsApp

- [Disparo plantillas](https://github.com/aprendebo-byte/acrecer-actualz/blob/main/Automations/management/commands/enviar_plantillas.py): `Automations/management/commands/enviar_plantillas.py`
- [Estado contacto durable](https://github.com/aprendebo-byte/acrecer-actualz/blob/main/Automations/Services/Contacto.py): `Automations/Services/Contacto.py`
- [Reglas de contacto](https://github.com/aprendebo-byte/acrecer-actualz/blob/main/contacto_inmuebles.py): `contacto_inmuebles.py`
- [Envío plantilla](https://github.com/aprendebo-byte/acrecer-actualz/blob/main/Automations/Services/Plantillas.py): `Automations/Services/Plantillas.py`
- [Conversación viva](https://github.com/aprendebo-byte/acrecer-actualz/blob/main/Automations/views_conversacion.py): `Automations/views_conversacion.py`
- [Memoria conversación](https://github.com/aprendebo-byte/acrecer-actualz/blob/main/Automations/Services/Memoria.py): `Automations/Services/Memoria.py`

### Integraciones

- [Adaptador Mobilia](https://github.com/aprendebo-byte/acrecer-actualz/blob/main/Automations/Services/Mobilia.py): `Automations/Services/Mobilia.py`
- [Notificaciones negocio](https://github.com/aprendebo-byte/acrecer-actualz/blob/main/Automations/Services/Email.py): `Automations/Services/Email.py`
- [Correo informe](https://github.com/aprendebo-byte/acrecer-actualz/blob/main/Automations/Services/Email.py): `Automations/Services/Email.py`
- [Registro de eventos](https://github.com/aprendebo-byte/acrecer-actualz/blob/main/Automations/Services/Logging.py): `Automations/Services/Logging.py`
- [Handler PostgreSQL](https://github.com/aprendebo-byte/acrecer-actualz/blob/main/Automations/logging_handlers.py): `Automations/logging_handlers.py`

### Persistencia

- **PostgreSQL**
- [Modelos historial](https://github.com/aprendebo-byte/acrecer-actualz/blob/main/Automations/models.py): `Automations/models.py`
- [Estado inmueble](https://github.com/aprendebo-byte/acrecer-actualz/blob/main/Inmuebles/models.py): `Inmuebles/models.py`

### Other components

- **Agente / cliente**
- **Servidor SMTP**
- **API WhatsApp**
- **Webhook n8n**
- **Cache Redis**
- **Cliente de informes**

## Connections

- Agente / cliente → Rutas API: envía solicitud
- Rutas API → Cambios inventario: despacha cambios
- Cambios inventario → Adaptador Mobilia: consulta / actualiza
- Cambios inventario → Modelos historial: registra novedades
- Cambios inventario → Notificaciones negocio: notifica cambios
- Notificaciones negocio → Servidor SMTP: envía correo
- Agente / cliente → Rutas API: solicita consulta
- Rutas API → Consultas historial: despacha historial
- Rutas API → Dashboard métricas: despacha métricas
- Consultas historial → Modelos historial: consulta historial
- Dashboard métricas → Modelos historial: agrega métricas
- Dashboard métricas → Estado inmueble: consulta contacto
- Dashboard métricas → PostgreSQL: agrega logs
- Informe programado → Generador XLSX: genera XLSX
- Generador XLSX → Modelos historial: lee historial
- Informe programado → Correo informe: envía informe
- Correo informe → Servidor SMTP: envía correo
- Disparo plantillas → Estado contacto durable: enriquece intentos
- Estado contacto durable → Estado inmueble: lee estado
- Disparo plantillas → Reglas de contacto: selecciona inmuebles
- Reglas de contacto → Envío plantilla: despacha elegibles
- Envío plantilla → API WhatsApp: envía plantilla
- Envío plantilla → Memoria conversación: guarda conversación
- Memoria conversación → Cache Redis: persiste TTL
- Envío plantilla → Webhook n8n: notifica contacto
- Envío plantilla → Modelos historial: registra envío
- Webhook n8n → Rutas API: consulta conversación
- Rutas API → Conversación viva: despacha conversación
- Conversación viva → Memoria conversación: consulta memoria
- Registro de eventos → Handler PostgreSQL: emite evento
- Handler PostgreSQL → PostgreSQL: guarda logs
- Modelos historial → PostgreSQL: lee / escribe
- Estado inmueble → PostgreSQL: lee / escribe
