🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
402 lines
9.5 KiB
Markdown
402 lines
9.5 KiB
Markdown
---
|
|
id: "STACK-BA"
|
|
title: "Stack Tecnologico - Betting Analytics"
|
|
type: "Technical"
|
|
status: "Draft"
|
|
version: "1.0.0"
|
|
created_date: "2026-01-04"
|
|
updated_date: "2026-01-04"
|
|
---
|
|
|
|
# Stack Tecnologico - Betting Analytics
|
|
|
|
---
|
|
|
|
## 1. RESUMEN DEL STACK
|
|
|
|
| Capa | Tecnologia | Version | Estado |
|
|
|------|------------|---------|--------|
|
|
| **Backend** | NestJS | ^10.3.0 | Implementado |
|
|
| **Frontend** | React + Vite | TBD | Planificado |
|
|
| **ML Engine** | FastAPI | TBD | Planificado |
|
|
| **Database** | PostgreSQL | 15+ | Planificado |
|
|
| **ORM** | TypeORM | ^0.3.19 | Implementado |
|
|
| **Autenticacion** | JWT + Passport | ^10.2.0 | Placeholder |
|
|
| **Containerizacion** | Docker | 24+ | Implementado |
|
|
|
|
---
|
|
|
|
## 2. BACKEND
|
|
|
|
### 2.1 Framework Principal
|
|
|
|
| Componente | Tecnologia | Version | Proposito |
|
|
|------------|------------|---------|-----------|
|
|
| **Framework** | NestJS | ^10.3.0 | Framework modular para Node.js |
|
|
| **Runtime** | Node.js | 20 LTS | Entorno de ejecucion |
|
|
| **Lenguaje** | TypeScript | ^5.3.3 | Tipado estatico |
|
|
|
|
### 2.2 Dependencias de Produccion
|
|
|
|
```json
|
|
{
|
|
"@nestjs/common": "^10.3.0",
|
|
"@nestjs/config": "^3.1.1",
|
|
"@nestjs/core": "^10.3.0",
|
|
"@nestjs/jwt": "^10.2.0",
|
|
"@nestjs/passport": "^10.0.3",
|
|
"@nestjs/platform-express": "^10.3.0",
|
|
"@nestjs/typeorm": "^10.0.1",
|
|
"bcrypt": "^5.1.1",
|
|
"class-transformer": "^0.5.1",
|
|
"class-validator": "^0.14.1",
|
|
"passport": "^0.7.0",
|
|
"passport-jwt": "^4.0.1",
|
|
"passport-local": "^1.0.0",
|
|
"pg": "^8.11.3",
|
|
"reflect-metadata": "^0.2.1",
|
|
"rxjs": "^7.8.1",
|
|
"typeorm": "^0.3.19",
|
|
"stripe": "^14.0.0"
|
|
}
|
|
```
|
|
|
|
### 2.3 Dependencias de Desarrollo
|
|
|
|
```json
|
|
{
|
|
"@nestjs/cli": "^10.3.0",
|
|
"@nestjs/testing": "^10.3.0",
|
|
"@types/bcrypt": "^5.0.2",
|
|
"@types/express": "^4.17.21",
|
|
"@types/jest": "^29.5.11",
|
|
"@types/node": "^20.10.6",
|
|
"@typescript-eslint/eslint-plugin": "^6.18.0",
|
|
"eslint": "^8.56.0",
|
|
"jest": "^29.7.0",
|
|
"prettier": "^3.1.1",
|
|
"supertest": "^6.3.4",
|
|
"ts-jest": "^29.1.1",
|
|
"typescript": "^5.3.3"
|
|
}
|
|
```
|
|
|
|
### 2.4 Configuracion
|
|
|
|
| Archivo | Proposito |
|
|
|---------|-----------|
|
|
| `tsconfig.json` | Configuracion TypeScript |
|
|
| `package.json` | Dependencias y scripts |
|
|
| `src/config/index.ts` | Configuracion de app, DB, JWT |
|
|
|
|
### 2.5 Scripts Disponibles
|
|
|
|
```bash
|
|
npm run start:dev # Desarrollo con hot-reload
|
|
npm run build # Build de produccion
|
|
npm run start:prod # Ejecutar build de produccion
|
|
npm run test # Tests unitarios
|
|
npm run test:e2e # Tests end-to-end
|
|
npm run lint # ESLint
|
|
npm run format # Prettier
|
|
```
|
|
|
|
---
|
|
|
|
## 3. FRONTEND (Planificado)
|
|
|
|
### 3.1 Stack Objetivo
|
|
|
|
| Componente | Tecnologia | Version | Proposito |
|
|
|------------|------------|---------|-----------|
|
|
| **Framework** | React | 18+ | UI Library |
|
|
| **Bundler** | Vite | 5+ | Build tool rapido |
|
|
| **Lenguaje** | TypeScript | 5+ | Tipado estatico |
|
|
| **Estado** | Zustand | TBD | Gestion de estado |
|
|
| **UI Kit** | TBD | - | Componentes UI |
|
|
| **HTTP** | Axios / Fetch | - | Cliente HTTP |
|
|
|
|
### 3.2 Estructura Planificada
|
|
|
|
```
|
|
frontend/
|
|
├── src/
|
|
│ ├── assets/ # Imagenes, fuentes
|
|
│ ├── components/ # Componentes reutilizables
|
|
│ │ ├── common/ # Botones, inputs, etc
|
|
│ │ ├── layout/ # Header, footer, sidebar
|
|
│ │ └── charts/ # Graficos y visualizaciones
|
|
│ ├── pages/ # Paginas/rutas
|
|
│ │ ├── auth/ # Login, registro
|
|
│ │ ├── dashboard/ # Dashboard principal
|
|
│ │ └── analytics/ # Vistas de analytics
|
|
│ ├── hooks/ # Custom hooks
|
|
│ ├── stores/ # Estado global (Zustand)
|
|
│ ├── services/ # Clientes API
|
|
│ ├── types/ # Definiciones TypeScript
|
|
│ ├── utils/ # Utilidades
|
|
│ ├── App.tsx # Componente principal
|
|
│ └── main.tsx # Punto de entrada
|
|
├── public/
|
|
├── index.html
|
|
├── vite.config.ts
|
|
├── tsconfig.json
|
|
└── package.json
|
|
```
|
|
|
|
---
|
|
|
|
## 4. ML ENGINE (Planificado)
|
|
|
|
### 4.1 Stack Objetivo
|
|
|
|
| Componente | Tecnologia | Version | Proposito |
|
|
|------------|------------|---------|-----------|
|
|
| **Framework** | FastAPI | TBD | API asincrona |
|
|
| **Runtime** | Python | 3.11 | Lenguaje |
|
|
| **ML** | scikit-learn | TBD | Modelos ML |
|
|
| **Data** | pandas | TBD | Manipulacion de datos |
|
|
| **Server** | Uvicorn | TBD | ASGI server |
|
|
|
|
### 4.2 Estructura Planificada
|
|
|
|
```
|
|
ml/
|
|
├── src/
|
|
│ ├── api/ # Endpoints FastAPI
|
|
│ │ ├── routes/ # Rutas
|
|
│ │ └── schemas/ # Pydantic schemas
|
|
│ ├── models/ # Modelos ML
|
|
│ │ ├── prediction/ # Modelos de prediccion
|
|
│ │ └── training/ # Scripts de entrenamiento
|
|
│ ├── pipelines/ # Pipelines de datos
|
|
│ ├── config/ # Configuracion
|
|
│ └── main.py # Punto de entrada
|
|
├── tests/
|
|
├── requirements.txt
|
|
├── requirements-dev.txt
|
|
└── Dockerfile
|
|
```
|
|
|
|
---
|
|
|
|
## 5. BASE DE DATOS
|
|
|
|
### 5.1 PostgreSQL
|
|
|
|
| Caracteristica | Valor |
|
|
|----------------|-------|
|
|
| **Version** | 15+ |
|
|
| **Puerto** | 5432 |
|
|
| **Base de datos** | betting_analytics |
|
|
| **Encoding** | UTF-8 |
|
|
|
|
### 5.2 Configuracion TypeORM
|
|
|
|
```typescript
|
|
// src/config/index.ts
|
|
export const databaseConfig = registerAs('database', () => ({
|
|
type: 'postgres',
|
|
host: process.env.DB_HOST || 'localhost',
|
|
port: parseInt(process.env.DB_PORT, 10) || 5432,
|
|
username: process.env.DB_USERNAME || 'postgres',
|
|
password: process.env.DB_PASSWORD || 'postgres',
|
|
database: process.env.DB_NAME || 'betting_analytics',
|
|
synchronize: process.env.NODE_ENV !== 'production',
|
|
logging: process.env.NODE_ENV === 'development',
|
|
}));
|
|
```
|
|
|
|
### 5.3 Migraciones
|
|
|
|
- TypeORM migrations para control de esquema
|
|
- No usar `synchronize: true` en produccion
|
|
- Versionado de migraciones en repositorio
|
|
|
|
---
|
|
|
|
## 6. AUTENTICACION
|
|
|
|
### 6.1 Stack de Autenticacion
|
|
|
|
| Componente | Tecnologia | Proposito |
|
|
|------------|------------|-----------|
|
|
| **Tokens** | JWT | Access tokens |
|
|
| **Estrategias** | Passport.js | Autenticacion modular |
|
|
| **Hash** | bcrypt | Hash de passwords |
|
|
|
|
### 6.2 Configuracion JWT
|
|
|
|
```typescript
|
|
// src/config/index.ts
|
|
export const jwtConfig = registerAs('jwt', () => ({
|
|
secret: process.env.JWT_SECRET || 'change-me-in-production',
|
|
expiresIn: process.env.JWT_EXPIRES_IN || '1d',
|
|
}));
|
|
```
|
|
|
|
### 6.3 Estrategias Planificadas
|
|
|
|
- `JwtStrategy` - Validacion de tokens
|
|
- `LocalStrategy` - Login con email/password
|
|
- `RefreshStrategy` - Renovacion de tokens
|
|
|
|
---
|
|
|
|
## 7. CONTAINERIZACION
|
|
|
|
### 7.1 Docker
|
|
|
|
| Servicio | Base Image | Puerto |
|
|
|----------|------------|--------|
|
|
| Backend | node:20-alpine | 3090 |
|
|
| Frontend | nginx:alpine | 80 |
|
|
| ML Engine | python:3.11-slim | 3093 |
|
|
| Database | postgres:15 | 5432 |
|
|
|
|
### 7.2 Dockerfile Backend
|
|
|
|
```dockerfile
|
|
# Multi-stage build
|
|
FROM node:20-alpine AS deps
|
|
FROM node:20-alpine AS builder
|
|
FROM node:20-alpine AS runner
|
|
|
|
# Non-root user
|
|
USER express
|
|
EXPOSE 3090
|
|
CMD ["node", "dist/main.js"]
|
|
```
|
|
|
|
### 7.3 Dockerfile Frontend
|
|
|
|
```dockerfile
|
|
# Multi-stage build
|
|
FROM node:20-alpine AS deps
|
|
FROM node:20-alpine AS builder
|
|
FROM nginx:alpine AS runner
|
|
|
|
EXPOSE 80
|
|
CMD ["nginx", "-g", "daemon off;"]
|
|
```
|
|
|
|
---
|
|
|
|
## 8. HERRAMIENTAS DE DESARROLLO
|
|
|
|
### 8.1 Linting y Formato
|
|
|
|
| Herramienta | Proposito |
|
|
|-------------|-----------|
|
|
| ESLint | Linting de codigo |
|
|
| Prettier | Formato de codigo |
|
|
| TypeScript | Chequeo de tipos |
|
|
|
|
### 8.2 Testing
|
|
|
|
| Herramienta | Proposito |
|
|
|-------------|-----------|
|
|
| Jest | Tests unitarios |
|
|
| Supertest | Tests de integracion |
|
|
| ts-jest | Jest con TypeScript |
|
|
|
|
### 8.3 IDE Recomendado
|
|
|
|
- VS Code con extensiones:
|
|
- ESLint
|
|
- Prettier
|
|
- TypeScript
|
|
- NestJS Snippets
|
|
- Docker
|
|
|
|
---
|
|
|
|
## 9. VARIABLES DE ENTORNO
|
|
|
|
### Backend
|
|
|
|
```env
|
|
# App
|
|
NODE_ENV=development
|
|
PORT=3090
|
|
API_PREFIX=api
|
|
CORS_ORIGIN=*
|
|
|
|
# Database
|
|
DB_HOST=localhost
|
|
DB_PORT=5432
|
|
DB_USERNAME=postgres
|
|
DB_PASSWORD=postgres
|
|
DB_NAME=betting_analytics
|
|
|
|
# JWT
|
|
JWT_SECRET=change-me-in-production
|
|
JWT_EXPIRES_IN=1d
|
|
```
|
|
|
|
### Frontend
|
|
|
|
```env
|
|
VITE_API_URL=http://localhost:3090/api
|
|
VITE_WS_URL=ws://localhost:3090
|
|
```
|
|
|
|
### ML Engine
|
|
|
|
```env
|
|
PYTHONDONTWRITEBYTECODE=1
|
|
PYTHONUNBUFFERED=1
|
|
PORT=3093
|
|
DATABASE_URL=postgresql://postgres:postgres@localhost:5432/betting_analytics
|
|
```
|
|
|
|
---
|
|
|
|
## 10. DECISIONES TECNICAS
|
|
|
|
| Decision | Razon | ADR |
|
|
|----------|-------|-----|
|
|
| NestJS sobre Express | Arquitectura modular, TypeScript nativo | ADR-001 |
|
|
| TypeORM sobre Prisma | Decorators, integracion NestJS | ADR-001 |
|
|
| PostgreSQL | Datos relacionales, extensiones JSON | ADR-001 |
|
|
| JWT sobre Sessions | Stateless, escalabilidad | ADR-001 |
|
|
| Docker | Portabilidad, consistencia | ADR-001 |
|
|
|
|
---
|
|
|
|
## 11. ROADMAP TECNICO
|
|
|
|
### Fase 1 (Actual)
|
|
- [x] Estructura NestJS base
|
|
- [x] Configuracion TypeORM
|
|
- [x] Modulo auth placeholder
|
|
- [ ] Implementar autenticacion JWT
|
|
|
|
### Fase 2
|
|
- [ ] Setup frontend React + Vite
|
|
- [ ] Integracion con backend
|
|
- [ ] Dashboard basico
|
|
|
|
### Fase 3
|
|
- [ ] Setup ML Engine Python
|
|
- [ ] Modelos predictivos basicos
|
|
- [ ] API de predicciones
|
|
|
|
---
|
|
|
|
## 12. REFERENCIAS
|
|
|
|
- **Vision:** [VISION-PRODUCTO.md](./VISION-PRODUCTO.md)
|
|
- **Arquitectura:** [ARQUITECTURA-GENERAL.md](./ARQUITECTURA-GENERAL.md)
|
|
- **ADR-001:** [../97-adr/ADR-001-stack-tecnologico.md](../97-adr/ADR-001-stack-tecnologico.md)
|
|
- **NestJS Docs:** https://docs.nestjs.com
|
|
- **TypeORM Docs:** https://typeorm.io
|
|
|
|
---
|
|
|
|
**Documento:** Stack Tecnologico
|
|
**Proyecto:** Betting Analytics
|
|
**Version:** 1.0.0
|
|
**Fecha:** 2026-01-04
|
|
**Estado:** Draft
|