# lehoangluan1/bookstore-fahasa-inspired architecture

> Architecture diagram of the GitHub repository lehoangluan1/bookstore-fahasa-inspired, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/lehoangluan1/bookstore-fahasa-inspired
- Repository: https://github.com/lehoangluan1/bookstore-fahasa-inspired

## Overview

This is a PHP/MySQL bookstore storefront with customer accounts and an administrator back office. A browser request enters at the public front controller, which dispatches to a feature controller; that controller prepares model data and renders a view or returns JSON. The feature branches cover product discovery and reviews, cart/checkout, Q&A, accounts, blog, contact, and administration. The sampled code supports several controller-to-model and rendering links; other feature internals are represented from the file tree and source index, so uncertain links are omitted.

Main entry points: [`public/index.php`](https://github.com/lehoangluan1/bookstore-fahasa-inspired/blob/main/public/index.php) (Request router), [`app/Core/Database.php`](https://github.com/lehoangluan1/bookstore-fahasa-inspired/blob/main/app/Core/Database.php) (MySQL database), [`app/Controllers/QnaController.php`](https://github.com/lehoangluan1/bookstore-fahasa-inspired/blob/main/app/Controllers/QnaController.php) (Questions and answers), [`app/Controllers/ProductController.php`](https://github.com/lehoangluan1/bookstore-fahasa-inspired/blob/main/app/Controllers/ProductController.php) (Product browsing)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Request handling"]
  node_router["Request router<br/>[index.php]"]
end

subgraph group_storefront["Storefront"]
  node_products["Product browsing"]
  node_productmodel["Product catalog<br/>[Product.php]"]
  node_filters["Catalog filters<br/>[Filter.php]"]
  node_reviews["Product reviews<br/>[Review.php]"]
  node_cart["Cart and checkout<br/>[CartController.php]"]
  node_cartmodel["Cart data<br/>[Cart.php]"]
  node_orders["Order records<br/>[Order.php]"]
end

subgraph group_community["Community content"]
  node_qna["Questions and answers<br/>[QnaController.php]"]
  node_questions["Question records<br/>[Question.php]"]
  node_answers["Answer records<br/>[Answer.php]"]
  node_votes["Community votes<br/>[Vote.php]"]
  node_tags["Question tags<br/>[Tag.php]"]
  node_blog["Blog publishing<br/>[BlogController.php]"]
  node_contact["Contact forms"]
end

subgraph group_accounts["Accounts"]
  node_auth["Sign-in and recovery<br/>[AuthController.php]"]
  node_users["Customer accounts<br/>[UserController.php]"]
end

subgraph group_admin["Administration"]
  node_admin["Admin operations"]
  node_adminqna["Moderate Q&amp;A"]
  node_adminusers["Manage users"]
end

subgraph group_infra["Shared infrastructure"]
  node_base["Controller base<br/>[Controller.php]"]
  node_database[("MySQL database<br/>[Database.php]")]
  node_authmw["Access middleware<br/>[AuthMiddleware.php]"]
end

node_visitor(("Browser user"))

node_visitor -->|"requests pages"| node_router
node_router -->|"dispatches"| node_products
node_router -->|"dispatches"| node_cart
node_router -->|"dispatches"| node_qna
node_router -->|"dispatches"| node_blog
node_router -->|"dispatches"| node_contact
node_router -->|"dispatches"| node_auth
node_router -->|"dispatches"| node_users
node_router -->|"dispatches"| node_admin
node_router -->|"dispatches"| node_adminqna
node_router -->|"dispatches"| node_adminusers
node_products -.->|"queries catalog"| node_productmodel
node_products -->|"loads filters"| node_filters
node_products -->|"loads reviews"| node_reviews
node_qna -->|"lists questions"| node_questions
node_qna -->|"creates answers"| node_answers
node_qna -->|"processes votes"| node_votes
node_qna -.->|"loads tags"| node_tags
node_adminqna -->|"requires admin"| node_authmw
node_adminqna -->|"uses Q&amp;A admin model"| node_admin
node_adminusers -->|"requires admin"| node_authmw
node_admin -.->|"guards admin routes"| node_authmw
node_filters -.->|"queries database"| node_database
node_reviews -->|"queries database"| node_database
node_questions -.->|"queries database"| node_database
node_answers -.->|"queries database"| node_database
node_votes -.->|"queries database"| node_database
node_tags -.->|"queries database"| node_database

click node_router "https://github.com/lehoangluan1/bookstore-fahasa-inspired/blob/main/public/index.php"
click node_base "https://github.com/lehoangluan1/bookstore-fahasa-inspired/blob/main/app/Core/Controller.php"
click node_database "https://github.com/lehoangluan1/bookstore-fahasa-inspired/blob/main/app/Core/Database.php"
click node_authmw "https://github.com/lehoangluan1/bookstore-fahasa-inspired/blob/main/app/Core/AuthMiddleware.php"
click node_products "https://github.com/lehoangluan1/bookstore-fahasa-inspired/blob/main/app/Controllers/ProductController.php"
click node_productmodel "https://github.com/lehoangluan1/bookstore-fahasa-inspired/blob/main/app/Models/Product.php"
click node_filters "https://github.com/lehoangluan1/bookstore-fahasa-inspired/blob/main/app/Models/Filter.php"
click node_reviews "https://github.com/lehoangluan1/bookstore-fahasa-inspired/blob/main/app/Models/Review.php"
click node_cart "https://github.com/lehoangluan1/bookstore-fahasa-inspired/blob/main/app/Controllers/CartController.php"
click node_cartmodel "https://github.com/lehoangluan1/bookstore-fahasa-inspired/blob/main/app/Models/Cart.php"
click node_orders "https://github.com/lehoangluan1/bookstore-fahasa-inspired/blob/main/app/Models/Order.php"
click node_qna "https://github.com/lehoangluan1/bookstore-fahasa-inspired/blob/main/app/Controllers/QnaController.php"
click node_questions "https://github.com/lehoangluan1/bookstore-fahasa-inspired/blob/main/app/Models/Question.php"
click node_answers "https://github.com/lehoangluan1/bookstore-fahasa-inspired/blob/main/app/Models/Answer.php"
click node_votes "https://github.com/lehoangluan1/bookstore-fahasa-inspired/blob/main/app/Models/Vote.php"
click node_tags "https://github.com/lehoangluan1/bookstore-fahasa-inspired/blob/main/app/Models/Tag.php"
click node_blog "https://github.com/lehoangluan1/bookstore-fahasa-inspired/blob/main/app/Controllers/BlogController.php"
click node_contact "https://github.com/lehoangluan1/bookstore-fahasa-inspired/blob/main/app/Controllers/ContactController.php"
click node_auth "https://github.com/lehoangluan1/bookstore-fahasa-inspired/blob/main/app/Controllers/AuthController.php"
click node_users "https://github.com/lehoangluan1/bookstore-fahasa-inspired/blob/main/app/Controllers/UserController.php"
click node_admin "https://github.com/lehoangluan1/bookstore-fahasa-inspired/tree/main/app/Controllers/Admin"
click node_adminqna "https://github.com/lehoangluan1/bookstore-fahasa-inspired/blob/main/app/Controllers/Admin/AdminQnaController.php"
click node_adminusers "https://github.com/lehoangluan1/bookstore-fahasa-inspired/blob/main/app/Controllers/Admin/AdminUserController.php"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_router,node_visitor toneBlue
class node_products,node_productmodel,node_filters,node_reviews,node_cart,node_cartmodel,node_orders toneAmber
class node_qna,node_questions,node_answers,node_votes,node_tags,node_blog,node_contact toneMint
class node_auth,node_users toneRose
class node_admin,node_adminqna,node_adminusers toneIndigo
class node_base,node_database,node_authmw toneTeal
```

## Components

### Request handling

- [Request router](https://github.com/lehoangluan1/bookstore-fahasa-inspired/blob/main/public/index.php): `public/index.php`

### Storefront

- [Product browsing](https://github.com/lehoangluan1/bookstore-fahasa-inspired/blob/main/app/Controllers/ProductController.php): `app/Controllers/ProductController.php`
- [Product catalog](https://github.com/lehoangluan1/bookstore-fahasa-inspired/blob/main/app/Models/Product.php): `app/Models/Product.php`
- [Catalog filters](https://github.com/lehoangluan1/bookstore-fahasa-inspired/blob/main/app/Models/Filter.php): `app/Models/Filter.php`
- [Product reviews](https://github.com/lehoangluan1/bookstore-fahasa-inspired/blob/main/app/Models/Review.php): `app/Models/Review.php`
- [Cart and checkout](https://github.com/lehoangluan1/bookstore-fahasa-inspired/blob/main/app/Controllers/CartController.php): `app/Controllers/CartController.php`
- [Cart data](https://github.com/lehoangluan1/bookstore-fahasa-inspired/blob/main/app/Models/Cart.php): `app/Models/Cart.php`
- [Order records](https://github.com/lehoangluan1/bookstore-fahasa-inspired/blob/main/app/Models/Order.php): `app/Models/Order.php`

### Community content

- [Questions and answers](https://github.com/lehoangluan1/bookstore-fahasa-inspired/blob/main/app/Controllers/QnaController.php): `app/Controllers/QnaController.php`
- [Question records](https://github.com/lehoangluan1/bookstore-fahasa-inspired/blob/main/app/Models/Question.php): `app/Models/Question.php`
- [Answer records](https://github.com/lehoangluan1/bookstore-fahasa-inspired/blob/main/app/Models/Answer.php): `app/Models/Answer.php`
- [Community votes](https://github.com/lehoangluan1/bookstore-fahasa-inspired/blob/main/app/Models/Vote.php): `app/Models/Vote.php`
- [Question tags](https://github.com/lehoangluan1/bookstore-fahasa-inspired/blob/main/app/Models/Tag.php): `app/Models/Tag.php`
- [Blog publishing](https://github.com/lehoangluan1/bookstore-fahasa-inspired/blob/main/app/Controllers/BlogController.php): `app/Controllers/BlogController.php`
- [Contact forms](https://github.com/lehoangluan1/bookstore-fahasa-inspired/blob/main/app/Controllers/ContactController.php): `app/Controllers/ContactController.php`

### Accounts

- [Sign-in and recovery](https://github.com/lehoangluan1/bookstore-fahasa-inspired/blob/main/app/Controllers/AuthController.php): `app/Controllers/AuthController.php`
- [Customer accounts](https://github.com/lehoangluan1/bookstore-fahasa-inspired/blob/main/app/Controllers/UserController.php): `app/Controllers/UserController.php`

### Administration

- [Admin operations](https://github.com/lehoangluan1/bookstore-fahasa-inspired/tree/main/app/Controllers/Admin): `app/Controllers/Admin`
- [Moderate Q&A](https://github.com/lehoangluan1/bookstore-fahasa-inspired/blob/main/app/Controllers/Admin/AdminQnaController.php): `app/Controllers/Admin/AdminQnaController.php`
- [Manage users](https://github.com/lehoangluan1/bookstore-fahasa-inspired/blob/main/app/Controllers/Admin/AdminUserController.php): `app/Controllers/Admin/AdminUserController.php`

### Shared infrastructure

- [Controller base](https://github.com/lehoangluan1/bookstore-fahasa-inspired/blob/main/app/Core/Controller.php): `app/Core/Controller.php`
- [MySQL database](https://github.com/lehoangluan1/bookstore-fahasa-inspired/blob/main/app/Core/Database.php): `app/Core/Database.php`
- [Access middleware](https://github.com/lehoangluan1/bookstore-fahasa-inspired/blob/main/app/Core/AuthMiddleware.php): `app/Core/AuthMiddleware.php`

### Other components

- **Browser user**

## Connections

- Browser user → Request router: requests pages (evidence: `public/index.php`)
- Request router → Product browsing: dispatches (evidence: `public/index.php`)
- Request router → Cart and checkout: dispatches (evidence: `public/index.php`)
- Request router → Questions and answers: dispatches (evidence: `public/index.php`)
- Request router → Blog publishing: dispatches (evidence: `public/index.php`)
- Request router → Contact forms: dispatches (evidence: `public/index.php`)
- Request router → Sign-in and recovery: dispatches (evidence: `public/index.php`)
- Request router → Customer accounts: dispatches (evidence: `public/index.php`)
- Request router → Admin operations: dispatches (evidence: `public/index.php`)
- Request router → Moderate Q&A: dispatches (evidence: `public/index.php`)
- Request router → Manage users: dispatches (evidence: `public/index.php`)
- Product browsing → Product catalog: queries catalog
- Product browsing → Catalog filters: loads filters (evidence: `app/Controllers/ProductController.php`)
- Product browsing → Product reviews: loads reviews (evidence: `app/Controllers/ProductController.php`)
- Questions and answers → Question records: lists questions (evidence: `app/Controllers/QnaController.php`)
- Questions and answers → Answer records: creates answers (evidence: `app/Controllers/QnaController.php`)
- Questions and answers → Community votes: processes votes (evidence: `app/Controllers/QnaController.php`)
- Questions and answers → Question tags: loads tags (evidence: `app/Controllers/QnaController.php`)
- Moderate Q&A → Access middleware: requires admin (evidence: `app/Controllers/Admin/AdminQnaController.php`)
- Moderate Q&A → Admin operations: uses Q&A admin model (evidence: `app/Controllers/Admin/AdminQnaController.php`)
- Manage users → Access middleware: requires admin (evidence: `app/Controllers/Admin/AdminUserController.php`)
- Admin operations → Access middleware: guards admin routes (evidence: `app/Controllers/Admin/AdminQnaController.php`)
- Catalog filters → MySQL database: queries database (evidence: `app/Models/Filter.php`)
- Product reviews → MySQL database: queries database (evidence: `app/Models/Review.php`)
- Question records → MySQL database: queries database (evidence: `app/Models/Question.php`)
- Answer records → MySQL database: queries database (evidence: `app/Models/Answer.php`)
- Community votes → MySQL database: queries database (evidence: `app/Models/Vote.php`)
- Question tags → MySQL database: queries database (evidence: `app/Models/Tag.php`)
