## Backend API (apps/api) - Express.js server with TypeScript - JWT authentication with access/refresh tokens - Multi-tenant middleware (schema per tenant) - Complete CRUD routes: auth, cfdis, transactions, contacts, categories, metrics, alerts - SAT integration: CFDI 4.0 XML parser, FIEL authentication - Metrics engine: 50+ financial metrics (Core, Startup, Enterprise) - Rate limiting, CORS, Helmet security ## Frontend Web (apps/web) - Next.js 14 with App Router - Authentication pages: login, register, forgot-password - Dashboard layout with Sidebar and Header - Dashboard pages: overview, cash-flow, revenue, expenses, metrics - Zustand stores for auth and UI state - Theme support with flash prevention ## Database Package (packages/database) - PostgreSQL migrations with multi-tenant architecture - Public schema: plans, tenants, users, sessions, subscriptions - Tenant schema: sat_credentials, cfdis, transactions, contacts, accounts, alerts - Tenant management functions - Seed data for plans and super admin ## Shared Package (packages/shared) - TypeScript types: auth, tenant, financial, metrics, reports - Zod validation schemas for all entities - Utility functions for formatting ## UI Package (packages/ui) - Chart components: LineChart, BarChart, AreaChart, PieChart - Data components: DataTable, MetricCard, KPICard, AlertBadge - PeriodSelector and Skeleton components ## Infrastructure - Docker Compose: PostgreSQL 15, Redis 7, MinIO, Mailhog - Makefile with 25+ development commands - Development scripts: dev-setup.sh, dev-down.sh - Complete .env.example template Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
146 lines
5.1 KiB
YAML
146 lines
5.1 KiB
YAML
# =============================================================================
|
|
# Horux Strategy - Docker Compose para Desarrollo
|
|
# =============================================================================
|
|
# Este archivo define los servicios de infraestructura necesarios para el
|
|
# desarrollo local del proyecto Horux Strategy.
|
|
#
|
|
# Uso:
|
|
# docker-compose up -d # Levantar todos los servicios
|
|
# docker-compose down # Detener todos los servicios
|
|
# docker-compose logs -f # Ver logs en tiempo real
|
|
# =============================================================================
|
|
|
|
version: '3.8'
|
|
|
|
services:
|
|
# ---------------------------------------------------------------------------
|
|
# PostgreSQL - Base de datos principal
|
|
# ---------------------------------------------------------------------------
|
|
postgres:
|
|
image: postgres:15-alpine
|
|
container_name: horux-postgres
|
|
restart: unless-stopped
|
|
ports:
|
|
- "${POSTGRES_PORT:-5432}:5432"
|
|
environment:
|
|
POSTGRES_USER: ${POSTGRES_USER:-horux}
|
|
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-horux_secret_2024}
|
|
POSTGRES_DB: ${POSTGRES_DB:-horux_strategy}
|
|
# Configuracion para mejor rendimiento en desarrollo
|
|
POSTGRES_INITDB_ARGS: "--encoding=UTF-8 --lc-collate=en_US.utf8 --lc-ctype=en_US.utf8"
|
|
volumes:
|
|
# Persistencia de datos
|
|
- postgres_data:/var/lib/postgresql/data
|
|
# Script de inicializacion
|
|
- ./docker/postgres/init.sql:/docker-entrypoint-initdb.d/init.sql:ro
|
|
healthcheck:
|
|
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-horux} -d ${POSTGRES_DB:-horux_strategy}"]
|
|
interval: 10s
|
|
timeout: 5s
|
|
retries: 5
|
|
start_period: 30s
|
|
networks:
|
|
- horux-network
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# Redis - Cache y colas de trabajo (BullMQ)
|
|
# ---------------------------------------------------------------------------
|
|
redis:
|
|
image: redis:7-alpine
|
|
container_name: horux-redis
|
|
restart: unless-stopped
|
|
ports:
|
|
- "${REDIS_PORT:-6379}:6379"
|
|
command: redis-server --appendonly yes --maxmemory 256mb --maxmemory-policy allkeys-lru
|
|
volumes:
|
|
- redis_data:/data
|
|
healthcheck:
|
|
test: ["CMD", "redis-cli", "ping"]
|
|
interval: 10s
|
|
timeout: 5s
|
|
retries: 5
|
|
networks:
|
|
- horux-network
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# MinIO - Almacenamiento de objetos (compatible con S3)
|
|
# ---------------------------------------------------------------------------
|
|
# Usado para almacenar reportes, adjuntos y exportaciones
|
|
minio:
|
|
image: minio/minio:latest
|
|
container_name: horux-minio
|
|
restart: unless-stopped
|
|
ports:
|
|
- "${MINIO_API_PORT:-9000}:9000" # API S3
|
|
- "${MINIO_CONSOLE_PORT:-9001}:9001" # Consola web
|
|
environment:
|
|
MINIO_ROOT_USER: ${MINIO_ROOT_USER:-horux_minio}
|
|
MINIO_ROOT_PASSWORD: ${MINIO_ROOT_PASSWORD:-horux_minio_secret}
|
|
command: server /data --console-address ":9001"
|
|
volumes:
|
|
- minio_data:/data
|
|
healthcheck:
|
|
test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"]
|
|
interval: 30s
|
|
timeout: 20s
|
|
retries: 3
|
|
networks:
|
|
- horux-network
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# MinIO Setup - Inicializacion de buckets
|
|
# ---------------------------------------------------------------------------
|
|
# Este servicio se ejecuta una vez para crear los buckets necesarios
|
|
minio-setup:
|
|
image: minio/mc:latest
|
|
container_name: horux-minio-setup
|
|
depends_on:
|
|
minio:
|
|
condition: service_healthy
|
|
entrypoint: /bin/sh
|
|
command: /scripts/init.sh
|
|
volumes:
|
|
- ./docker/minio/init.sh:/scripts/init.sh:ro
|
|
environment:
|
|
MINIO_ROOT_USER: ${MINIO_ROOT_USER:-horux_minio}
|
|
MINIO_ROOT_PASSWORD: ${MINIO_ROOT_PASSWORD:-horux_minio_secret}
|
|
networks:
|
|
- horux-network
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# Mailhog - Servidor SMTP para testing de emails
|
|
# ---------------------------------------------------------------------------
|
|
# Captura todos los emails enviados y los muestra en una interfaz web
|
|
# NO envia emails reales - perfecto para desarrollo
|
|
mailhog:
|
|
image: mailhog/mailhog:latest
|
|
container_name: horux-mailhog
|
|
restart: unless-stopped
|
|
ports:
|
|
- "${MAILHOG_SMTP_PORT:-1025}:1025" # SMTP
|
|
- "${MAILHOG_UI_PORT:-8025}:8025" # Interfaz web
|
|
networks:
|
|
- horux-network
|
|
|
|
# =============================================================================
|
|
# Volumenes persistentes
|
|
# =============================================================================
|
|
volumes:
|
|
postgres_data:
|
|
driver: local
|
|
name: horux_postgres_data
|
|
redis_data:
|
|
driver: local
|
|
name: horux_redis_data
|
|
minio_data:
|
|
driver: local
|
|
name: horux_minio_data
|
|
|
|
# =============================================================================
|
|
# Red interna
|
|
# =============================================================================
|
|
networks:
|
|
horux-network:
|
|
driver: bridge
|
|
name: horux-network
|