# bhagirath-chauhan/mvc architecture

> Architecture diagram of the GitHub repository bhagirath-chauhan/mvc, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-11-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/bhagirath-chauhan/mvc
- Repository: https://github.com/bhagirath-chauhan/mvc

## Overview

##### Project type and purpose
- This is a monolithic, server-rendered PHP web application following the MVC (Model-View-Controller) pattern.
- The README (“# mvc”) and the file tree (“app/controllers”, “app/models”, “app/views”) confirm it’s a classic PHP MVC project that serves HTML views, handles user authentication, and persists data in a relational database.

##### File structure
Top-level directories and their roles:
- index.php (front controller / single entry point)
- app/
- controllers/: HTTP request handlers (AuthController, HomeController, UserController)
- models/: domain objects and data mappers (User, Message, Country)
- views/: PHP templates, organized by feature and layouts
- core/: framework core classes (Config, Controller base class, Database abstraction)
- common/: shared utilities (Utility.php)
- public/: static assets (CSS, JavaScript)
- db/: SQL scripts (mvc.sql)
- config.php: application configuration

##### README for additional insights
- The project is minimal; the key insight is just that it implements MVC.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client
    Browser("Browser / Client"):::external

    %% Web Server
    WebServer("Web Server\n(Apache/Nginx + PHP Runtime)"):::application

    %% Presentation Layer
    subgraph "Presentation Layer"
        direction TB
        StaticCSS["Static Assets\n(CSS)"]:::presentation
        StaticJS["Static Assets\n(JavaScript)"]:::presentation
        ViewsAuth["Auth Views\n(app/views/auth)"]:::presentation
        ViewHome["Home View\n(app/views/home.php)"]:::presentation
        ViewsUser["User Views\n(app/views/user/)"]:::presentation
        ViewFlash["Flash Message\n(app/views/common/flash_message.php)"]:::presentation
        Layouts["Layouts\n(app/views/layouts/)"]:::presentation
    end

    %% Application Layer
    subgraph "Application Layer"
        direction TB
        FrontController["Front Controller\n(index.php)"]:::application
        ConfigFile["Configuration File\n(config.php)"]:::application
        CoreConfig["core/Config"]:::application
        CoreController["core/Controller"]:::application
        CoreDatabase["core/Database"]:::application
        AuthCtrl["AuthController"]:::application
        HomeCtrl["HomeController"]:::application
        UserCtrl["UserController"]:::application
        Utility["Utility Functions\n(common/Utility.php)"]:::application
    end

    %% Data Layer
    subgraph "Data Layer"
        direction TB
        UserModel["User Model\n(app/models/User.php)"]:::data
        MessageModel["Message Model\n(app/models/Message.php)"]:::data
        CountryModel["Country Model\n(app/models/Country.php)"]:::data
        Database[(MySQL Database)]:::data
        SchemaScript["DB Schema Script\n(db/mvc.sql)"]:::data
    end

    %% Others
    README["README.md"]:::external
    HTAccess[".htaccess\n(Rewrite Rules)"]:::application

    %% Connections
    Browser -->|request| WebServer
    Browser -->|fetch| StaticCSS
    Browser -->|fetch| StaticJS

    WebServer -->|rewrite| FrontController
    WebServer -->|serves .htaccess| HTAccess

    FrontController -->|load config| ConfigFile
    ConfigFile --> CoreConfig
    FrontController --> CoreConfig
    FrontController --> CoreController
    FrontController --> CoreDatabase
    FrontController -->|route| AuthCtrl
    FrontController -->|route| HomeCtrl
    FrontController -->|route| UserCtrl

    AuthCtrl --> Utility
    HomeCtrl --> Utility
    UserCtrl --> Utility

    AuthCtrl --> UserModel
    HomeCtrl --> MessageModel
    UserCtrl --> UserModel
    UserCtrl --> CountryModel

    UserModel --> CoreDatabase
    MessageModel --> CoreDatabase
    CountryModel --> CoreDatabase
    CoreDatabase --> Database
    SchemaScript --> Database

    AuthCtrl --> ViewsAuth
    HomeCtrl --> ViewHome
    UserCtrl --> ViewsUser
    AuthCtrl --> ViewFlash
    HomeCtrl --> ViewFlash
    UserCtrl --> ViewFlash
    ViewHome --> Browser
    ViewsAuth --> Browser
    ViewsUser --> Browser
    ViewFlash --> Browser
    Layouts --> ViewsAuth
    Layouts --> ViewHome
    Layouts --> ViewsUser

    %% Click Events
    click FrontController "https://github.com/bhagirath-chauhan/mvc/blob/main/index.php"
    click ConfigFile "https://github.com/bhagirath-chauhan/mvc/blob/main/config.php"
    click CoreConfig "https://github.com/bhagirath-chauhan/mvc/blob/main/core/Config.php"
    click CoreController "https://github.com/bhagirath-chauhan/mvc/blob/main/core/Controller.php"
    click CoreDatabase "https://github.com/bhagirath-chauhan/mvc/blob/main/core/Database.php"
    click AuthCtrl "https://github.com/bhagirath-chauhan/mvc/blob/main/app/controllers/AuthController.php"
    click HomeCtrl "https://github.com/bhagirath-chauhan/mvc/blob/main/app/controllers/HomeController.php"
    click UserCtrl "https://github.com/bhagirath-chauhan/mvc/blob/main/app/controllers/UserController.php"
    click UserModel "https://github.com/bhagirath-chauhan/mvc/blob/main/app/models/User.php"
    click MessageModel "https://github.com/bhagirath-chauhan/mvc/blob/main/app/models/Message.php"
    click CountryModel "https://github.com/bhagirath-chauhan/mvc/blob/main/app/models/Country.php"
    click ViewsAuth "https://github.com/bhagirath-chauhan/mvc/blob/main/app/views/auth/index.php"
    click ViewHome "https://github.com/bhagirath-chauhan/mvc/blob/main/app/views/home.php"
    click ViewsUser "https://github.com/bhagirath-chauhan/mvc/tree/main/app/views/user/"
    click ViewFlash "https://github.com/bhagirath-chauhan/mvc/blob/main/app/views/common/flash_message.php"
    click Layouts "https://github.com/bhagirath-chauhan/mvc/tree/main/app/views/layouts/"
    click Utility "https://github.com/bhagirath-chauhan/mvc/blob/main/common/Utility.php"
    click StaticCSS "https://github.com/bhagirath-chauhan/mvc/tree/main/public/css/"
    click StaticJS "https://github.com/bhagirath-chauhan/mvc/tree/main/public/js/"
    click SchemaScript "https://github.com/bhagirath-chauhan/mvc/blob/main/db/mvc.sql"
    click HTAccess "https://github.com/bhagirath-chauhan/mvc/blob/main/.htaccess"
    click README "https://github.com/bhagirath-chauhan/mvc/blob/main/README.md"

    %% Styles
    classDef presentation fill:#add8e6,stroke:#333,stroke-width:1px
    classDef application fill:#90ee90,stroke:#333,stroke-width:1px
    classDef data fill:#ffcc80,stroke:#333,stroke-width:1px
    classDef external fill:#cccccc,stroke:#333,stroke-width:1px
```
