# imxsquash/polissage-lending-v2 architecture

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

- Interactive diagram: https://gitdiagram.com/imxsquash/polissage-lending-v2
- Repository: https://github.com/imxsquash/polissage-lending-v2

## Overview

##### Project type and purpose
- This is a small full-stack PHP/JavaScript web application (“Polissage Lending v2”) for presenting automotive polishing training content.
- It uses PHP for routing and server-side rendering, JavaScript for interactive UI, and a Python script to generate or initialize JSON-based test data.

##### File structure
- Top-level
- composer.json (PHP dependencies)
- data/ (JSON files act as the data store: articles.json, courses.json, gallery.json, reviews.json)
- public/ (web-root containing index.php, CSS, JS, .htaccess)
- python/ (init_data.py for dev-only data generation)
- src/ (application code)
- src/
- config/config.php (application configuration)
- controllers/HomeController.php (handles incoming requests, invokes services)
- services/DataService.php (reads/writes JSON files, business logic)
- utils/Router.php (parses URLs and dispatches to appropriate controller)
- utils/ViewRenderer.php (renders PHP view templates)
- views/ (server-side templates, split into pages/ and components/)
- render.yaml (possibly build or deployment config)

- Architectural pattern: lightweight MVC. No external database—uses JSON files as datastore.

##### Extract additional insights from README
- Backend: PHP 8+
- Frontend: HTML/CSS served by PHP, JS for carousels and animations
- Python: only for generating test data in development
- Deployment: can run on PHP’s built-in server or any Apache/Nginx

