How ysohaarsh/hospital_management_system works
Project Type and Purpose
• This is a web-based hospital management system. Its purpose is to provide functionalities for managing hospital processes such as doctor management, appointment scheduling, chat communication, complaints handling, employee management, user authentication (login, signup, reset/set password), and receipt generation.
• It is a full-stack web application built using Node.js/Express (backend), MySQL (database), and EJS for templating (front-end view rendering). The design also incorporates client-side elements (HTML, CSS, JavaScript) residing mainly under the “public” directory.
File Structure
• Key directories:
• controllers: Holds individual route handlers and business logic for features (e.g., add_doctor.js, appointment.js, chat.js, etc.).
• models: Contains database connection logic (db_controller.js) that interfaces with MySQL.
• views: Contains EJS templates used for rendering dynamic HTML pages (e.g., home.ejs, login.ejs, signup.ejs, etc.).
• public: Contains static assets (CSS, fonts, JavaScript, images, and even a separate “182 Medico -DOC” subdirectory that seems to deliver a front-end theme).
• Other important files include app.js (the entry-point that sets up Express, middleware, and routing) and nodelogin.sql (SQL script to create the required database).
README for Additional Insights
• The README highlights the system architecture, explaining various features and the overall workflow (sign up, verify, login, book appointments, etc.).
• It details configuration steps for the database and email service.
a. Main Components:
• Client/User Interface: This includes static assets and EJS views served from the “public” and “views” directories.
• Web Server (Backend Application):
• app.js serves as the main entry point.
• Controllers (in the “controllers” directory) handle business logic for various functionalities (doctor, appointment, chat, complaint, etc.).
• Models (in the “models” directory) manage database operations via MySQL.
• Database: MySQL, represented by the nodelogin.sql schema and managed via the models.
• External Services:
• Email service (via nodemailer) for user verification, password reset, etc.
• Static Content Delivery: The “public” directory includes themes, CSS, images, and client-side JavaScript scripts.
b. Relationships and Interactions:
• The user interacts with the front-end (EJS generated views along with static files) rendered by Express.
• HTTP requests hit the server’s routes (defined in app.js) and are then mapped to various controllers.
• Each controller processes business logic, possibly interacting with the database through the model (db_controller.js) and with external services (like an email transporter).
• The controllers then render responses via EJS views, sending back HTML or JSON responses as needed.
• There is a clear data flow: Client → Web Server (Express: middleware, controllers) → Database (and vice versa) → Client.
c. Architectural Patterns and Design Principles:
• MVC Pattern: Although not explicitly separated, controllers (business logic), models (data access), and views (EJS templates) follow a loosely MVC-style pattern.
• Separation of Concerns: Different controllers handle discrete functionality (user authentication, appointment scheduling, chat, etc.).
• Modularity: Files and directories are organized by feature (each controller handles a specific area) and resource type (static assets, SQL file).
• Integration with external services like an email server for verification.
d. Relevant Technologies, Frameworks, and Libraries:
• Node.js and Express for the server and routing.
• MySQL as the database.
• EJS for dynamic HTML generation.
• Nodemailer (as indicated in the signup/readme snippet) for sending verification emails.
• Various front-end libraries and frameworks visible under the “public/assets”, “public/css”, “public/js”, and the “182 Medico -DOC” folder.
• From Controllers to Models (data queries and updates).
• From Controllers to Email Service (for verification or alerts).
• Rectangles for components.
• Circles for external services.
• Important configuration points (such as the database setup in db_controller.js and email settings in the signup controller).