# milemise/his-hospital architecture

> Architecture diagram of the GitHub repository milemise/his-hospital, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-13). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/milemise/his-hospital
- Repository: https://github.com/milemise/his-hospital

## Overview

##### Project type and purpose
- From the file tree and the minimal README (“his-hospital”), this is a monolithic, full-stack web application—a Hospital Information System (HIS).
- It uses Node.js/Express for the backend, Sequelize for ORM/migrations/seed data, and Pug templates + static assets for the frontend.
- Core use cases: user authentication/authorization, patient admission, bed assignment, room management, nurse and patient workflows.

##### File structure
- Top-level files:
- app.js – application entry point, ties together server, middleware, routes.
- config/ – database (Sequelize) and server (Express) configurations.
- controllers/ – MVC controllers for auth, bed, nurse, patient logic.
- routes/ – Express route modules mapping URLs to controller actions.
- models/, migrations/, seeders/ – Sequelize models, schema migrations, demo data.
- views/ – Pug templates, organized by feature (autorizacion, camas, pacientes), plus shared layouts.
- public/ – client‐side static assets (CSS, JS).
- Pattern: MVC (Model–View–Controller) with a relational DB and server-rendered views.

##### README for insights
- README is terse, only project name. We infer tech stack from directories: Node.js, Express, Sequelize, Pug.

