# solimanshady/qatan architecture

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

- Interactive diagram: https://gitdiagram.com/solimanshady/qatan
- Repository: https://github.com/solimanshady/qatan

## Overview

##### Project type and purpose
- This is a monolithic PHP-based single-vendor e-commerce web application (“qatan”) built on a custom MVC framework.
- It provides storefront functionality, admin dashboard, payment integration, email/SMS notifications and basic file uploads.

##### File structure
- application/
- controller.php (front controller), model.php, view.php (core MVC dispatcher)
- controllers/ (account, admin, ajax, api, error, home)
- models/ and views/ (templates for admin, AJAX, public pages)
- config/ (database, pagination, SMS, SMTP, Stripe, upload)
- includes/ (global config, constants, functions, settings)
- index.php (entry point) and .htaccess / web.config (URL rewrite)
- css/, js/, images/, sound/, fonts (static assets served by the web server)
- uploads/ (user- and product-uploaded files)
- libraries/ (PHPMailer, messagebird SMS, payment libraries, geoplugin)
- db/ (MySQL dump)
- sessions/ (custom session handler)

##### Key insights from README
- Custom MVC framework
- Uses minimal dependencies
- Requires database setup, base URL configuration

##### Main components and their interactions
a. Client Browser
- Loads HTML/CSS/JS assets, interacts via HTTP/HTTPS
b. Web Server (Apache/IIS)
- Serves static assets (css, js, images)
- Forwards dynamic requests to index.php/front controller
c. MVC Application Layer
- index.php → core.php dispatches to application/controller.php
- Controller selects Model for data, calls application/models
- Model interacts with MySQL DB via config/database.php
- Controller calls View to render HTML using application/views
d. Database (MySQL)
- Stores products, orders, customers, settings
e. File Storage
- uploads/ for product and user files
- logs, session files in sessions/
f. External Services
- SMTP (PHPMailer via libraries/mail/phpmailer) for email
- SMS gateway (MessageBird via libraries/sms/messagebird)
- Payment gateway (Stripe via config/stripe.php and libraries/payments)
- Geolocation API (geoplugin in libraries/geoplugin)