a. Main components
1. Client/browser (requests, renders HTML/CSS/JS)
2. Web server (Apache/Nginx or PHP built-in)
3. Router (src/utils/Router.php)
4. Controllers (HomeController.php)
5. Services (DataService.php reading JSON files)
6. ViewRenderer (templates in src/views/)
7. Data store (JSON files under data/)
8. Static assets (public/css, public/js)
9. Python data generator (python/init_data.py)
b. Relationships and data flow
- Browser → HTTP request → Web server → index.php
- index.php → Router → Controller
- Controller → DataService → JSON data
- Controller → ViewRenderer → HTML
- HTML + CSS + JS → Browser
- Python script ↔ JSON files (only in dev workflow)
c. Architectural patterns / design principles
- MVC-style separation (Router, Controller, View)
- Single-source JSON datastore (no RDBMS)
- Clear separation between static assets and dynamic rendering
- Single entry point (public/index.php)
d. Key technologies
- PHP 8.0+, Composer
- JavaScript for UI interactivity
- Python 3.6+ (dev data generation)
- JSON files as datastore
- Apache/Nginx or PHP built-in server

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Frontend (Client/Browser)"
        direction TB
        Browser["Browser"]:::frontend
        CSS["style.css"]:::frontend
        JS["main.js"]:::frontend
    end

    %% Server / Entry Point
    subgraph "Web Server"
        direction TB
        Index["index.php"]:::backend
        HTAccess[".htaccess"]:::backend
    end

    %% Backend Application
    subgraph "Backend Application (PHP)"
        direction TB
        Config["config.php"]:::config
        Router["Router"]:::backend
        Controller["HomeController"]:::backend
        Service["DataService"]:::backend
        ViewRenderer["ViewRenderer"]:::backend

        subgraph "Views"
            direction TB
            HomePage["home.php"]:::backend
            ArticleCard["article-card.php"]:::backend
            FormationCard["formation-card.php"]:::backend
            GoogleReviewCard["google-review-card.php"]:::backend
            Header["header.php"]:::backend
            Footer["footer.php"]:::backend
            ReviewCard["review-card.php"]:::backend
        end
    end

    %% Data Store
    subgraph "Data Store (JSON Files)"
        direction TB
        Articles["articles.json"]:::datastore
        Courses["courses.json"]:::datastore
        Gallery["gallery.json"]:::datastore
        Reviews["reviews.json"]:::datastore
    end

    %% Development Tooling
    subgraph "Dev Tools"
        direction TB
        Python["init_data.py"]:::devtool
        RenderConfig["render.yaml"]:::config
    end

    %% Data Flow
    Browser -->|"HTTP Request"| Index
    Index -->|"uses"| Router
    Router -->|"routes to"| Controller
    Controller -->|"fetches data via"| Service
    Service -->|"reads/writes"| Articles
    Service -->|"reads/writes"| Courses
    Service -->|"reads/writes"| Gallery
    Service -->|"reads/writes"| Reviews
    Service -->|"returns data to"| Controller
    Controller -->|"renders via"| ViewRenderer
    ViewRenderer -->|"uses templates"| HomePage
    ViewRenderer -->|"uses components"| ArticleCard
    ViewRenderer -->|"uses components"| FormationCard
    ViewRenderer -->|"uses components"| GoogleReviewCard
    ViewRenderer -->|"uses components"| Header
    ViewRenderer -->|"uses components"| Footer
    ViewRenderer -->|"uses components"| ReviewCard
    ViewRenderer -->|"outputs HTML"| Index
    Index -->|"HTTP Response"| Browser

    Python -.->|"dev generates data in"| Articles
    Python -.-> Courses
    Python -.-> Gallery
    Python -.-> Reviews

    %% Click Events
    click CSS "https://github.com/imxsquash/polissage-lending-v2/blob/main/public/css/style.css"
    click JS "https://github.com/imxsquash/polissage-lending-v2/blob/main/public/js/main.js"
    click Index "https://github.com/imxsquash/polissage-lending-v2/blob/main/public/index.php"
    click HTAccess "https://github.com/imxsquash/polissage-lending-v2/blob/main/public/.htaccess"
    click Router "https://github.com/imxsquash/polissage-lending-v2/blob/main/src/utils/Router.php"
    click Controller "https://github.com/imxsquash/polissage-lending-v2/blob/main/src/controllers/HomeController.php"
    click Service "https://github.com/imxsquash/polissage-lending-v2/blob/main/src/services/DataService.php"
    click ViewRenderer "https://github.com/imxsquash/polissage-lending-v2/blob/main/src/utils/ViewRenderer.php"
    click HomePage "https://github.com/imxsquash/polissage-lending-v2/blob/main/src/views/pages/home.php"
    click ArticleCard "https://github.com/imxsquash/polissage-lending-v2/blob/main/src/views/components/article-card.php"
    click FormationCard "https://github.com/imxsquash/polissage-lending-v2/blob/main/src/views/components/formation-card.php"
    click GoogleReviewCard "https://github.com/imxsquash/polissage-lending-v2/blob/main/src/views/components/google-review-card.php"
    click Header "https://github.com/imxsquash/polissage-lending-v2/blob/main/src/views/components/header.php"
    click Footer "https://github.com/imxsquash/polissage-lending-v2/blob/main/src/views/components/footer.php"
    click ReviewCard "https://github.com/imxsquash/polissage-lending-v2/blob/main/src/views/components/review-card.php"
    click Config "https://github.com/imxsquash/polissage-lending-v2/blob/main/src/config/config.php"
    click RenderConfig "https://github.com/imxsquash/polissage-lending-v2/blob/main/render.yaml"
    click Articles "https://github.com/imxsquash/polissage-lending-v2/blob/main/data/articles.json"
    click Courses "https://github.com/imxsquash/polissage-lending-v2/blob/main/data/courses.json"
    click Gallery "https://github.com/imxsquash/polissage-lending-v2/blob/main/data/gallery.json"
    click Reviews "https://github.com/imxsquash/polissage-lending-v2/blob/main/data/reviews.json"
    click Python "https://github.com/imxsquash/polissage-lending-v2/blob/main/python/init_data.py"

    %% Styles
    classDef frontend fill:#E0F7FA,stroke:#006064,color:#004D40
    classDef backend fill:#E8F5E9,stroke:#2E7D32,color:#1B5E20
    classDef datastore fill:#FFF3E0,stroke:#EF6C00,color:#E65100
    classDef devtool fill:#F3E5F5,stroke:#6A1B9A,color:#4A148C
    classDef config fill:#ECEFF1,stroke:#546E7A,color:#263238
```
