# Stack TecnolΓ³gico - App Canchas de PΓ‘del ## πŸ—οΈ Arquitectura General ``` β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ CLIENTES β”‚ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ β”‚ β”‚ Web App β”‚ β”‚ Mobile App β”‚ β”‚ Admin Panel β”‚ β”‚ β”‚ β”‚ (React) β”‚ β”‚(React Native)β”‚ β”‚ (React) β”‚ β”‚ β”‚ β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β”‚ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β” β”‚ API Gateway β”‚ β”‚ (Nginx) β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ β”‚ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β” β”‚ Backend β”‚ β”‚ Backend β”‚ β”‚ Backend β”‚ β”‚ (Node.js) β”‚ β”‚ (Node.js) β”‚ β”‚ (Node.js) β”‚ β”‚ API REST β”‚ β”‚ API REST β”‚ β”‚ API REST β”‚ β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜ β”‚ β”‚ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β” β”‚ PostgreSQL β”‚ β”‚ (Primary) β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ β”‚ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β–Όβ”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β–Όβ”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β–Όβ”€β”€β” β”‚ Redis β”‚ β”‚MinIO/S3 β”‚ β”‚Mailhog/β”‚ β”‚ (Cache) β”‚ β”‚(Files) β”‚ β”‚SendGridβ”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”˜ ``` --- ## πŸ“¦ Stack por Componente ### Backend | TecnologΓ­a | VersiΓ³n | Uso | |------------|---------|-----| | Node.js | 20.x LTS | Runtime | | Express.js | 4.x | Framework HTTP | | TypeScript | 5.x | Tipado estΓ‘tico | | Prisma | 5.x | ORM y migraciones | | Zod | 3.x | ValidaciΓ³n de schemas | | JWT | 9.x | AutenticaciΓ³n | | bcrypt | 5.x | Hash de passwords | | cors | 2.x | Cross-origin | | helmet | 7.x | Seguridad HTTP | | morgan | 1.x | Logging HTTP | | winston | 3.x | Logging app | | nodemailer | 6.x | EnvΓ­o de emails | | dotenv | 16.x | Variables de entorno | ### Base de Datos | TecnologΓ­a | Uso | |------------|-----| | PostgreSQL 16 | Base de datos principal | | Redis | Cache y sesiones | ### Frontend Web | TecnologΓ­a | VersiΓ³n | Uso | |------------|---------|-----| | React | 18.x | UI Library | | TypeScript | 5.x | Tipado estΓ‘tico | | Vite | 5.x | Build tool | | React Router | 6.x | Routing | | TanStack Query | 5.x | Data fetching | | Axios | 1.x | HTTP client | | TailwindCSS | 3.x | Estilos | | HeadlessUI | 1.x | Componentes accesibles | | React Hook Form | 7.x | Formularios | | Zod | 3.x | ValidaciΓ³n | | date-fns | 3.x | Manejo de fechas | --- ## πŸ“ Estructura de Carpetas ``` backend/ # API REST Node.js + Express β”œβ”€β”€ src/ β”‚ β”œβ”€β”€ config/ # ConfiguraciΓ³n (DB, email, etc) β”‚ β”œβ”€β”€ controllers/ # Controladores HTTP β”‚ β”œβ”€β”€ middleware/ # Middlewares (auth, error, etc) β”‚ β”œβ”€β”€ routes/ # DefiniciΓ³n de rutas β”‚ β”œβ”€β”€ services/ # LΓ³gica de negocio β”‚ β”œβ”€β”€ utils/ # Utilidades β”‚ β”œβ”€β”€ validators/ # Schemas Zod β”‚ └── index.ts # Entry point β”œβ”€β”€ prisma/ β”‚ └── schema.prisma # Schema de BD β”œβ”€β”€ tests/ β”œβ”€β”€ Dockerfile └── package.json ``` --- ## πŸ” Seguridad - **JWT** para autenticaciΓ³n stateless - **bcrypt** con salt rounds 12 para passwords - **Helmet** para headers de seguridad HTTP - **CORS** configurado por dominio - **Rate limiting** en endpoints sensibles - **ValidaciΓ³n** de todos los inputs con Zod - **SQL Injection** protegido por Prisma ORM --- ## πŸ”Œ API Endpoints (VersiΓ³n 1) ### AutenticaciΓ³n ``` POST /api/v1/auth/register # Registro POST /api/v1/auth/login # Login POST /api/v1/auth/logout # Logout POST /api/v1/auth/refresh # Refresh token POST /api/v1/auth/forgot-password POST /api/v1/auth/reset-password GET /api/v1/auth/me # Perfil actual ``` ### Usuarios ``` GET /api/v1/users # Listar usuarios GET /api/v1/users/:id # Ver usuario PUT /api/v1/users/:id # Actualizar usuario DELETE /api/v1/users/:id # Eliminar usuario (admin) ``` ### Canchas ``` GET /api/v1/courts # Listar canchas GET /api/v1/courts/:id # Ver cancha POST /api/v1/courts # Crear cancha (admin) PUT /api/v1/courts/:id # Actualizar cancha (admin) DELETE /api/v1/courts/:id # Eliminar cancha (admin) GET /api/v1/courts/:id/availability # Ver disponibilidad ``` ### Reservas ``` GET /api/v1/bookings # Mis reservas GET /api/v1/bookings/:id # Ver reserva POST /api/v1/bookings # Crear reserva PUT /api/v1/bookings/:id # Modificar reserva DELETE /api/v1/bookings/:id # Cancelar reserva ``` --- *Definido el: 2026-01-31* *Fase: 1 - Fundamentos*