##### Essential architectural elements to capture
- app.js bootstrapping Express & middleware
- Route modules routing URLs to controller methods
- Controllers invoking Sequelize models
- Migrations & seeders managing DB schema & initial data
- Pug view rendering pipeline
- Static asset serving
- Database connection & transactional boundaries

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client/Presentation Layer
    subgraph "Client/Presentation Layer"
        Browser["Browser"]:::frontend
        subgraph "Static Assets"
            CSS["style.css"]:::frontend
            JS["main.js"]:::frontend
        end
        subgraph "Pug Templates"
            AuthViews["views/autorizacion/"]:::frontend
            BedViews["views/camas/"]:::frontend
            PatientViews["views/pacientes/"]:::frontend
            LayoutView["views/layouts/main.pug"]:::frontend
        end
    end

    %% Server/Application Layer
    subgraph "Server/Application Layer"
        Express["Express App (app.js)"]:::backend
        Middleware["Middleware"]:::backend
        subgraph "Routes"
            IndexRoute["routes/index.js"]:::backend
            AuthRoute["routes/autorizacionRoutes.js"]:::backend
            BedRoute["routes/camaRoutes.js"]:::backend
            PatientRoute["routes/pacientesRoutes.js"]:::backend
        end
        subgraph "Controllers"
            AuthCtrl["authController.js"]:::backend
            BedCtrl["bedController.js"]:::backend
            NurseCtrl["nurseController.js"]:::backend
            PatientCtrl["patientController.js"]:::backend
        end
    end

    %% Data Layer
    subgraph "Data Layer"
        subgraph "Sequelize Models"
            UserModel["models/User.js"]:::data
            PatientModel["models/Patient.js"]:::data
            BedModel["models/Bed.js"]:::data
            RoomModel["models/Room.js"]:::data
            AdmissionModel["models/Admission.js"]:::data
        end
        subgraph "Migrations"
            Mig1["migrations/1-create-user.js"]:::data
            Mig2["migrations/2-create-patient.js"]:::data
            Mig3["migrations/3-create-bed.js"]:::data
        end
        subgraph "Seeders"
            Seed1["seeders/1-demo-users.js"]:::data
            Seed2["seeders/2-demo-rooms.js"]:::data
        end
        DB["Database"]:::data
    end

    %% Connections
    Browser -->|HTTP GET/POST| Express
    Express --> Middleware
    Middleware --> IndexRoute
    IndexRoute --> AuthRoute
    IndexRoute --> BedRoute
    IndexRoute --> PatientRoute
    AuthRoute --> AuthCtrl
    BedRoute --> BedCtrl
    PatientRoute --> PatientCtrl
    AuthCtrl --> UserModel
    BedCtrl --> BedModel
    BedCtrl --> RoomModel
    PatientCtrl --> PatientModel
    PatientCtrl --> AdmissionModel
    UserModel -->|SELECT/INSERT| DB
    PatientModel -->|SELECT/INSERT| DB
    BedModel -->|SELECT/INSERT| DB
    RoomModel -->|SELECT/INSERT| DB
    AdmissionModel -->|SELECT/INSERT| DB
    Mig1 --> DB
    Mig2 --> DB
    Mig3 --> DB
    Seed1 --> DB
    Seed2 --> DB
    Express -->|"serve"| CSS
    Express -->|"serve"| JS
    AuthCtrl -->|"render"| AuthViews
    BedCtrl -->|"render"| BedViews
    PatientCtrl -->|"render"| PatientViews
    AuthCtrl -->|"render"| LayoutView
    BedCtrl -->|"render"| LayoutView
    PatientCtrl -->|"render"| LayoutView

    %% Click Events
    click CSS "https://github.com/milemise/his-hospital/blob/main/public/css/style.css"
    click JS "https://github.com/milemise/his-hospital/blob/main/public/jss/main.js"
    click AuthViews "https://github.com/milemise/his-hospital/tree/main/views/autorizacion/"
    click BedViews "https://github.com/milemise/his-hospital/tree/main/views/camas/"
    click PatientViews "https://github.com/milemise/his-hospital/tree/main/views/pacientes/"
    click LayoutView "https://github.com/milemise/his-hospital/blob/main/views/layouts/main.pug"
    click Express "https://github.com/milemise/his-hospital/blob/main/app.js"
    click IndexRoute "https://github.com/milemise/his-hospital/blob/main/routes/index.js"
    click AuthRoute "https://github.com/milemise/his-hospital/blob/main/routes/autorizacionRoutes.js"
    click BedRoute "https://github.com/milemise/his-hospital/blob/main/routes/camaRoutes.js"
    click PatientRoute "https://github.com/milemise/his-hospital/blob/main/routes/pacientesRoutes.js"
    click AuthCtrl "https://github.com/milemise/his-hospital/blob/main/controllers/authController.js"
    click BedCtrl "https://github.com/milemise/his-hospital/blob/main/controllers/bedController.js"
    click NurseCtrl "https://github.com/milemise/his-hospital/blob/main/controllers/nurseController.js"
    click PatientCtrl "https://github.com/milemise/his-hospital/blob/main/controllers/patientController.js"
    click UserModel "https://github.com/milemise/his-hospital/blob/main/models/User.js"
    click PatientModel "https://github.com/milemise/his-hospital/blob/main/models/Patient.js"
    click BedModel "https://github.com/milemise/his-hospital/blob/main/models/Bed.js"
    click RoomModel "https://github.com/milemise/his-hospital/blob/main/models/Room.js"
    click AdmissionModel "https://github.com/milemise/his-hospital/blob/main/models/Admission.js"
    click Mig1 "https://github.com/milemise/his-hospital/blob/main/migrations/1-create-user.js"
    click Mig2 "https://github.com/milemise/his-hospital/blob/main/migrations/2-create-patient.js"
    click Mig3 "https://github.com/milemise/his-hospital/blob/main/migrations/3-create-bed.js"
    click Seed1 "https://github.com/milemise/his-hospital/blob/main/seeders/1-demo-users.js"
    click Seed2 "https://github.com/milemise/his-hospital/blob/main/seeders/2-demo-rooms.js"

    %% Styles
    classDef frontend fill:#D6EAF8,stroke:#3498DB,color:#1B4F72
    classDef backend fill:#D5F5E3,stroke:#27AE60,color:#145A32
    classDef data fill:#FCF3CF,stroke:#F1C40F,color:#7D6608
```
