How thegodlessman/educativaapi-teg works
Project Type and Purpose
• This is a monolithic, backend-only REST API built with Node.js and Express.
• Its primary responsibilities are: user management, profile handling, room management, test administration, and file uploads (via Cloudinary).
File Structure
• src/index.js: the Express app entry point.
• src/routes/**/*.js: route definitions that map HTTP endpoints to controller actions.
• src/controllers/**/*.js: business-logic handlers for each resource (users, profiles, rooms, tests, Cloudinary).
• src/middleware: auth (JWT validation) and format (response shaping).
• src/helpers: utility functions (token generation, bcrypt wrappers, code generators).
• src/db.js & educativaDB.sql: database connection setup and schema.
• src/cloudinary.js & multer.js: file-upload configuration and Cloudinary SDK integration.
• src/config.js: environment/configuration variables.
Out the System
a. Main Components
• Client(s): e.g., web SPA, mobile app, or API tester.
• API Gateway (Express server in src/index.js).
• Route Layer (src/routes).
• Controller Layer (src/controllers).
• Middleware Layer (src/middleware).
• Helper/Service Layer (src/helpers, multer.js, cloudinary.js).
• Database (MySQL/Postgres via src/db.js and educativeDB.sql).
• External Service: Cloudinary for image/file storage.
b. Relationships and Interactions
• Client → Express → Route → Middleware → Controller.
• Controllers → Helpers (generateToken, handleBcrypt, generateCode).
• Controllers → DB module → Database.
• Controllers → Cloudinary SDK → Cloudinary.
c. Architectural Patterns
• Layered (HTTP Layer → Routing → Business Logic → Data Access).
• MVC‐ish separation between routes (V), controllers (C), and models/DB (M).
• Use of middleware for cross-cutting concerns (auth, formatting).
d. Key Technologies & Frameworks
• Node.js, Express.js
• JWT for authentication
• bcrypt for password hashing
• Multer + Cloudinary SDK for file uploads
• MySQL/Postgres (educativaDB.sql)
• dotenv/config for environment variables