Changes include: - Updated architecture documentation - Enhanced module definitions (OQI-001 to OQI-008) - ML integration documentation updates - Trading strategies documentation - Orchestration and inventory updates - Docker configuration updates 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
503 lines
16 KiB
Markdown
503 lines
16 KiB
Markdown
---
|
|
id: "INVENTARIO-STC-PLATFORM-WEB"
|
|
title: "stc-platform-web"
|
|
type: "Documentation"
|
|
project: "trading-platform"
|
|
version: "1.0.0"
|
|
updated_date: "2026-01-04"
|
|
---
|
|
|
|
# Inventario de Funcionalidades: stc-platform-web
|
|
|
|
**Ultima actualizacion:** 2025-12-05
|
|
**Version del proyecto analizado:** stc-platform-web (React 18 + Vite + Supabase)
|
|
**Ubicacion:** `[LEGACY: proyecto cerrado - ver MIGRACION-SUPABASE-EXPRESS.md]/`
|
|
|
|
---
|
|
|
|
## Resumen Ejecutivo
|
|
|
|
El proyecto `stc-platform-web` contiene una implementacion funcional de una plataforma de trading educativo con las siguientes caracteristicas principales:
|
|
|
|
| Modulo | Estado | Componentes | Servicios | Hooks |
|
|
|--------|--------|-------------|-----------|-------|
|
|
| Autenticacion | Completo | 5+ | 4 | 5 |
|
|
| Cursos/Educacion | Completo | 10+ | 5 | 6 |
|
|
| Trading (Bots/Signals) | Completo | 15+ | 6 | 6 |
|
|
| Pagos (Stripe) | Completo | 8+ | 4 | 4 |
|
|
| Admin Panel | Completo | 10+ | - | - |
|
|
| Soporte | Parcial | 3+ | - | - |
|
|
|
|
---
|
|
|
|
## 1. Modulo de Autenticacion
|
|
|
|
### 1.1 Servicios Implementados
|
|
|
|
#### AuthService (`features/auth/services/authService.ts`)
|
|
```typescript
|
|
class AuthService {
|
|
signInWithEmail(email, password) // Login con email/password
|
|
signUpWithEmail(email, password, metadata) // Registro con metadata
|
|
signInWithProvider(config: SocialAuthConfig) // OAuth (Google, Facebook, etc.)
|
|
signOut() // Cerrar sesion
|
|
forgotPassword(email) // Solicitar reset password
|
|
resetPassword(password) // Cambiar password
|
|
updatePassword(password) // Actualizar password
|
|
verifyEmail(token, type) // Verificar email
|
|
resendVerification(email) // Reenviar verificacion
|
|
getCurrentUser() // Usuario actual
|
|
getCurrentSession() // Sesion actual
|
|
refreshSession() // Refrescar sesion
|
|
updateUserMetadata(metadata) // Actualizar metadata
|
|
onAuthStateChange(callback) // Listener de cambios
|
|
validatePasswordStrength(password) // Validar fortaleza password
|
|
}
|
|
```
|
|
|
|
#### TokenService (`features/auth/services/tokenService.ts`)
|
|
```typescript
|
|
class TokenService {
|
|
getAccessToken() // Obtener access token
|
|
getRefreshToken() // Obtener refresh token
|
|
setTokens(access, refresh) // Guardar tokens
|
|
clearTokens() // Limpiar tokens
|
|
getSessionInfo() // Info de sesion
|
|
setSessionInfo(info) // Guardar info sesion
|
|
isAccessTokenExpired() // Verificar expiracion
|
|
isTokenExpiringSoon() // Expira en 5 min
|
|
getTimeUntilExpiry() // Tiempo restante
|
|
refreshTokenIfNeeded() // Refrescar si necesario
|
|
setupAutoRefresh() // Auto-refresh cada minuto
|
|
decodeToken(token) // Decodificar JWT
|
|
getTokenPayload() // Payload del token
|
|
getUserIdFromToken() // User ID del token
|
|
getUserEmailFromToken() // Email del token
|
|
getUserRoleFromToken() // Role del token
|
|
isValidTokenFormat(token) // Validar formato
|
|
createAuthHeader() // Header Authorization
|
|
handleTokenFromUrl() // OAuth redirect tokens
|
|
validateStoredSession() // Validar sesion guardada
|
|
getExpiryWarningMessage() // Mensaje de expiracion
|
|
}
|
|
```
|
|
|
|
#### PermissionService (`features/auth/services/permissionService.ts`)
|
|
```typescript
|
|
class PermissionService {
|
|
hasPermission(role, permission) // Verificar permiso
|
|
hasAllPermissions(role, permissions) // Todos los permisos
|
|
hasAnyPermission(role, permissions) // Algun permiso
|
|
getRolePermissions(role) // Permisos de rol
|
|
hasRole(userRole, requiredRoles) // Verificar rol
|
|
hasMinimumRole(userRole, minimumRole) // Rol minimo
|
|
getRoleLevel(role) // Nivel de rol
|
|
canManageRole(actorRole, targetRole) // Puede gestionar rol
|
|
getAvailablePermissions(current, target) // Permisos disponibles
|
|
canAccessResource(role, ownerId, userId, permission) // Acceso a recurso
|
|
validatePermissions(role, permissions) // Validar permisos
|
|
getPermissionDescription(permission) // Descripcion permiso
|
|
getRoleDescription(role) // Descripcion rol
|
|
requiresConfirmation(role, permission) // Requiere confirmacion
|
|
getPermissionsByCategory() // Permisos por categoria
|
|
createPermissionMatrix() // Matriz de permisos
|
|
updateRolePermissions(role, permissions) // Actualizar permisos
|
|
addPermissionToRole(role, permission) // Agregar permiso
|
|
removePermissionFromRole(role, permission) // Remover permiso
|
|
}
|
|
```
|
|
|
|
### 1.2 Roles y Permisos Definidos
|
|
|
|
```typescript
|
|
type UserRole = 'user' | 'instructor' | 'admin'
|
|
|
|
type Permission =
|
|
| 'read_courses' | 'write_courses' | 'delete_courses'
|
|
| 'read_users' | 'write_users' | 'delete_users'
|
|
| 'read_signals' | 'write_signals' | 'delete_signals'
|
|
| 'manage_subscriptions' | 'view_analytics' | 'manage_settings'
|
|
```
|
|
|
|
### 1.3 Hooks Disponibles
|
|
|
|
- `useAuth()` - Hook principal de autenticacion
|
|
- `useSession()` - Manejo de sesiones
|
|
- `useProfile()` - Perfil de usuario
|
|
- `usePermissions()` - Verificacion de permisos
|
|
|
|
### 1.4 Paginas Implementadas
|
|
|
|
| Pagina | Ruta | Descripcion |
|
|
|--------|------|-------------|
|
|
| Login | `/login` | Login con email/OAuth |
|
|
| Register | `/register` | Registro con validaciones |
|
|
| ForgotPassword | `/forgot-password` | Solicitar reset |
|
|
| ResetPassword | `/reset-password` | Cambiar password |
|
|
| VerifyEmail | `/verify-email` | Verificacion de email |
|
|
|
|
---
|
|
|
|
## 2. Modulo de Cursos/Educacion
|
|
|
|
### 2.1 Servicios Implementados
|
|
|
|
#### CourseService (`features/courses/services/courseService.ts`)
|
|
```typescript
|
|
class CourseService {
|
|
getCourses(filters, sort, page, perPage) // Listar con filtros
|
|
getCourse(id) // Obtener por ID
|
|
getCourseBySlug(slug) // Obtener por slug
|
|
createCourse(payload) // Crear curso
|
|
updateCourse(payload) // Actualizar curso
|
|
deleteCourse(id) // Eliminar curso
|
|
publishCourse(id) // Publicar curso
|
|
archiveCourse(id) // Archivar curso
|
|
getFeaturedCourses(limit) // Cursos destacados
|
|
getCoursesByCategory(categoryId, limit) // Por categoria
|
|
getSimilarCourses(courseId, limit) // Cursos similares
|
|
searchCourses(query, limit) // Buscar cursos
|
|
getCourseStats(courseId) // Estadisticas
|
|
}
|
|
```
|
|
|
|
#### EnrollmentService (`features/courses/services/enrollmentService.ts`)
|
|
- Inscripcion a cursos
|
|
- Verificacion de acceso
|
|
- Estado de inscripcion
|
|
|
|
#### ProgressService (`features/courses/services/progressService.ts`)
|
|
- Tracking de progreso
|
|
- Completion de lecciones
|
|
- Estadisticas de usuario
|
|
|
|
#### QuizService (`features/courses/services/quizService.ts`)
|
|
- Creacion de quizzes
|
|
- Evaluacion de respuestas
|
|
- Resultados y feedback
|
|
|
|
#### CertificateService (`features/courses/services/certificateService.ts`)
|
|
- Generacion de certificados
|
|
- Verificacion publica
|
|
- Descarga de certificados
|
|
|
|
### 2.2 Filtros de Cursos
|
|
|
|
```typescript
|
|
interface CourseFilters {
|
|
search?: string
|
|
category_id?: string
|
|
level?: 'beginner' | 'intermediate' | 'advanced'
|
|
price_min?: number
|
|
price_max?: number
|
|
rating_min?: number
|
|
has_certificate?: boolean
|
|
is_featured?: boolean
|
|
instructor_id?: string
|
|
status?: 'draft' | 'published' | 'archived'
|
|
tags?: string[]
|
|
}
|
|
```
|
|
|
|
### 2.3 Stores (Zustand)
|
|
|
|
- `courseStore` - Estado de cursos
|
|
- `progressStore` - Progreso de usuario
|
|
- `playerStore` - Reproductor de video
|
|
|
|
### 2.4 Paginas Implementadas
|
|
|
|
| Pagina | Ruta | Descripcion |
|
|
|--------|------|-------------|
|
|
| CoursesList | `/courses` | Catalogo de cursos |
|
|
| CourseDetail | `/courses/:slug` | Detalle de curso |
|
|
| CourseLearning | `/courses/:slug/learn` | Reproductor de curso |
|
|
| MyCourses | `/my-courses` | Mis cursos inscritos |
|
|
| Certificates | `/certificates` | Mis certificados |
|
|
| CertificateVerification | `/certificates/verify/:id` | Verificar certificado |
|
|
|
|
---
|
|
|
|
## 3. Modulo de Trading
|
|
|
|
### 3.1 Servicios Implementados
|
|
|
|
#### SignalService (`features/trading/services/signalService.ts`)
|
|
```typescript
|
|
class SignalService {
|
|
getSignals(filters, page, perPage) // Listar senales
|
|
getSignalById(id) // Detalle de senal
|
|
subscribeToSignals(botIds, callback) // Suscripcion realtime
|
|
unsubscribeFromSignals(subscriptionId) // Desuscribir
|
|
unsubscribeAll() // Desuscribir todo
|
|
executeSignal(signalId, userId, options) // Ejecutar senal
|
|
getUserSignalHistory(userId, page, perPage) // Historial de usuario
|
|
getMockSignals() // Datos mock
|
|
createMockSignal(botId) // Crear mock
|
|
}
|
|
```
|
|
|
|
#### BotService (`features/trading/services/botService.ts`)
|
|
```typescript
|
|
class BotService {
|
|
getBots(filters, page, perPage) // Listar bots
|
|
getBotById(id) // Detalle de bot
|
|
getFeaturedBots(limit) // Bots destacados
|
|
getBotsByDeveloper(developerId) // Bots por developer
|
|
subscribeToBo(botId, userId, settings) // Suscribirse a bot
|
|
getUserBotSubscriptions(userId) // Suscripciones usuario
|
|
cancelSubscription(subscriptionId, userId) // Cancelar suscripcion
|
|
getBotReviews(botId, page, perPage) // Reviews del bot
|
|
createBotReview(botId, userId, review) // Crear review
|
|
getMockBots() // Datos mock
|
|
}
|
|
```
|
|
|
|
#### CopyTradingService (`features/trading/services/copyTradingService.ts`)
|
|
- Copiar operaciones de traders
|
|
- Configuracion de copy trading
|
|
- Estadisticas de copia
|
|
|
|
#### PortfolioService (`features/trading/services/portfolioService.ts`)
|
|
- Gestion de portafolio
|
|
- Posiciones abiertas/cerradas
|
|
- Rendimiento
|
|
|
|
#### TradeHistoryService (`features/trading/services/tradeHistoryService.ts`)
|
|
- Historial de operaciones
|
|
- Filtros y exportacion
|
|
- Estadisticas
|
|
|
|
### 3.2 Tipos de Trading
|
|
|
|
```typescript
|
|
interface TradingSignal {
|
|
id: string
|
|
bot_id: string
|
|
symbol: string
|
|
signal_type: 'buy' | 'sell'
|
|
entry_price: number
|
|
stop_loss: number
|
|
take_profit: number
|
|
confidence: number
|
|
risk_reward_ratio: number
|
|
analysis: string
|
|
tags: string[]
|
|
expires_at: string
|
|
is_executed: boolean
|
|
execution_count: number
|
|
}
|
|
|
|
interface TradingBot {
|
|
id: string
|
|
name: string
|
|
strategy_type: 'scalping' | 'swing' | 'position' | 'arbitrage'
|
|
risk_level: 'low' | 'medium' | 'high'
|
|
subscription_price: number
|
|
performance_metrics: PerformanceMetrics
|
|
configuration: BotConfiguration
|
|
is_verified: boolean
|
|
is_featured: boolean
|
|
is_demo_available: boolean
|
|
}
|
|
```
|
|
|
|
### 3.3 Paginas Implementadas
|
|
|
|
| Pagina | Ruta | Descripcion |
|
|
|--------|------|-------------|
|
|
| Trading | `/trading` | Dashboard de trading |
|
|
| Portfolio | `/trading/portfolio` | Mi portafolio |
|
|
| TradeHistory | `/trading/history` | Historial de trades |
|
|
| BotsMarketplace | `/trading/bots` | Marketplace de bots |
|
|
| BotDetail | `/trading/bots/:id` | Detalle de bot |
|
|
| Signals | `/trading/signals` | Senales de trading |
|
|
| CopyTrading | `/trading/copy-trading` | Copy trading |
|
|
|
|
---
|
|
|
|
## 4. Modulo de Pagos (Stripe)
|
|
|
|
### 4.1 Componentes Principales
|
|
|
|
#### SubscriptionManager
|
|
- Visualizacion de suscripciones
|
|
- Cancelar/reanudar suscripciones
|
|
- Historial de suscripciones
|
|
- Portal de Stripe Customer
|
|
|
|
#### PaymentHistory
|
|
- Tabla de transacciones
|
|
- Filtros avanzados
|
|
- Paginacion
|
|
- Descarga de facturas
|
|
- Exportacion CSV/PDF
|
|
|
|
#### PaymentDashboard
|
|
- Dashboard integrado
|
|
- Balance de creditos
|
|
- Paquetes de creditos
|
|
|
|
### 4.2 Servicios de Pagos
|
|
|
|
#### WebhookService
|
|
Eventos soportados:
|
|
- `payment_intent.succeeded`
|
|
- `payment_intent.payment_failed`
|
|
- `payment_intent.canceled`
|
|
- `checkout.session.completed`
|
|
- `invoice.payment_succeeded`
|
|
- `invoice.payment_failed`
|
|
- `customer.subscription.created`
|
|
- `customer.subscription.updated`
|
|
- `customer.subscription.deleted`
|
|
- `customer.subscription.trial_will_end`
|
|
|
|
#### StripeService
|
|
- `cancelSubscription(subscriptionId, reason)`
|
|
- `updateSubscription(subscriptionId, newPriceId)`
|
|
- `resumeSubscription(subscriptionId)`
|
|
|
|
### 4.3 Hooks de Pagos
|
|
|
|
- `useSubscriptions()` - Gestion de suscripciones
|
|
- `usePaymentHistory()` - Historial de pagos
|
|
- `usePayment()` - Operaciones de pago
|
|
- `useCredits()` - Balance de creditos
|
|
|
|
### 4.4 Paginas Implementadas
|
|
|
|
| Pagina | Ruta | Descripcion |
|
|
|--------|------|-------------|
|
|
| Payments | `/payments` | Dashboard de pagos |
|
|
| Billing | `/billing` | Facturacion |
|
|
| Subscriptions | `/subscriptions` | Mis suscripciones |
|
|
| Invoices | `/invoices` | Facturas |
|
|
| Credits | `/credits` | Balance creditos |
|
|
| Checkout | `/checkout` | Proceso de pago |
|
|
|
|
---
|
|
|
|
## 5. Panel de Administracion
|
|
|
|
### 5.1 Paginas Implementadas
|
|
|
|
| Pagina | Ruta | Descripcion |
|
|
|--------|------|-------------|
|
|
| AdminOverview | `/admin` | Dashboard admin |
|
|
| UsersManagement | `/admin/users` | Gestion usuarios |
|
|
| CoursesManagement | `/admin/courses` | Gestion cursos |
|
|
| CourseEditor | `/admin/courses/:id/edit` | Editor de curso |
|
|
| ModuleEditor | `/admin/courses/:id/modules/:mid` | Editor de modulo |
|
|
| LessonEditor | `/admin/courses/:id/lessons/:lid` | Editor de leccion |
|
|
|
|
### 5.2 Funcionalidades
|
|
|
|
- CRUD de usuarios
|
|
- CRUD de cursos
|
|
- Editor de contenido
|
|
- Estadisticas y reportes
|
|
- Gestion de categorias
|
|
|
|
---
|
|
|
|
## 6. Sistema de Soporte
|
|
|
|
### 6.1 Paginas Implementadas
|
|
|
|
| Pagina | Ruta | Descripcion |
|
|
|--------|------|-------------|
|
|
| HelpCenter | `/help` | Centro de ayuda |
|
|
| Tickets | `/support/tickets` | Tickets de soporte |
|
|
|
|
---
|
|
|
|
## 7. Componentes UI Comunes
|
|
|
|
### Guards (Proteccion de rutas)
|
|
|
|
```typescript
|
|
// AuthGuard - Requiere autenticacion
|
|
// GuestGuard - Solo usuarios no autenticados
|
|
// RoleGuard - Requiere rol especifico
|
|
```
|
|
|
|
### Layouts
|
|
|
|
- `AdminLayout` - Layout para admin panel
|
|
- (otros layouts en development)
|
|
|
|
### UI Components (Shadcn/ui)
|
|
|
|
Componentes base de Radix UI + Tailwind CSS
|
|
|
|
---
|
|
|
|
## 8. Dependencias Clave
|
|
|
|
### Frontend
|
|
```json
|
|
{
|
|
"react": "^18.2.0",
|
|
"react-router-dom": "^6.x",
|
|
"zustand": "^4.4.0",
|
|
"@tanstack/react-query": "^5.0.0",
|
|
"react-hook-form": "^7.48.0",
|
|
"@radix-ui/*": "latest",
|
|
"tailwindcss": "^3.x",
|
|
"@stripe/stripe-js": "^2.x",
|
|
"@supabase/supabase-js": "^2.x"
|
|
}
|
|
```
|
|
|
|
### Base de Datos (Supabase)
|
|
|
|
Schemas:
|
|
- `public` - Usuarios, perfiles
|
|
- `education` - Cursos, modulos, lecciones, quizzes
|
|
- `trading` - Bots, signals, positions
|
|
- `financial` - Transacciones, suscripciones
|
|
- `audit` - Logs de actividad
|
|
|
|
---
|
|
|
|
## 9. Consideraciones para Migracion
|
|
|
|
### Reemplazar Supabase por Express
|
|
|
|
1. **Autenticacion**
|
|
- Supabase Auth → JWT + Passport.js
|
|
- OAuth providers → Configurar manualmente
|
|
- Session management → Redis + JWT refresh tokens
|
|
|
|
2. **Base de datos**
|
|
- Supabase queries → TypeORM/Prisma
|
|
- RPC functions → Express endpoints
|
|
- Realtime → WebSocket/Socket.io
|
|
|
|
3. **Storage**
|
|
- Supabase Storage → S3/MinIO
|
|
- Image uploads → Multer + CDN
|
|
|
|
4. **Webhooks**
|
|
- Mantener logica de Stripe webhooks
|
|
- Adaptar a Express endpoints
|
|
|
|
---
|
|
|
|
## 10. Archivos de Configuracion
|
|
|
|
| Archivo | Descripcion |
|
|
|---------|-------------|
|
|
| `vite.config.ts` | Config de Vite |
|
|
| `tailwind.config.js` | Config de Tailwind |
|
|
| `tsconfig.json` | Config de TypeScript |
|
|
| `.env.example` | Variables de entorno |
|
|
| `package.json` | Dependencias |
|
|
|
|
---
|
|
|
|
## Siguiente Paso
|
|
|
|
Ver [MIGRACION-SUPABASE-EXPRESS.md](./MIGRACION-SUPABASE-EXPRESS.md) para el plan detallado de migracion.
|