Files
HoruxStrategyKimi/Makefile
HORUX360 a9b1994c48 feat: Implement Phase 1 & 2 - Full monorepo architecture
## 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>
2026-01-31 11:05:24 +00:00

237 lines
7.5 KiB
Makefile

# =============================================================================
# Horux Strategy - Makefile
# =============================================================================
# Comandos utiles para el desarrollo del proyecto.
#
# Uso:
# make help - Ver todos los comandos disponibles
# make dev - Levantar entorno de desarrollo
# make down - Detener servicios
# =============================================================================
# Variables
DOCKER_COMPOSE = docker compose
PNPM = pnpm
# Colores para output
GREEN := $(shell tput -Txterm setaf 2)
YELLOW := $(shell tput -Txterm setaf 3)
BLUE := $(shell tput -Txterm setaf 4)
RESET := $(shell tput -Txterm sgr0)
# Default target
.DEFAULT_GOAL := help
# =============================================================================
# Ayuda
# =============================================================================
.PHONY: help
help: ## Mostrar esta ayuda
@echo ''
@echo '${BLUE}Horux Strategy - Comandos disponibles${RESET}'
@echo ''
@echo '${YELLOW}Desarrollo:${RESET}'
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf " ${GREEN}%-15s${RESET} %s\n", $$1, $$2}'
@echo ''
# =============================================================================
# Docker y Servicios
# =============================================================================
.PHONY: dev
dev: ## Levantar todos los servicios de desarrollo
@echo "${BLUE}Levantando servicios de desarrollo...${RESET}"
@./scripts/dev-setup.sh --skip-migrations
@echo "${GREEN}Servicios listos!${RESET}"
.PHONY: dev-full
dev-full: ## Setup completo (incluye migraciones)
@echo "${BLUE}Ejecutando setup completo...${RESET}"
@./scripts/dev-setup.sh
.PHONY: up
up: ## Levantar contenedores Docker (sin setup)
@echo "${BLUE}Levantando contenedores...${RESET}"
@$(DOCKER_COMPOSE) up -d
@echo "${GREEN}Contenedores levantados${RESET}"
.PHONY: down
down: ## Detener todos los servicios (mantiene datos)
@echo "${BLUE}Deteniendo servicios...${RESET}"
@./scripts/dev-down.sh
@echo "${GREEN}Servicios detenidos${RESET}"
.PHONY: down-clean
down-clean: ## Detener servicios y eliminar volumenes
@./scripts/dev-down.sh --clean
.PHONY: restart
restart: down up ## Reiniciar todos los servicios
.PHONY: logs
logs: ## Ver logs de todos los servicios
@$(DOCKER_COMPOSE) logs -f
.PHONY: logs-api
logs-api: ## Ver logs solo del API (si esta en Docker)
@$(DOCKER_COMPOSE) logs -f api 2>/dev/null || echo "API no esta en Docker, usa: pnpm --filter @horux/api dev"
.PHONY: logs-postgres
logs-postgres: ## Ver logs de PostgreSQL
@$(DOCKER_COMPOSE) logs -f postgres
.PHONY: logs-redis
logs-redis: ## Ver logs de Redis
@$(DOCKER_COMPOSE) logs -f redis
.PHONY: logs-minio
logs-minio: ## Ver logs de MinIO
@$(DOCKER_COMPOSE) logs -f minio
.PHONY: status
status: ## Ver estado de los contenedores
@echo "${BLUE}Estado de contenedores:${RESET}"
@$(DOCKER_COMPOSE) ps
# =============================================================================
# Base de Datos
# =============================================================================
.PHONY: migrate
migrate: ## Ejecutar migraciones de base de datos
@echo "${BLUE}Ejecutando migraciones...${RESET}"
@$(PNPM) db:migrate:dev
@echo "${GREEN}Migraciones completadas${RESET}"
.PHONY: migrate-prod
migrate-prod: ## Ejecutar migraciones (produccion)
@echo "${BLUE}Ejecutando migraciones de produccion...${RESET}"
@$(PNPM) db:migrate
@echo "${GREEN}Migraciones completadas${RESET}"
.PHONY: seed
seed: ## Ejecutar seeds (datos de prueba)
@echo "${BLUE}Ejecutando seeds...${RESET}"
@$(PNPM) db:seed
@echo "${GREEN}Seeds completados${RESET}"
.PHONY: db-reset
db-reset: ## Resetear base de datos (cuidado!)
@echo "${YELLOW}Esto eliminara todos los datos de la base de datos${RESET}"
@read -p "Estas seguro? (y/N): " confirm && [ "$$confirm" = "y" ] || exit 1
@$(DOCKER_COMPOSE) exec -T postgres psql -U horux -d horux_strategy -c "DROP SCHEMA public CASCADE; CREATE SCHEMA public;"
@$(PNPM) db:migrate:dev
@echo "${GREEN}Base de datos reseteada${RESET}"
.PHONY: db-shell
db-shell: ## Abrir shell de PostgreSQL
@$(DOCKER_COMPOSE) exec postgres psql -U horux -d horux_strategy
.PHONY: redis-shell
redis-shell: ## Abrir shell de Redis
@$(DOCKER_COMPOSE) exec redis redis-cli
# =============================================================================
# Desarrollo de Aplicacion
# =============================================================================
.PHONY: install
install: ## Instalar dependencias con pnpm
@echo "${BLUE}Instalando dependencias...${RESET}"
@$(PNPM) install
@echo "${GREEN}Dependencias instaladas${RESET}"
.PHONY: start
start: ## Iniciar aplicacion en modo desarrollo
@echo "${BLUE}Iniciando aplicacion...${RESET}"
@$(PNPM) dev
.PHONY: build
build: ## Compilar la aplicacion
@echo "${BLUE}Compilando aplicacion...${RESET}"
@$(PNPM) build
@echo "${GREEN}Compilacion completada${RESET}"
.PHONY: test
test: ## Ejecutar tests
@echo "${BLUE}Ejecutando tests...${RESET}"
@$(PNPM) test
.PHONY: test-watch
test-watch: ## Ejecutar tests en modo watch
@$(PNPM) test:watch
.PHONY: lint
lint: ## Ejecutar linter
@echo "${BLUE}Ejecutando linter...${RESET}"
@$(PNPM) lint
.PHONY: lint-fix
lint-fix: ## Ejecutar linter y corregir errores
@echo "${BLUE}Corrigiendo errores de lint...${RESET}"
@$(PNPM) lint:fix
.PHONY: format
format: ## Formatear codigo con Prettier
@echo "${BLUE}Formateando codigo...${RESET}"
@$(PNPM) format
.PHONY: typecheck
typecheck: ## Verificar tipos de TypeScript
@echo "${BLUE}Verificando tipos...${RESET}"
@$(PNPM) typecheck
# =============================================================================
# Limpieza
# =============================================================================
.PHONY: clean
clean: ## Limpiar artefactos de build
@echo "${BLUE}Limpiando artefactos...${RESET}"
@$(PNPM) clean
@echo "${GREEN}Limpieza completada${RESET}"
.PHONY: clean-all
clean-all: down-clean clean ## Limpiar todo (contenedores + artefactos)
@echo "${GREEN}Limpieza completa realizada${RESET}"
.PHONY: prune
prune: ## Limpiar recursos de Docker no utilizados
@echo "${BLUE}Limpiando recursos de Docker...${RESET}"
@docker system prune -f
@echo "${GREEN}Recursos limpiados${RESET}"
# =============================================================================
# Utilidades
# =============================================================================
.PHONY: env
env: ## Crear archivo .env desde .env.example
@if [ -f .env ]; then \
echo "${YELLOW}El archivo .env ya existe${RESET}"; \
else \
cp .env.example .env; \
echo "${GREEN}Archivo .env creado${RESET}"; \
fi
.PHONY: minio-console
minio-console: ## Abrir consola de MinIO en el navegador
@echo "${BLUE}Abriendo consola de MinIO...${RESET}"
@open http://localhost:9001 2>/dev/null || xdg-open http://localhost:9001 2>/dev/null || echo "Abre http://localhost:9001 en tu navegador"
.PHONY: mailhog
mailhog: ## Abrir Mailhog en el navegador
@echo "${BLUE}Abriendo Mailhog...${RESET}"
@open http://localhost:8025 2>/dev/null || xdg-open http://localhost:8025 2>/dev/null || echo "Abre http://localhost:8025 en tu navegador"
.PHONY: check-deps
check-deps: ## Verificar dependencias del sistema
@echo "${BLUE}Verificando dependencias...${RESET}"
@echo ""
@echo "Docker: $$(docker --version 2>/dev/null || echo 'No instalado')"
@echo "Docker Compose: $$(docker compose version 2>/dev/null || echo 'No instalado')"
@echo "Node.js: $$(node --version 2>/dev/null || echo 'No instalado')"
@echo "pnpm: $$(pnpm --version 2>/dev/null || echo 'No instalado')"
@echo ""