##### Architectural patterns & design principles
- Custom MVC (separation of concerns: controllers, models, views)
- Front controller pattern (index.php central dispatcher)
- Configuration-driven (all credentials/settings in config/ and includes/)
- Modular libraries folder for third-party and custom integrations

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Layer
    Browser["Client Browser"]:::public
    Browser -->|HTTP/HTTPS| WebServer

    %% Web Server Layer
    subgraph "Web Server"   
        direction TB
        StaticAssets["Static Assets (css/, js/, images/, sound/, fonts)"]:::public
        FrontController["Front Controller<br/>index.php"]:::core
    end
    WebServer["Apache / IIS"]:::public
    WebServer --> StaticAssets
    WebServer --> FrontController
    FrontController -->|dispatch| CoreMVC

    click FrontController "https://github.com/solimanshady/qatan/blob/master/index.php"

    %% Application Layer
    subgraph "MVC Application" 
        direction TB
        CoreMVC["Core MVC Dispatcher<br/>core.php"]:::core
        ControllerModule["Controller Module<br/>application/controller.php"]:::core
        ModelModule["Model Module<br/>application/model.php"]:::core
        ViewModule["View Module<br/>application/view.php"]:::core

        Controllers["Controllers<br/>(home, account, admin, ajax, api, error)"]:::core
        ModelsDir["Models Directory<br/>application/models/"]:::core
        ViewsGroup["Views (public, ajax, admin)"]:::core

        CoreMVC --> ControllerModule
        ControllerModule --> Controllers
        ControllerModule --> ModelModule
        ModelModule --> ModelsDir
        ControllerModule --> ViewModule
        ViewModule --> ViewsGroup
    end

    click CoreMVC "https://github.com/solimanshady/qatan/blob/master/core.php"
    click ControllerModule "https://github.com/solimanshady/qatan/blob/master/application/controller.php"
    click ModelModule "https://github.com/solimanshady/qatan/blob/master/application/model.php"
    click ViewModule "https://github.com/solimanshady/qatan/blob/master/application/view.php"

    click Controllers "https://github.com/solimanshady/qatan/blob/master/application/controllers/home.php"
    click Controllers "https://github.com/solimanshady/qatan/blob/master/application/controllers/account.php"
    click Controllers "https://github.com/solimanshady/qatan/blob/master/application/controllers/admin.php"
    click Controllers "https://github.com/solimanshady/qatan/blob/master/application/controllers/ajax.php"
    click Controllers "https://github.com/solimanshady/qatan/blob/master/application/controllers/api.php"
    click Controllers "https://github.com/solimanshady/qatan/blob/master/application/controllers/error.php"

    click ModelsDir "https://github.com/solimanshady/qatan/tree/master/application/models/"
    
    click ViewsGroup "https://github.com/solimanshady/qatan/blob/master/application/views/index.php"
    click ViewsGroup "https://github.com/solimanshady/qatan/blob/master/application/views/login.php"
    click ViewsGroup "https://github.com/solimanshady/qatan/blob/master/application/views/payments.php"
    click ViewsGroup "https://github.com/solimanshady/qatan/blob/master/application/views/terms.php"
    click ViewsGroup "https://github.com/solimanshady/qatan/blob/master/application/views/forget.php"
    click ViewsGroup "https://github.com/solimanshady/qatan/blob/master/application/views/badbrowser.php"
    click ViewsGroup "https://github.com/solimanshady/qatan/blob/master/application/views/error.php"
    click ViewsGroup "https://github.com/solimanshady/qatan/blob/master/application/views/ajax/data.php"
    click ViewsGroup "https://github.com/solimanshady/qatan/blob/master/application/views/ajax/menus.php"
    click ViewsGroup "https://github.com/solimanshady/qatan/blob/master/application/views/admin/index.php"
    click ViewsGroup "https://github.com/solimanshady/qatan/blob/master/application/views/admin/products.php"
    click ViewsGroup "https://github.com/solimanshady/qatan/blob/master/application/views/admin/orders.php"
    click ViewsGroup "https://github.com/solimanshady/qatan/blob/master/application/views/admin/settings.php"
    click ViewsGroup "https://github.com/solimanshady/qatan/blob/master/application/views/admin/stripe.php"
    click ViewsGroup "https://github.com/solimanshady/qatan/blob/master/application/views/admin/smtp.php"
    click ViewsGroup "https://github.com/solimanshady/qatan/blob/master/application/views/admin/sms.php"

    FrontController --> ConfigFiles
    CoreMVC --> ConfigFiles

    subgraph "Configuration" 
        direction TB
        ConfigFiles["Config Files"]:::core
    end

    click ConfigFiles "https://github.com/solimanshady/qatan/blob/master/config/database.php"
    click ConfigFiles "https://github.com/solimanshady/qatan/blob/master/config/pagination.php"
    click ConfigFiles "https://github.com/solimanshady/qatan/blob/master/config/sms.php"
    click ConfigFiles "https://github.com/solimanshady/qatan/blob/master/config/smtp.php"
    click ConfigFiles "https://github.com/solimanshady/qatan/blob/master/config/stripe.php"
    click ConfigFiles "https://github.com/solimanshady/qatan/blob/master/config/upload.php"
    click ConfigFiles "https://github.com/solimanshady/qatan/blob/master/config/autoload.php"

    subgraph "Global Includes"
        direction TB
        Includes["Includes"]:::core
    end
    CoreMVC --> Includes
    click Includes "https://github.com/solimanshady/qatan/blob/master/includes/config.php"
    click Includes "https://github.com/solimanshady/qatan/blob/master/includes/constants.php"
    click Includes "https://github.com/solimanshady/qatan/blob/master/includes/functions.php"
    click Includes "https://github.com/solimanshady/qatan/blob/master/includes/settings.php"

    %% Persistence Layer
    subgraph "Persistence" 
        direction TB
        MySQLDB["MySQL Database"]:::persistence
        FileStorage["File Storage<br/>uploads/, logs"]:::persistence
        SessionStore["Session Storage<br/>sessions/"]:::persistence
    end
    ModelModule --> MySQLDB
    ControllerModule --> FileStorage
    FrontController --> SessionStore

    click MySQLDB "https://github.com/solimanshady/qatan/blob/master/db/Database backup (August 25, 2021 at 01,39 PM).sql"
    click FileStorage "https://github.com/solimanshady/qatan/tree/master/uploads/images/"
    click FileStorage "https://github.com/solimanshady/qatan/tree/master/uploads/products/"
    click SessionStore "https://github.com/solimanshady/qatan/blob/master/sessions/index.php"

    %% External Services
    subgraph "External Services"
        direction TB
        SMTP["Email Service<br/>SMTP"]:::external
        SMS["SMS Gateway"]:::external
        Payment["Payment Gateway<br/>Stripe & others"]:::external
        GeoAPI["Geolocation API"]:::external
    end
    ControllerModule --> SMTP
    ControllerModule --> SMS
    ControllerModule --> Payment
    ControllerModule --> GeoAPI

    click SMTP "https://github.com/solimanshady/qatan/tree/master/libraries/mail/phpmailer/"
    click SMS "https://github.com/solimanshady/qatan/tree/master/libraries/sms/messagebird/"
    click Payment "https://github.com/solimanshady/qatan/tree/master/libraries/payments/"
    click GeoAPI "https://github.com/solimanshady/qatan/tree/master/libraries/geoplugin/"

    %% Interactions
    Browser -->|loads assets| StaticAssets
    Browser -->|dynamic request| FrontController
    FrontController -->|calls| ControllerModule
    Controllers -->|uses| ModelModule
    Controllers -->|renders| ViewModule

    %% Legend Styles
    classDef public fill:#E0F7FA,stroke:#006064,color:#004D40
    classDef core fill:#E8F5E9,stroke:#1B5E20,color:#2E7D32
    classDef persistence fill:#FFF3E0,stroke:#E65100,color:#BF360C
    classDef external fill:#ECEFF1,stroke:#37474F,color:#263238
```
