How franca26/hospital-app works
Project Type & Purpose
• Full-stack Hospital Management System
• Frontend: React SPA (Vite, Tailwind)
• Backend: Node.js + Express + Sequelize (MariaDB)
• Core features: appointment scheduling, medical record management, doctor availability, user management, in-app & email notifications
Top-Level Components
a. Client / Browser
b. Frontend SPA (“hospital-frontend”)
• Pages, Layouts, UI Components
• Context Providers (Auth, Toast)
• API service (Axios wrapper)
c. API Gateway / Express Server (“hospital-backend/server.js”)
• Route Layer (routes/*.js)
• Controller Layer (controllers/*.js)
• Utils/Services (auth, email, notification, turnoUtils, sync)
• File Upload Handler (Multer → upload/historiales)
• PDF Generator (PDFKit)
d. ORM Layer (Sequelize models/index.js → models/*.js)
e. Relational Database (MariaDB)
f. External Services
• SMTP Mail Server (Nodemailer)
• (Optional) Push / WebSocket notifications
Relationships & Data Flows
• Frontend → HTTP(S) → Express Routes
• Routes → Controllers → Services/Utils
• Controllers → Sequelize ORM → MariaDB
• Controllers → Utils → Nodemailer (SMTP)
• File uploads: Frontend → Express/Multer → /upload/historiales → Stored on disk
• PDF Generation: Controller invokes PDFKit → streams PDF back to client
• Auth Flow: Frontend sends credentials → authController issues JWT → Stored in HTTP-only cookie or localStorage → Subsequent requests carry JWT → auth middleware validates → user context returned
• Notification Flow: Server writes notification record → Frontend polls GET /api/notificaciones or subscribes via WebSocket (if implemented) → user sees Toast
Architectural Patterns & Principles
• Layered (Presentation → API Layer → Business Logic → Data Access)
• MVC-inspired separation (Routes = View, Controllers = Controller, Models = Model)
• Modularization by feature (each entity: Turno, Usuario, Servicio, etc.)
• Single-Page Application for smooth UX
• Stateless API with JWT for easy scaling
• Use of environment variables (.env) to decouple config