Plataforma educativa MERN con backend en Express + MongoDB y frontend en React + Vite + Tailwind.
- Backend estable con seguridad, auth por roles, gamificacion, notificaciones y realtime con Socket.io.
- Frontend con rediseno global Glassmorphism (landing, auth, dashboard, profile).
- Flujo full-stack de captura de leads activo en la landing (
POST /api/public/leads).
- Node.js, Express, Mongoose
- JWT (access + refresh)
- Helmet, CORS, rate-limit, xss-clean, mongo-sanitize
- Socket.io
- Jest + Supertest + mongodb-memory-server
- React + Vite
- Tailwind CSS
- Framer Motion
- Axios
- React Router
Patron por capas:
Request -> Route -> Controller -> Service -> Repository -> MongoDB
- Route: declara endpoint + middlewares
- Controller: capa HTTP delgada
- Service: negocio
- Repository: acceso a datos
- Model: esquema de persistencia
platform-creative/
app.js
server.js
routes/
controllers/
services/
repositories/
models/
tests/
docs/
client/
src/
pages/
components/
context/
api/
Backend (raiz, archivo .env):
MONGODB_URI(obligatoria)PORT(opcional, default:10000)JWT_SECREToJWT_ACCESS_SECRET+JWT_REFRESH_SECRETCORS_ORIGINS(opcional, separados por coma)
Frontend (opcional, client/.env):
VITE_API_BASE_URL(default:http://localhost:10000/api)
npm install
npm startBackend disponible en:
- API base:
http://localhost:10000/api - Health:
http://localhost:10000/health - Swagger UI:
http://localhost:10000/api-docs
cd client
npm install
npm run devFrontend disponible en:
http://localhost:5173
npm start: inicia backendnpm run dev: backend en watchnpm run seed: siembra datos inicialesnpm test: tests backendnpm run test:watch: tests en watchnpm run test:coverage: cobertura backendnpm run socket:test: prueba manual de socket client
npm run dev: entorno local Vitenpm run lint: lint frontendnpm run build: build produccion frontendnpm run preview: preview del build
POST /api/auth/registerPOST /api/auth/loginPOST /api/auth/refreshPOST /api/auth/logout
GET /api/student/subjectsGET /api/student/recommendations/review
POST /api/public/leads- payload:
email(string, requerido)source(string, opcional, defaultlanding)metadata(object, opcional)
- payload:
Implementacion full-stack activa:
- Frontend: componente
LeadCaptureen landing (estado, validacion, loading, success/error). - Backend: flujo Route -> Controller -> Service -> Repository -> Model (
Lead).
Comportamiento:
- Primer registro de email: crea lead (
201). - Email repetido: responde exitoso con
alreadyRegistered: true.
Eventos principales:
NEW_NOTIFICATIONNEW_FEEDBACK
Flujo:
- Cliente conecta con JWT.
- Middleware valida token.
- Socket queda vinculado a
userId. - Servicios emiten eventos dirigidos.
npm test- Ejecuta suites unitarias e integracion del backend.
- Integracion usa
mongodb-memory-server.
Cobertura:
npm run test:coverageWorkflow en .github/workflows/node.js.yml para push y pull_request sobre main.
- Si el frontend cambia a otro puerto (por ejemplo 5174), incluye el origen en
CORS_ORIGINSo usa la configuracion por defecto ya permitida. - Si
:10000esta ocupado, libera el proceso antes de reiniciar backend. - La documentacion OpenAPI en
docs/openapi.yamles referencial y puede requerir sincronizacion de version/base path con endpoints actuales.
MIT.