How carlosapz/sistema-constructora-hermanos works
Purpose and topology
This is a construction-management system with a React/Vite single-page frontend and a Django REST backend. It manages users, projects/works and documents, construction cost estimates/quotes, APU resources, and exchange-rate forecasting. The empty supplied README leaves the file tree as the primary evidence.
Runtime entry points
• Django starts through constructora/manage.py; HTTP deployment adapters are constructora/constructora/asgi.py and constructora/constructora/wsgi.py.
• Root backend route composition is constructora/constructora/urls.py, which delegates to application URL modules.
• The SPA bootstraps at front-hermanos/src/main.jsx and application routing/layout begins in front-hermanos/src/App.jsx.
• Containerized backend execution is defined by constructora/constructora/Dockerfile and constructora/docker-compose.yml.
Identity, roles, and access boundary
The usuarios Django app owns custom users, roles, authentication services, and role/permission enforcement. Backend endpoint views form the authentication/authorization boundary before domain operations.
• Models: constructora/usuarios/models/usuario.py, constructora/usuarios/models/rol.py
• API layer: constructora/usuarios/views/auth_views.py, constructora/usuarios/urls.py
• Frontend session protection: front-hermanos/src/components/AuthGuard.jsx, front-hermanos/src/services/authService.js
Documents, projects, and work records
documentos is the project-document lifecycle domain: works (Obra), projects, uploaded documents, versions, notifications, and activity history. Views/serializers expose APIs; services centralize document, audit, notification, PDF, and export operations. Signals and middleware indicate cross-cutting lifecycle/audit behavior.
• Domain: constructora/documentos/models/documento.py, constructora/documentos/models/obra.py, constructora/documentos/models/version.py
• Orchestration: constructora/documentos/services/documento_service.py, constructora/documentos/services/exportacion_service.py
• Client surfaces: front-hermanos/src/pages/Documentos.jsx, front-hermanos/src/services/documentosService.js
Estimation and costing core
prediccion owns quotations, future quotations, proformas, products/materials, reusable templates, and APU-based resource costing (materials, labor, equipment, CADECO). Typical control flow is SPA page → frontend service/Axios → Django URL/view → serializer/service → relational models; generated quotation PDFs are returned or persisted as artifacts.
• Quote/product domain: constructora/prediccion/models/cotizacion.py, constructora/prediccion/models/producto.py, constructora/prediccion/models/proforma.py
• APU domain/API: constructora/prediccion/models/apu.py, constructora/prediccion/views/apu_views.py
• UI workflows: front-hermanos/src/pages/NuevaCotizacion.jsx, front-hermanos/src/pages/NuevoAPU.jsx, front-hermanos/src/services/cotizacionService.js
Forecasting pipeline
Exchange-rate prediction is an internal ML-oriented subsystem supporting estimation decisions. Persisted exchange-rate/prediction models are served through prediction and currency endpoints; forecasting implementations include GRU and Prophet approaches. Repository-held historical CSVs and serialized LSTM/scaler artifacts are material runtime inputs.
• APIs/services: constructora/prediccion/views/prediccion_views.py, constructora/prediccion/services/predictor.py, constructora/prediccion/services/tipo_cambio_service.py
• ML implementations/assets: constructora/prediccion/services/forecast_gru.py, constructora/modelos_tipo_cambio/modelo_dolar_lstm.h5, constructora/modelos_tipo_cambio/scaler_dolar.pkl
• UI: front-hermanos/src/pages/PrediccionDolar.jsx, front-hermanos/src/services/prediccionService.js
Async work, reporting, and integration boundaries
Celery is configured at constructora/constructora/celery.py; asynchronous prediction/quotation work is indicated by constructora/prediccion/tasks.py and quote PDF-generation migration fields. Django templates back server-side PDF/report rendering in both domains. Docker Compose is the infrastructure integration point; exact broker, database, storage, and third-party service settings must be verified in settings/compose rather than inferred from the tree.
• Backend settings: constructora/constructora/settings.py, constructora/docker-compose.yml
• Rendering: constructora/prediccion/services/pdf_service.py, constructora/documentos/services/pdf_service.py
• Frontend HTTP boundary: front-hermanos/src/services/axiosConfig.js
Main entry points: urls.py Root URL composition · axiosConfig.js HTTP client · main.jsx SPA bootstrap & routes · apu_views.py Quotation & APU API
Components 21
React SPA
- SPA bootstrap & routes
front-hermanos/src/main.jsx - Session guard
front-hermanos/src/components/AuthGuard.jsx - HTTP client
front-hermanos/src/services/axiosConfig.js - Document workflows
front-hermanos/src/pages/Documentos.jsx - Quotes & APU UI
front-hermanos/src/pages/NuevaCotizacion.jsx - Exchange forecast UI
front-hermanos/src/pages/PrediccionDolar.jsx
Django API
- Django runtime
constructora/manage.py - Root URL composition
constructora/constructora/urls.py - Identity & access API · Authenticates users and enforces role permissions.
constructora/usuarios/views/auth_views.py - Users & roles
constructora/usuarios/models/usuario.py - Async prediction & quote work
constructora/prediccion/tasks.py - Container deployment · Infrastructure dependencies are configured here and in Django settings.
constructora/docker-compose.yml
Documents & Works
- Document API
constructora/documentos/models/documento.py - Document lifecycle services · Coordinates documents, audit, notifications, PDFs, and exports.
constructora/documentos/services/documento_service.py - Works, documents & versions
constructora/documentos/models/obra.py
Estimation & Forecasting
- Quotation & APU API
constructora/prediccion/views/apu_views.py - Quotes, products & APU · Stores quotations, proformas, products, and resource costing.
constructora/prediccion/models/cotizacion.py - Forecast API
constructora/prediccion/views/prediccion_views.py - Forecasting service · Serves exchange-rate predictions for estimation decisions.
constructora/prediccion/services/predictor.py - LSTM model & scaler
constructora/modelos_tipo_cambio/modelo_dolar_lstm.h5 - PDF rendering
constructora/prediccion/services/pdf_service.py
Connections 24
- SPA bootstrap & routes → Session guard: protects routes
- SPA bootstrap & routes → Document workflows: renders
- SPA bootstrap & routes → Quotes & APU UI: renders
- SPA bootstrap & routes → Exchange forecast UI: renders
- Session guard → HTTP client: checks session
- Document workflows → HTTP client: API calls
- Quotes & APU UI → HTTP client: API calls
- Exchange forecast UI → HTTP client: API calls
- HTTP client → Root URL composition: HTTP requests
- Django runtime → Root URL composition: serves
- Root URL composition → Identity & access API: delegates auth routes
- Root URL composition → Document API: delegates domain routes
- Root URL composition → Quotation & APU API: delegates domain routes
- Root URL composition → Forecast API: delegates domain routes
- Identity & access API → Users & roles: authenticates & authorizes
- Document API → Document lifecycle services: orchestrates
- Document lifecycle services → Works, documents & versions: manages lifecycle
- Quotation & APU API → Quotes, products & APU: reads & writes
- Quotation & APU API → Async prediction & quote work: queues work
- Async prediction & quote work → PDF rendering: generates PDFs
- Forecast API → Forecasting service: requests forecast
- Forecasting service → LSTM model & scaler: loads model state
- Forecast API → Async prediction & quote work: may queue prediction
- Container deployment → Django runtime: runs backend