# canhnt04/shoesstore architecture

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

- Interactive diagram: https://gitdiagram.com/canhnt04/shoesstore
- Repository: https://github.com/canhnt04/shoesstore

## Overview

##### Main Components
- Admin Module
- Contains its own MVC layers: controllers (e.g., ProductController.php), models (e.g., Database.php), and views (e.g., Header.php).
- Responsible for managing the administrative aspects of the ShoesStore (like product management).
- User Module
- Also separated into MVC components: controllers (e.g., HomeController.php, UserController.php), models (e.g., Database.php, User.php), and views (e.g., Home.php, Login.php, User.php).
- This module handles the end-user functionalities like browsing products, logging in, etc.
- Public Directory
- Configurations
- The config directory holds files that set up the database connection (e.g., ConnectDB.php) and even includes the SQL schema (ShoesStore.sql), which shows how the database is structured to support both admin and user modules.

##### Relationships and Interactions
- Both Admin and User modules share a similar MVC pattern, interacting internally:
- Controllers receive requests, invoke models to retrieve or update data, and then call views to render the appropriate output.
- Both modules likely rely on a common database configuration (ConnectDB.php) to access the ShoesStore.sql database.
- The Public directory is the gateway through which client requests are initially routed, loading static resources and potentially directing PHP requests to the correct controller based on the URL.
- There is a separation of concerns: the administrative/back-end functionality (admin module) is kept distinct from the user-facing/front-end aspects (user module).

##### Architectural Patterns and Technologies
- MVC Pattern: Both the admin and user components are structured with clear separation into controllers, models, and views.
- Full-Stack Web Application: PHP is used for server-side logic, and the public assets (CSS, JavaScript) manage client-side behavior.
- Shared Database: The config directory indicates that both modules depend on a common database configuration and schema, emphasizing centralized data management.
- Static Assets: The public folder organizes CSS, JavaScript, and images, which are vital for building the front-end user experience.

## Diagram (Mermaid)

```mermaid
graph TD
    %% Public Assets and Entry Point
    PA["Public Assets Entry (index.php)"]:::public

    %% Configurations & Database
    subgraph "Configurations & Database"
        CDB["ConnectDB.php"]:::config
        SSQ["ShoesStore.sql"]:::config
    end

    %% Admin Module
    subgraph "Admin Module"
        direction TB
        AC["Admin Controller (ProductController.php)"]:::controller
        AM["Admin Model (Database.php)"]:::model
        AV["Admin View (Header.php)"]:::view
    end

    %% User Module
    subgraph "User Module"
        direction TB
        UC1["User Controller 1 (HomeController.php)"]:::controller
        UC2["User Controller 2 (UserController.php)"]:::controller

        subgraph "User Models"
            direction TB
            UDM["User Database Model (Database.php)"]:::model
            UM["User Model (User.php)"]:::model
        end

        subgraph "User Views"
            direction TB
            UVH["User Home View (Home.php)"]:::view
            UVL["User Login View (Login.php)"]:::view
            UVP["User Profile View (User.php)"]:::view
        end
    end

    %% Public routes to controllers
    PA -->|"Routes"| AC
    PA -->|"Routes"| UC1
    PA -->|"Routes"| UC2

    %% Admin Module MVC Flow
    AC -->|"Calls"| AM
    AM -->|"Renders"| AV
    AC -->|"Uses_DB"| CDB

    %% User Module MVC Flow
    UC1 -->|"Calls"| UDM
    UDM -->|"Renders"| UVH
    UC2 -->|"Calls"| UM
    UM -->|"Renders"| UVP
    UC2 -->|"Calls"| UDM
    UDM -->|"Renders"| UVL
    UC1 -->|"Uses_DB"| CDB
    UC2 -->|"Uses_DB"| CDB

    %% Database Schema Link
    CDB -->|"Defines_Schema"| SSQ

    %% Click Events for Admin Module
    click AC "https://github.com/canhnt04/shoesstore/blob/main/admin/controller/ProductController.php"
    click AM "https://github.com/canhnt04/shoesstore/blob/main/admin/model/Database.php"
    click AV "https://github.com/canhnt04/shoesstore/blob/main/admin/view/Header.php"

    %% Click Events for User Module
    click UC1 "https://github.com/canhnt04/shoesstore/blob/main/user/controller/HomeController.php"
    click UC2 "https://github.com/canhnt04/shoesstore/blob/main/user/controller/UserController.php"
    click UDM "https://github.com/canhnt04/shoesstore/blob/main/user/model/Database.php"
    click UM "https://github.com/canhnt04/shoesstore/blob/main/user/model/User.php"
    click UVH "https://github.com/canhnt04/shoesstore/blob/main/user/view/Home.php"
    click UVL "https://github.com/canhnt04/shoesstore/blob/main/user/view/Login.php"
    click UVP "https://github.com/canhnt04/shoesstore/blob/main/user/view/User.php"

    %% Click Events for Public and Configurations
    click PA "https://github.com/canhnt04/shoesstore/blob/main/public/index.php"
    click CDB "https://github.com/canhnt04/shoesstore/blob/main/config/database/ConnectDB.php"
    click SSQ "https://github.com/canhnt04/shoesstore/blob/main/config/database/ShoesStore.sql"

    %% Class Definitions for Styling
    classDef controller fill:#f9c,stroke:#333,stroke-width:2px;
    classDef model fill:#bbf,stroke:#333,stroke-width:2px;
    classDef view fill:#bfb,stroke:#333,stroke-width:2px;
    classDef config fill:#ff9,stroke:#333,stroke-width:2px;
    classDef public fill:#fbf,stroke:#333,stroke-width:2px;
```
