# DIRECTIVA: Stack Tecnológico Trading Platform **ID**: DOQ-002 **Tipo**: Tecnología **Alcance**: Trading Platform (trading-platform) **Versión**: 2.0 **Fecha**: 2025-12-07 **Actualizado desde**: trading (NestJS -> Express.js) ## Backend Principal - Express.js ### Versiones Requeridas ```json { "node": ">=20.0.0", "typescript": "^5.3.0", "express": "^4.18.0" } ``` ### Dependencias Core ```json { // Framework "express": "^4.18.2", "cors": "^2.8.5", "helmet": "^7.1.0", "compression": "^1.7.4", // Routing "express-async-errors": "^3.1.1", // Autenticación "passport": "^0.7.0", "passport-jwt": "^4.0.1", "passport-local": "^1.0.0", "passport-google-oauth20": "^2.0.0", "passport-facebook": "^3.0.0", "passport-github2": "^0.1.12", "jsonwebtoken": "^9.0.2", "bcrypt": "^5.1.1", "speakeasy": "^2.0.0", "qrcode": "^1.5.3", // Validación "zod": "^3.22.0", // Base de Datos "pg": "^8.11.0", "redis": "^4.6.0", // HTTP Client (para ML Services) "axios": "^1.6.0", // WebSockets "socket.io": "^4.7.0", // Pagos "stripe": "^14.0.0", // SMS/WhatsApp "twilio": "^4.20.0", // Logging "winston": "^3.11.0", "morgan": "^1.10.0", // Configuración "dotenv": "^16.3.0" } ``` ### Dependencias Dev ```json { "@types/node": "^20.0.0", "@types/express": "^4.17.21", "@types/passport-jwt": "^4.0.0", "@types/bcrypt": "^5.0.0", "@types/cors": "^2.8.17", "typescript": "^5.3.0", "tsx": "^4.7.0", "eslint": "^8.57.0", "prettier": "^3.2.0", "@typescript-eslint/eslint-plugin": "^7.0.0", "@typescript-eslint/parser": "^7.0.0", "vitest": "^1.2.0", "supertest": "^6.3.0" } ``` --- ## Frontend - React ### Versiones Requeridas ```json { "node": ">=20.0.0", "react": "^18.0.0", "typescript": "^5.3.0" } ``` ### Dependencias Core ```json { // Framework "react": "^18.2.0", "react-dom": "^18.2.0", // Routing "react-router-dom": "^6.22.0", // State Management "zustand": "^4.5.0", // Data Fetching "@tanstack/react-query": "^5.20.0", // Styling "tailwindcss": "^3.4.0", "@tailwindcss/forms": "^0.5.0", "clsx": "^2.1.0", "class-variance-authority": "^0.7.0", // UI Components (Shadcn/Radix) "@radix-ui/react-dialog": "^1.0.0", "@radix-ui/react-dropdown-menu": "^2.0.0", "@radix-ui/react-select": "^2.0.0", "@radix-ui/react-tabs": "^1.0.0", "@radix-ui/react-tooltip": "^1.0.0", "@radix-ui/react-avatar": "^1.0.0", "@radix-ui/react-checkbox": "^1.0.0", "@radix-ui/react-switch": "^1.0.0", "@radix-ui/react-progress": "^1.0.0", "@radix-ui/react-accordion": "^1.0.0", "@radix-ui/react-popover": "^1.0.0", "@radix-ui/react-scroll-area": "^1.0.0", // Forms "react-hook-form": "^7.50.0", "zod": "^3.22.0", "@hookform/resolvers": "^3.3.0", // Charts "recharts": "^2.12.0", "lightweight-charts": "^4.1.0", // Icons "lucide-react": "^0.350.0", // Animations "framer-motion": "^11.0.0", // HTTP Client "axios": "^1.6.0", // Notifications "sonner": "^1.4.0", // Dates "date-fns": "^3.3.0", // Payments "@stripe/stripe-js": "^3.0.0", "@stripe/react-stripe-js": "^2.5.0" } ``` ### Dependencias Dev ```json { "vite": "^5.4.0", "@vitejs/plugin-react": "^4.2.0", "typescript": "^5.3.0", "@types/react": "^18.2.0", "@types/react-dom": "^18.2.0", "eslint": "^8.57.0", "eslint-plugin-react": "^7.33.0", "prettier": "^3.2.0", "vitest": "^2.0.0", "@testing-library/react": "^14.2.0", "playwright": "^1.42.0" } ``` --- ## ML Engine - FastAPI (Python) ### Versiones Requeridas ```yaml python: ">=3.11,<3.13" cuda: ">=12.0" # Opcional para GPU ``` ### Ambiente Conda ```yaml name: trading-ml channels: - pytorch - nvidia - conda-forge - defaults dependencies: - python=3.11 - pytorch=2.5.0 - pytorch-cuda=12.1 - cudatoolkit=12.1 - pip ``` ### Dependencias Python (requirements.txt) ```txt # API Framework fastapi>=0.115.0 uvicorn[standard]>=0.32.0 websockets>=13.0 httpx>=0.28.0 # ML Core torch>=2.5.0 xgboost>=2.1.0 scikit-learn>=1.5.0 # Data Processing pandas>=2.2.0 numpy>=1.26.0 ta-lib>=0.4.32 pandas-ta>=0.3.14b pyarrow>=17.0.0 # Database pymysql>=1.1.0 sqlalchemy>=2.0.0 # Validation pydantic>=2.10.0 # Configuration pyyaml>=6.0.0 python-dotenv>=1.0.0 # Logging loguru>=0.7.0 # Monitoring wandb>=0.19.0 tensorboard>=2.18.0 # Serialization joblib>=1.4.0 # Development pytest>=8.3.0 black>=24.0.0 isort>=5.13.0 mypy>=1.8.0 ``` ### Dependencias Opcionales (GPU) ```txt # GPU Acceleration nvidia-cuda-runtime-cu12>=12.0.0 nvidia-cudnn-cu12>=9.0.0 ``` --- ## Bases de Datos ### PostgreSQL 15+ ```yaml version: "15" extensions: - uuid-ossp - pgcrypto - btree_gin - pg_trgm features: - Row Level Security (RLS) - JSON/JSONB support - Full-text search - Partitioning (si necesario) schemas: - public # Users, profiles, auth - education # Courses, lessons, quizzes - trading # Watchlists, orders, positions - investment # Products, accounts, transactions - financial # Subscriptions, wallets, billing - ml # Models, predictions, signals - audit # Audit logs, events ``` ### MySQL 8+ ```yaml version: "8.0" charset: utf8mb4 collation: utf8mb4_unicode_ci purpose: Historical trading data (OHLCV) features: - JSON support - Window functions - CTEs ``` ### Redis 7+ ```yaml version: "7.x" purpose: - Session storage - Rate limiting - Caching - Real-time pub/sub ``` --- ## DevOps ### Docker ```yaml docker: ">=24.0.0" docker-compose: ">=2.24.0" ``` ### Node.js Runtime ```yaml node: "20.x LTS" npm: ">=10.0.0" ``` ### Python Runtime ```yaml miniconda: "latest" python: "3.11.x" ``` --- ## Estructura de Configuración ### Backend (Express.js) ``` apps/backend/ ├── .env # Variables de entorno ├── .env.example # Template ├── tsconfig.json # TypeScript config ├── package.json # Dependencies └── src/ └── config/ └── index.ts # Configuración centralizada ``` ### Frontend (React) ``` apps/frontend/ ├── .env # Variables de entorno ├── .env.example # Template ├── vite.config.ts # Vite config ├── tsconfig.json # TypeScript config ├── tailwind.config.ts # Tailwind config ├── postcss.config.js # PostCSS config └── package.json # Dependencies ``` ### ML Engine (FastAPI) ``` apps/ml-engine/ ├── .env # Variables de entorno ├── .env.example # Template ├── environment.yml # Conda environment ├── requirements.txt # Pip dependencies ├── pyproject.toml # Project config └── config/ ├── trading.yaml # Trading params ├── models.yaml # Model config └── database.yaml # Database config ``` --- ## Comandos de Desarrollo ### Backend (Express.js) ```bash # Desarrollo npm run dev # Build npm run build # Start producción npm start # Test npm run test npm run test:watch # Lint npm run lint npm run lint:fix # Format npm run format ``` ### Frontend ```bash # Desarrollo npm run dev # Build npm run build # Preview npm run preview # Test npm run test npm run test:e2e # Lint npm run lint ``` ### ML Engine ```bash # Activar ambiente conda activate trading-ml # Desarrollo uvicorn src.api.main:app --reload --port 8000 # Test pytest tests/ # Lint black src/ isort src/ mypy src/ ``` --- ## Reglas de Versionado 1. **Semantic Versioning**: MAJOR.MINOR.PATCH 2. **Lockfiles**: package-lock.json, conda-lock.yml 3. **Actualización de dependencias**: Mensual para patches, trimestral para minor 4. **Breaking changes**: Solo en releases major planificados --- ## Comparación con trading (versión anterior) | Aspecto | trading | trading-platform | |---------|-------------|------------------| | Backend Framework | NestJS 11.x | Express.js 4.18.x | | ORM | TypeORM | Raw SQL + pg | | Validation | class-validator | Zod | | Logger | NestJS Logger | Winston | | React Version | 19.x | 18.x | | State Management | Zustand 5.x | Zustand 4.x | --- *Migrado desde trading y actualizado para Express.js*