How imquangthang/pbl4-backend works
Project type and purpose
• This is a Node.js/Express-based web application with both server-side rendered views and a JSON API.
• It follows an MVC (Model-View-Controller) and layered-service architecture, exposing endpoints for doctors, hospitals, users, roles, messages, etc., and uses JWT for authentication.
File-structure analysis
• Top-level
• index.js / src/server.js – application entry points
• .babelrc – ES6+ transpilation config
• package.json – dependencies and scripts (e.g. “npm run dev”)
• src/Config
• viewEngine.js – sets up the template engine for server-side rendering
• src/Middleware
• CORS.js – cross-origin config
• JWTActions.js – token parsing/verification
• src/Routes
• Web.js – routes that render HTML views
• Api.js – JSON API endpoints
• src/Controllers
• One controller per resource (doctorController, userController, etc.) – handle HTTP requests, invoke services
• src/Services
• Business-logic layer (loginRegisterService, userApiService, messageService, etc.)
• JWTService for token issuance and validation
• src/Models
• Database connection (ConnectDB.js), table definitions (CreateTable.js)
• One model per domain entity (Accounts, Appointment, Faculty, Groups, HealthRecord, MedicalRecord, Roles, Message, Group_Role)
• src/Models/index.js – aggregates and exports all models
Insights from README
• Minimal instructions: “dùng ‘npm run dev’ để chạy” (use npm run dev to launch in development mode).