# Product Requirements Document (PRD) ## 1. Executive Summary **Project Name:** **Target Audience:** **Business Goal:** (Métrica que mejora, ej: Reducir carga operativa en 40%, aumentar conversión 25%) **Deadline:** --- ## 2. Problem Statement ### Current Situation (Describe el estado actual del negocio/operación) ### Pain Points - **Pain 1:** (Qué duele ahora) - **Pain 2:** (Qué cuesta dinero) - **Pain 3:** (Qué consume tiempo) ### Success Metric - ¿Cómo mediremos éxito? (KPI específico) --- ## 3. Proposed Solution ### Overview (Descripción ejecutiva de la solución en 2-3 párrafos) ### Key Features (MVP) 1. **Feature 1:** (Qué hace) 2. **Feature 2:** (Qué hace) 3. **Feature 3:** (Qué hace) --- ## 4. Tech Stack & Infrastructure - **Backend:** Node.js / NestJS - **Database:** MySQL - **Frontend:** Angular + Tailwind CSS - **Cloud Provider:** AWS (EC2, Lambda, SES) - **Mobile (si aplica):** Flutter - **Authentication:** Firebase Auth / JWT - **Real-time (si aplica):** WebSockets / Socket.io --- ## 5. Core Logic & User Flow ### User Journey (Paso a Paso) **Flujo 1: [Nombre del Flujo Principal]** 1. El usuario [acción 1] 2. El sistema [reacción 1] 3. El usuario [acción 2] 4. El sistema [reacción 2] 5. Resultado final: [estado del sistema] **Flujo 2: [Nombre del Flujo Alternativo]** 1. El usuario [acción 1] 2. ... (repetir estructura) --- ## 6. API Endpoints | Method | Route | Description | Request Payload | Response | |--------|-------|-------------|-----------------|----------| | `POST` | `/api/v1/users/register` | Crear nuevo usuario | `{ email, password, name }` | `{ userId, token }` | | `POST` | `/api/v1/auth/login` | Autenticar usuario | `{ email, password }` | `{ token, expiresIn }` | | `GET` | `/api/v1/users/:id` | Obtener datos usuario | Params: userId | `{ user }` | | `PUT` | `/api/v1/users/:id` | Actualizar usuario | `{ name, email, phone }` | `{ success }` | | `DELETE` | `/api/v1/users/:id` | Eliminar usuario | Params: userId | `{ success }` | --- ## 7. Database Schema ### Users Table ```sql CREATE TABLE users ( id VARCHAR(36) PRIMARY KEY, email VARCHAR(255) UNIQUE NOT NULL, password_hash VARCHAR(255) NOT NULL, name VARCHAR(255) NOT NULL, phone VARCHAR(20), tenant_id VARCHAR(36), created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, updated_at TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, is_active BOOLEAN DEFAULT TRUE, INDEX idx_email (email), INDEX idx_tenant (tenant_id) ); ``` ### [Entity Name] Table ```sql CREATE TABLE [entity_name] ( id VARCHAR(36) PRIMARY KEY, [column_name] [DATA_TYPE], created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, INDEX idx_[important_field] ([important_field]) ); ``` --- ## 8. Frontend Architecture ### Pages/Components - **[Page 1]:** (Descripción breve) - **[Page 2]:** (Descripción breve) ### State Management - Redux / Zustand / NgRx (dependiendo del framework) - Estado global: `auth`, `user`, `data` ### Styling - Tailwind CSS - Light Mode (sin dark mode) - Color Palette: - Primary: #101626 - Accent: #6D28D9 - Background: #FFFFFF --- ## 9. Infrastructure & Deployment ### AWS Services Used - **EC2:** Instancias para backend (t3.medium mínimo) - **RDS:** MySQL (db.t3.micro para dev, db.t3.small para prod) - **S3:** Storage de archivos - **SES:** Email transaccional - **Lambda:** Background jobs (si aplica) - **CloudFront:** CDN para assets estáticos ### Environment Variables ``` DATABASE_URL=mysql://user:pass@host:3306/db JWT_SECRET=xxxxx AWS_ACCESS_KEY_ID=xxxxx AWS_SECRET_ACCESS_KEY=xxxxx SMTP_HOST=email-smtp.region.amazonaws.com NODE_ENV=production ``` --- ## 10. Security & Performance ### Security - ✓ JWT tokens (expiración: 24h) - ✓ HTTPS/TLS en todos los endpoints - ✓ Validación de inputs en backend - ✓ Rate limiting en login (5 intentos/5 min) - ✓ SQL injection prevention (prepared statements) - ✓ CORS configurado ### Performance Targets - Login endpoint: < 200ms - List endpoints: < 500ms - Database queries: < 300ms (sin N+1) - API payload size: < 5MB - Lighthouse score: > 80 --- ## 11. Definition of Done (Criterios de Aceptación) ### Backend - [ ] Todos los endpoints responden en tiempo < target - [ ] Cobertura de unit tests > 80% en funciones críticas - [ ] No hay warnings en linter (ESLint) - [ ] Documentación en código para lógica compleja - [ ] Manejo de errores consistente (500, 400, 401, 404) ### Frontend - [ ] Diseño responsive (mobile, tablet, desktop) - [ ] Cumple con paleta de colores y tipografía definida - [ ] Validación de inputs en cliente + servidor - [ ] Estados de carga visibles (spinners, skeletons) - [ ] Mensajes de error amigables para el usuario ### Testing - [ ] Unit tests ejecutados localmente sin errores - [ ] Integration tests pasan en CI/CD - [ ] Manual testing en navegadores principales - [ ] Load testing: Sin degradación > 10% en picos ### Deployment - [ ] Código mergeado a `main` con PR review - [ ] Migraciones de BD ejecutadas sin errores - [ ] Rollback plan documentado - [ ] Logs accesibles en CloudWatch - [ ] Monitoreo de errores activo (Sentry/Datadog) --- ## 12. Timeline | Week | Deliverables | Status | |------|--------------|--------| | Week 1 | Backend setup, DB schema, API skeleton | - | | Week 2 | Auth endpoints, user management | - | | Week 3 | Core feature endpoints | - | | Week 4 | Frontend components, integration | - | | Week 5 | Testing, bug fixes, deployment | - | --- ## 13. Assumptions & Constraints ### Assumptions - La base de datos será MySQL (no cambiar) - El equipo tiene acceso a AWS - El cliente aprobará mockups antes del desarrollo - No hay integraciones con terceros complejas ### Constraints - Budget: [monto] - Timeline: 5 semanas - Equipo: 1 backend + 1 frontend - Hosting: AWS incluido en el presupuesto --- ## 14. Out of Scope - Dark mode - Integración con Slack/Teams - Reportes avanzados - Soporte multiidioma --- ## 15. Next Steps 1. [ ] Cliente aprueba este PRD 2. [ ] Reservar reunión de kickoff 3. [ ] Setup inicial (repo, infra, CI/CD) 4. [ ] Comienza Week 1 de desarrollo