ERP para empresas de construccion
|
Some checks failed
CI Pipeline / Lint & Type Check (push) Has been cancelled
CI Pipeline / Validate SSOT Constants (push) Has been cancelled
CI Pipeline / Backend Tests (push) Has been cancelled
CI Pipeline / Frontend Tests (push) Has been cancelled
CI Pipeline / Build (push) Has been cancelled
CI Pipeline / Docker Build (push) Has been cancelled
- Agregar seccion Directivas de Documentacion (v3.7) - Agregar seccion Directivas de Mantenimiento (v3.8) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> |
||
|---|---|---|
| .github/workflows | ||
| devops/scripts | ||
| docs | ||
| orchestration | ||
| .env | ||
| .env.example | ||
| .gitignore | ||
| .gitmodules | ||
| CONTRIBUTING.md | ||
| docker-compose.prod.yml | ||
| docker-compose.yml | ||
| INVENTARIO.yml | ||
| PROJECT-STATUS.md | ||
| README.md | ||
ERP Construccion - Sistema de Administracion de Obra e INFONAVIT
Sistema ERP especializado para empresas de construccion de vivienda con integracion INFONAVIT. Arquitectura multi-tenant SaaS con Row Level Security (RLS).
Estado del Proyecto
| Campo | Valor |
|---|---|
| Estado | 🚧 En desarrollo (55%) |
| Version | 0.2.0 |
| Modulos | 18 (14 MAI + 3 MAE + 1 MAA) |
| DDL Schemas | 7 (110 tablas) |
| Entidades Backend | 30 |
| Services Backend | 8 |
Quick Start
Prerequisitos
- Node.js >= 18.0.0
- Docker & Docker Compose
- PostgreSQL 15+ con PostGIS (incluido en docker-compose)
Instalacion
# Clonar repositorio
cd apps/verticales/construccion
# Copiar variables de entorno
cp .env.example .env
# Levantar servicios con Docker
docker-compose up -d
# O desarrollo local
cd backend && npm install && npm run dev
URLs de Desarrollo
| Servicio | URL |
|---|---|
| Backend API | http://localhost:3000 |
| Frontend | http://localhost:5173 |
| Adminer (DB) | http://localhost:8080 |
| Mailhog | http://localhost:8025 |
Arquitectura
┌─────────────────────────────────────────────────────────┐
│ Frontend (React) │
│ ┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────────┐ │
│ │ Budgets │ │Progress │ │Estimates│ │ HSE │ │
│ └────┬────┘ └────┬────┘ └────┬────┘ └────┬────┘ │
└───────┼────────────┼────────────┼────────────┼──────────┘
│ │ │ │
┌───────▼────────────▼────────────▼────────────▼──────────┐
│ Backend (Express + TypeORM) │
│ ┌──────────────────────────────────────────────────┐ │
│ │ Auth Middleware (JWT + RLS) │ │
│ └──────────────────────────────────────────────────┘ │
│ ┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────────┐ │
│ │ Budgets │ │Progress │ │Estimates│ │ Auth │ │
│ │ Service │ │ Service │ │ Service │ │ Service │ │
│ └────┬────┘ └────┬────┘ └────┬────┘ └────┬────┘ │
└───────┼────────────┼────────────┼────────────┼──────────┘
│ │ │ │
┌───────▼────────────▼────────────▼────────────▼──────────┐
│ PostgreSQL 15 + PostGIS │
│ ┌──────────────────────────────────────────────────┐ │
│ │ Row Level Security (tenant_id) │ │
│ └──────────────────────────────────────────────────┘ │
│ ┌────────┐ ┌────────┐ ┌────────┐ ┌────────┐ ┌──────┐ │
│ │ auth │ │constru.│ │ hr │ │ hse │ │estim.│ │
│ └────────┘ └────────┘ └────────┘ └────────┘ └──────┘ │
└─────────────────────────────────────────────────────────┘
Stack Tecnologico
| Capa | Tecnologia |
|---|---|
| Backend | Node.js 20, Express 4, TypeORM 0.3 |
| Frontend | React 18, Vite 5, TypeScript 5 |
| Database | PostgreSQL 15 + PostGIS |
| Cache | Redis 7 |
| Auth | JWT + Refresh Tokens |
| Multi-tenant | RLS (Row Level Security) |
Estructura del Proyecto
construccion/
├── backend/
│ └── src/
│ ├── modules/
│ │ ├── auth/ # Autenticacion JWT
│ │ ├── budgets/ # MAI-003 Presupuestos
│ │ ├── progress/ # MAI-005 Control de Obra
│ │ ├── estimates/ # MAI-008 Estimaciones
│ │ ├── construction/ # MAI-002 Proyectos
│ │ ├── hr/ # MAI-007 RRHH
│ │ ├── hse/ # MAA-017 HSE
│ │ └── core/ # Entidades base
│ └── shared/
│ ├── constants/ # SSOT (schemas, rutas, enums)
│ └── services/ # BaseService multi-tenant
├── frontend/
│ ├── web/ # App web React
│ └── mobile/ # App movil (futuro)
├── database/
│ └── schemas/ # DDL por schema
│ ├── 01-construction-schema-ddl.sql # 24 tablas
│ ├── 02-hr-schema-ddl.sql # 8 tablas
│ ├── 03-hse-schema-ddl.sql # 58 tablas
│ ├── 04-estimates-schema-ddl.sql # 8 tablas
│ ├── 05-infonavit-schema-ddl.sql # 8 tablas
│ ├── 06-inventory-ext-schema-ddl.sql # 4 tablas
│ └── 07-purchase-ext-schema-ddl.sql # 5 tablas
├── docs/ # Documentacion completa
├── devops/
│ └── scripts/ # Validacion SSOT
├── docker-compose.yml
└── .env.example
Modulos Implementados
MAI-003: Presupuestos y Costos ✅
// Entidades
- Concepto // Catalogo jerarquico de conceptos
- Presupuesto // Presupuestos versionados
- PresupuestoPartida // Lineas con calculo automatico
// Services
- ConceptoService // Arbol, busqueda
- PresupuestoService // CRUD, versionamiento, aprobacion
MAI-005: Control de Obra ✅
// Entidades
- AvanceObra // Avances fisicos con workflow
- FotoAvance // Evidencias con GPS
- BitacoraObra // Bitacora diaria
- ProgramaObra // Programa maestro
- ProgramaActividad // WBS/Actividades
// Services
- AvanceObraService // Workflow captura->revision->aprobacion
- BitacoraObraService // Entradas secuenciales
MAI-008: Estimaciones ✅
// Entidades
- Estimacion // Estimaciones periodicas
- EstimacionConcepto // Lineas con acumulados
- Generador // Numeros generadores
- Anticipo // Anticipos con amortizacion
- Amortizacion // Descuentos por estimacion
- Retencion // Fondo de garantia
- FondoGarantia // Acumulado por contrato
- EstimacionWorkflow // Historial de estados
// Services
- EstimacionService // Workflow completo, calculo totales
Auth: Autenticacion JWT ✅
// Funcionalidades
- Login con email/password
- Registro de usuarios
- Refresh tokens
- Logout (revocacion)
- Middleware de autorizacion por roles
- Configuracion RLS por tenant
API Endpoints
Autenticacion
POST /api/v1/auth/login
POST /api/v1/auth/register
POST /api/v1/auth/refresh
POST /api/v1/auth/logout
POST /api/v1/auth/change-password
Presupuestos
GET /api/v1/conceptos
GET /api/v1/conceptos/:id
POST /api/v1/conceptos
GET /api/v1/conceptos/tree
GET /api/v1/presupuestos
GET /api/v1/presupuestos/:id
POST /api/v1/presupuestos
POST /api/v1/presupuestos/:id/partidas
POST /api/v1/presupuestos/:id/approve
POST /api/v1/presupuestos/:id/version
Control de Obra
GET /api/v1/avances
GET /api/v1/avances/:id
POST /api/v1/avances
POST /api/v1/avances/:id/fotos
POST /api/v1/avances/:id/review
POST /api/v1/avances/:id/approve
GET /api/v1/bitacora/:fraccionamientoId
POST /api/v1/bitacora
Estimaciones
GET /api/v1/estimaciones
GET /api/v1/estimaciones/:id
POST /api/v1/estimaciones
POST /api/v1/estimaciones/:id/conceptos
POST /api/v1/estimaciones/:id/submit
POST /api/v1/estimaciones/:id/review
POST /api/v1/estimaciones/:id/approve
Base de Datos
Schemas (7 total, 110 tablas)
| Schema | Tablas | Descripcion |
|---|---|---|
auth |
10 | Usuarios, roles, permisos, tenants |
construction |
24 | Proyectos, lotes, presupuestos, avances |
hr |
8 | Empleados, asistencias, cuadrillas |
hse |
58 | Incidentes, capacitaciones, EPP, STPS |
estimates |
8 | Estimaciones, anticipos, retenciones |
infonavit |
8 | Registro RUV, derechohabientes |
inventory |
4 | Almacenes, requisiciones |
Row Level Security
-- Todas las tablas tienen RLS activado
ALTER TABLE construction.fraccionamientos ENABLE ROW LEVEL SECURITY;
-- Politica de aislamiento por tenant
CREATE POLICY tenant_isolation ON construction.fraccionamientos
FOR ALL USING (tenant_id = current_setting('app.current_tenant_id')::UUID);
Scripts NPM
# Backend
npm run dev # Desarrollo con hot-reload
npm run build # Compilar TypeScript
npm run start # Produccion
npm run lint # ESLint
npm run test # Jest tests
npm run validate:constants # Validar SSOT
npm run sync:enums # Sincronizar enums a frontend
# Docker
docker-compose up -d # Levantar servicios
docker-compose --profile dev up # Con Adminer y Mailhog
docker-compose down # Detener servicios
Variables de Entorno
# Application
NODE_ENV=development
APP_PORT=3000
# Database
DB_HOST=localhost
DB_PORT=5432
DB_USER=construccion
DB_PASSWORD=construccion_dev_2024
DB_NAME=erp_construccion
# JWT
JWT_SECRET=your-secret-key-min-32-chars
JWT_EXPIRES_IN=1d
JWT_REFRESH_EXPIRES_IN=7d
# Redis
REDIS_HOST=localhost
REDIS_PORT=6379
Ver .env.example para la lista completa.
Documentacion
| Documento | Ubicacion |
|---|---|
| Estado del Proyecto | PROJECT-STATUS.md |
| Mapa de Base de Datos | database/_MAP.md |
| Constantes SSOT | backend/src/shared/constants/ |
| Modulos (18) | docs/02-definicion-modulos/ |
| Requerimientos (87 RF) | docs/03-requerimientos/ |
| User Stories (149 US) | docs/05-user-stories/ |
| ADRs (12) | docs/97-adr/ |
Proximos Pasos
-
Corto Plazo
- Controllers REST para modulos nuevos
- Backend MAI-009 (Calidad y Postventa)
- Backend MAI-011 (INFONAVIT)
- Testing de modulos existentes
-
Mediano Plazo
- Frontend: Integracion con API
- Modulos de Presupuestos y Estimaciones
- Curva S y reportes de avance
Licencia
UNLICENSED - Proyecto privado
Ultima actualizacion: 2025-12-12