# 24shubham12/senior_care architecture

> Architecture diagram of the GitHub repository 24shubham12/senior_care, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-06-15). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/24shubham12/senior_care
- Repository: https://github.com/24shubham12/senior_care

## Overview

##### Project type and purpose
- This is a monolithic, full-stack PHP web application built on the CodeIgniter MVC framework, named “senior_care.”
- It provides two role-based front ends—“admin” and “users”—for managing patient records, prescriptions, uploads, dashboards, etc.

##### Main architectural components
a. Client Layer (Web Browser)
- User and Admin browsers requesting HTML, CSS, JS, images, PDFs.
b. Web Server Layer (Apache / .htaccess)
- Serves static assets directly.
- Forwards PHP requests to the CodeIgniter front controller (index.php).
c. Application Layer (CodeIgniter MVC)
i. Front Controller (index.php + system/core/CodeIgniter.php)
- Bootstraps the framework, loads config, routes.
ii. Router & Controller Classes
- application/controllers/Users.php
- application/controllers/Admin.php
iii. Model Layer
- application/models/PatientDb.php, AdminDb.php
- Interacts with MySQL via system/database/* drivers.
iv. View Layer
- application/views/users/** and application/views/admin/**
- Contains HTML templates + asset subdirectories (css, js, images, scss).
v. Configuration & Services
- application/config/database.php (MySQL)
- application/config/memcached.php (Cache)
- application/config/email/mailer, routes, constants, hooks, etc.
vi. Third-party & Libraries
- SCSS toolchain (bootstrap, custom scss in views)
- JS libraries (jQuery, Chartist, AOS, plugins)
- Composer dependencies (composer.json)
d. Data Layer
- MySQL database (senior_care.sql)
- Memcached for caching session/data
- File storage on server for uploads (application/views/users/asset/uploaded_files).

##### Component interactions & data flow
1. Browser → HTTP request for page or asset
2. Web Server (Apache)
- If static asset → serve file directly
- If PHP route → forward to index.php
3. CodeIgniter Front Controller
→ Load config, router chooses Controller
4. Controller
→ Calls Model to query/update DB or cache
→ Processes business logic
→ Passes data to View
5. View renders HTML + includes CSS/JS links
6. Browser receives response

##### Architectural patterns & principles
- MVC separation: Controllers, Models, Views
- Single front controller (index.php)
- Layered separation: presentation, business, data
- Asset pipeline: SCSS → CSS compiled offline, served as static
- Caching layer abstracted via memcached driver

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Layer
    subgraph "Client Layer"
        direction TB
        BrowserAdmin["Browser - Admin UI"]:::infra
        BrowserUser["Browser - User UI"]:::infra
    end

    %% Web Server Layer
    Apache["Apache Web Server<br/>(.htaccess)"]:::infra
    click Apache "https://github.com/24shubham12/senior_care/blob/main/.htaccess"

    %% Application Layer
    subgraph "Application Layer (CodeIgniter MVC)"
        direction TB

        %% Front Controller & Bootstrap
        FrontController["Front Controller<br/>(index.php)"]:::app
        click FrontController "https://github.com/24shubham12/senior_care/blob/main/index.php"
        Bootstrap["CI Core Bootstrap<br/>(CodeIgniter.php)"]:::app
        click Bootstrap "https://github.com/24shubham12/senior_care/blob/main/system/core/CodeIgniter.php"

        %% Router
        RouterConfig["Routes Config<br/>(routes.php)"]:::app
        click RouterConfig "https://github.com/24shubham12/senior_care/blob/main/application/config/routes.php"
        RouterClass["Router Class<br/>(Router.php)"]:::app
        click RouterClass "https://github.com/24shubham12/senior_care/blob/main/system/core/Router.php"

        %% Controllers
        subgraph "Controllers" 
            direction TB
            UserCtrl["Users Controller<br/>(Users.php)"]:::app
            click UserCtrl "https://github.com/24shubham12/senior_care/blob/main/application/controllers/Users.php"
            AdminCtrl["Admin Controller<br/>(Admin.php)"]:::app
            click AdminCtrl "https://github.com/24shubham12/senior_care/blob/main/application/controllers/Admin.php"
        end

        %% Models
        subgraph "Models"
            direction TB
            PatientModel["PatientDb Model<br/>(PatientDb.php)"]:::app
            click PatientModel "https://github.com/24shubham12/senior_care/blob/main/application/models/PatientDb.php"
            AdminModel["AdminDb Model<br/>(AdminDb.php)"]:::app
            click AdminModel "https://github.com/24shubham12/senior_care/blob/main/application/models/AdminDb.php"
        end

        %% Views
        subgraph "Views"
            direction TB
            UserViews["User Views<br/>(application/views/users/)"]:::app
            click UserViews "https://github.com/24shubham12/senior_care/tree/main/application/views/users/"
            AdminViews["Admin Views<br/>(application/views/admin/)"]:::app
            click AdminViews "https://github.com/24shubham12/senior_care/tree/main/application/views/admin/"
            ErrorViews["Error Views<br/>(application/views/errors/)"]:::app
            click ErrorViews "https://github.com/24shubham12/senior_care/tree/main/application/views/errors/"
        end

        %% Config & Services
        subgraph "Config & Services"
            direction TB
            DBConfig["Database Config<br/>(database.php)"]:::app
            click DBConfig "https://github.com/24shubham12/senior_care/blob/main/application/config/database.php"
            CacheConfig["Memcached Config<br/>(memcached.php)"]:::app
            click CacheConfig "https://github.com/24shubham12/senior_care/blob/main/application/config/memcached.php"
            HooksConfig["Hooks Config<br/>(hooks.php)"]:::app
            click HooksConfig "https://github.com/24shubham12/senior_care/blob/main/application/config/hooks.php"
            Constants["Constants<br/>(constants.php)"]:::app
            click Constants "https://github.com/24shubham12/senior_care/blob/main/application/config/constants.php"
        end

        %% Third-Party & Assets
        subgraph "Third-Party & Assets"
            direction TB
            Composer["Composer Dependencies<br/>(composer.json)"]:::third
            click Composer "https://github.com/24shubham12/senior_care/blob/main/composer.json"
            SharedAssets["Shared Static Assets<br/>(asset/)"]:::third
            click SharedAssets "https://github.com/24shubham12/senior_care/tree/main/application/views/asset/"
            AdminAssets["Admin Assets<br/>(admin/asset/)"]:::third
            click AdminAssets "https://github.com/24shubham12/senior_care/tree/main/application/views/admin/asset/"
            UserAssets["User Assets<br/>(users/asset/)"]:::third
            click UserAssets "https://github.com/24shubham12/senior_care/tree/main/application/views/users/asset/"
            SessionDriver["Session Memcached Driver<br/>(Session_memcached_driver.php)"]:::app
            click SessionDriver "https://github.com/24shubham12/senior_care/blob/main/system/libraries/Session/drivers/Session_memcached_driver.php"
        end

        %% Offline Build
        SCSS["SCSS → CSS Build"]:::third
    end

    %% Data Layer
    MySQL["MySQL Database<br/>(senior_care.sql)"]:::persist
    click MySQL "https://github.com/24shubham12/senior_care/blob/main/senior_care.sql"
    Memcached["Memcached Cache"]:::persist
    FileStorage["File Storage - Uploads"]:::infra

    %% Connections
    BrowserAdmin -->|HTTP/HTTPS| Apache
    BrowserUser -->|HTTP/HTTPS| Apache
    Apache -->|PHP Request| FrontController
    Apache -->|Static Asset| SharedAssets
    Apache -->|Static Asset| AdminAssets
    Apache -->|Static Asset| UserAssets

    FrontController --> Bootstrap
    Bootstrap --> RouterConfig
    Bootstrap --> RouterClass
    RouterClass --> UserCtrl
    RouterClass --> AdminCtrl

    UserCtrl --> PatientModel
    AdminCtrl --> AdminModel
    UserCtrl --> Memcached
    AdminCtrl --> Memcached
    click Memcached "https://github.com/24shubham12/senior_care/blob/main/application/config/memcached.php"
    click Memcached "https://github.com/24shubham12/senior_care/blob/main/system/libraries/Session/drivers/Session_memcached_driver.php"

    PatientModel -->|SQL| MySQL
    AdminModel -->|SQL| MySQL

    UserCtrl --> UserViews
    AdminCtrl --> AdminViews
    UserCtrl --> FileStorage
    AdminCtrl --> FileStorage

    UserViews -->|HTML/CSS/JS| BrowserUser
    AdminViews -->|HTML/CSS/JS| BrowserAdmin

    SCSS --> SharedAssets

    %% Styles
    classDef infra fill:#ADD8E6,stroke:#000
    classDef app fill:#90EE90,stroke:#000
    classDef persist fill:#FFD580,stroke:#000
    classDef third fill:#D3D3D3,stroke:#000
```
