# sam-nisa/project-pp-year4 architecture

> Architecture diagram of the GitHub repository sam-nisa/project-pp-year4, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sam-nisa/project-pp-year4
- Repository: https://github.com/sam-nisa/project-pp-year4

## Overview

This is a digital-book marketplace with customer shopping, checkout and Bakong QR payment, plus author and admin operations for catalog, sales, balances and payouts. Customers browse and manage carts through the Next.js storefront; the backend API creates orders, coordinates payment, and tracks completed sales. Reviews, messaging, author applications, and administrative management are separate capabilities. The graph focuses on documented request paths and model/service responsibilities; unsampled routes and frontend pages are represented by their enclosing directories, and uncertain connections are omitted.

Main entry points: [`backend/routes/api.php`](https://github.com/sam-nisa/project-pp-year4/blob/main/backend/routes/api.php) (API routing), [`backend/app/Http/Controllers/OrderController.php`](https://github.com/sam-nisa/project-pp-year4/blob/main/backend/app/Http/Controllers/OrderController.php) (Order orchestration), [`frontend/app/utils/request.js`](https://github.com/sam-nisa/project-pp-year4/blob/main/frontend/app/utils/request.js) (API request client), [`backend/app/Models/Book.php`](https://github.com/sam-nisa/project-pp-year4/blob/main/backend/app/Models/Book.php) (Books and genres)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_storefront["Customer storefront"]
  node_storefront["Storefront pages"]
  node_frontend_checkout["Checkout flow<br/>[page.jsx]"]
  node_frontend_reviews["Review interface<br/>[ReviewsSection.jsx]"]
  node_payment_ui["QR payment UI<br/>[KHQRModal.jsx]"]
  node_review_ui_store["Review state<br/>[useReviewStore.js]"]
end

subgraph group_commerce["Commerce and payments"]
  node_cart_api["Cart API<br/>[CartController.php]"]
  node_cart_data[("Cart records<br/>[Cart.php]")]
  node_order_api["Order orchestration"]
  node_order_data[("Orders and items<br/>[Order.php]")]
  node_discount_data[("Discount codes<br/>[DiscountCode.php]")]
  node_payment_api["Bakong payment API"]
  node_payment_service["Bakong integration"]
end

subgraph group_accounts["Accounts and catalog"]
  node_auth_ui["Session state<br/>[authStore.js]"]
  node_catalog_api["Catalog API<br/>[BookController.php]"]
  node_catalog_data[("Books and genres<br/>[Book.php]")]
  node_review_api["Review API"]
  node_review_data[("Review records<br/>[Review.php]")]
  node_user_data[("User accounts<br/>[User.php]")]
end

subgraph group_operations["Author and admin operations"]
  node_author_api["Author workflows"]
  node_author_request_api["Author applications"]
  node_payout_api["Payout management"]
  node_payout_service["Payout processing<br/>[PayoutService.php]"]
  node_payout_data[("Balances and payouts<br/>[Payout.php]")]
  node_messages["Messaging"]
  node_telegram["Telegram notifications"]
end

subgraph group_shared["Shared platform"]
  node_client_request["API request client<br/>[request.js]"]
  node_api_routes["API routing<br/>[api.php]"]
  node_image_service["Image storage"]
end

node_customer(("Customer"))
node_bakong{{"Bakong service"}}
node_telegram_service{{"Telegram API"}}
node_imagekit{{"ImageKit"}}

node_customer -->|"browses"| node_storefront
node_customer -->|"checks out"| node_frontend_checkout
node_storefront -.->|"requests data"| node_client_request
node_frontend_checkout -->|"submits checkout"| node_client_request
node_frontend_checkout -->|"opens QR"| node_payment_ui
node_auth_ui -->|"calls API"| node_client_request
node_client_request -->|"sends requests"| node_api_routes
node_api_routes -->|"routes catalog"| node_catalog_api
node_catalog_api -->|"reads and writes"| node_catalog_data
node_api_routes -->|"routes cart"| node_cart_api
node_cart_api -->|"reads and writes"| node_cart_data
node_cart_api -->|"checks books"| node_catalog_data
node_api_routes -->|"routes orders"| node_order_api
node_order_api -->|"reads cart"| node_cart_data
node_order_api -->|"checks inventory"| node_catalog_data
node_order_api -->|"creates orders"| node_order_data
node_order_api -->|"records discounts"| node_discount_data
node_payment_ui -.->|"checks payment"| node_client_request
node_api_routes -->|"routes payments"| node_payment_api
node_payment_api -->|"generates QR"| node_payment_service
node_payment_service -.->|"requests payment"| node_bakong
node_payment_api -->|"finalizes pending order"| node_order_api
node_frontend_reviews -->|"uses review state"| node_review_ui_store
node_review_ui_store -->|"loads and submits"| node_client_request
node_api_routes -->|"routes reviews"| node_review_api
node_review_api -->|"loads book"| node_catalog_data
node_review_api -->|"manages reviews"| node_review_data
node_api_routes -->|"routes author tools"| node_author_api
node_author_api -->|"loads author data"| node_user_data
node_author_api -->|"reads author books"| node_catalog_data
node_api_routes -->|"routes applications"| node_author_request_api
node_author_request_api -->|"uploads documents"| node_image_service
node_api_routes -->|"routes payouts"| node_payout_api
node_payout_api -->|"delegates payout"| node_payout_service
node_payout_api -->|"manages balances"| node_payout_data
node_api_routes -->|"routes messaging"| node_messages
node_order_api -->|"sends payment alerts"| node_telegram
node_telegram -->|"posts messages"| node_telegram_service
node_image_service -.->|"stores images"| node_imagekit

click node_storefront "https://github.com/sam-nisa/project-pp-year4/tree/main/frontend/app/(user)"
click node_frontend_checkout "https://github.com/sam-nisa/project-pp-year4/blob/main/frontend/app/(user)/checkout/page.jsx"
click node_frontend_reviews "https://github.com/sam-nisa/project-pp-year4/blob/main/frontend/app/component/ReviewsSection.jsx"
click node_auth_ui "https://github.com/sam-nisa/project-pp-year4/blob/main/frontend/app/store/authStore.js"
click node_client_request "https://github.com/sam-nisa/project-pp-year4/blob/main/frontend/app/utils/request.js"
click node_api_routes "https://github.com/sam-nisa/project-pp-year4/blob/main/backend/routes/api.php"
click node_catalog_api "https://github.com/sam-nisa/project-pp-year4/blob/main/backend/app/Http/Controllers/BookController.php"
click node_catalog_data "https://github.com/sam-nisa/project-pp-year4/blob/main/backend/app/Models/Book.php"
click node_cart_api "https://github.com/sam-nisa/project-pp-year4/blob/main/backend/app/Http/Controllers/CartController.php"
click node_cart_data "https://github.com/sam-nisa/project-pp-year4/blob/main/backend/app/Models/Cart.php"
click node_order_api "https://github.com/sam-nisa/project-pp-year4/blob/main/backend/app/Http/Controllers/OrderController.php"
click node_order_data "https://github.com/sam-nisa/project-pp-year4/blob/main/backend/app/Models/Order.php"
click node_discount_data "https://github.com/sam-nisa/project-pp-year4/blob/main/backend/app/Models/DiscountCode.php"
click node_payment_ui "https://github.com/sam-nisa/project-pp-year4/blob/main/frontend/app/component/KHQRModal.jsx"
click node_payment_api "https://github.com/sam-nisa/project-pp-year4/blob/main/backend/app/Http/Controllers/BakongPaymentController.php"
click node_payment_service "https://github.com/sam-nisa/project-pp-year4/blob/main/backend/app/Services/BakongPaymentService.php"
click node_review_ui_store "https://github.com/sam-nisa/project-pp-year4/blob/main/frontend/app/store/useReviewStore.js"
click node_review_api "https://github.com/sam-nisa/project-pp-year4/blob/main/backend/app/Http/Controllers/ReviewController.php"
click node_review_data "https://github.com/sam-nisa/project-pp-year4/blob/main/backend/app/Models/Review.php"
click node_user_data "https://github.com/sam-nisa/project-pp-year4/blob/main/backend/app/Models/User.php"
click node_author_api "https://github.com/sam-nisa/project-pp-year4/blob/main/backend/app/Http/Controllers/AuthorDashboardController.php"
click node_author_request_api "https://github.com/sam-nisa/project-pp-year4/blob/main/backend/app/Http/Controllers/AuthorRequestController.php"
click node_payout_api "https://github.com/sam-nisa/project-pp-year4/blob/main/backend/app/Http/Controllers/AdminPayoutController.php"
click node_payout_service "https://github.com/sam-nisa/project-pp-year4/blob/main/backend/app/Services/PayoutService.php"
click node_payout_data "https://github.com/sam-nisa/project-pp-year4/blob/main/backend/app/Models/Payout.php"
click node_messages "https://github.com/sam-nisa/project-pp-year4/blob/main/backend/app/Http/Controllers/MessageController.php"
click node_telegram "https://github.com/sam-nisa/project-pp-year4/blob/main/backend/app/Services/TelegramService.php"
click node_image_service "https://github.com/sam-nisa/project-pp-year4/blob/main/backend/app/Services/ImageKitService.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_storefront,node_frontend_checkout,node_frontend_reviews,node_payment_ui,node_review_ui_store toneBlue
class node_cart_api,node_cart_data,node_order_api,node_order_data,node_discount_data,node_payment_api,node_payment_service toneAmber
class node_auth_ui,node_catalog_api,node_catalog_data,node_review_api,node_review_data,node_user_data,node_telegram_service toneMint
class node_author_api,node_author_request_api,node_payout_api,node_payout_service,node_payout_data,node_messages,node_telegram toneRose
class node_client_request,node_api_routes,node_image_service,node_customer,node_bakong,node_imagekit toneIndigo
```

## Components

### Customer storefront

- [Storefront pages](https://github.com/sam-nisa/project-pp-year4/tree/main/frontend/app/(user)): `frontend/app/(user)`
- [Checkout flow](https://github.com/sam-nisa/project-pp-year4/blob/main/frontend/app/(user)/checkout/page.jsx): `frontend/app/(user)/checkout/page.jsx`
- [Review interface](https://github.com/sam-nisa/project-pp-year4/blob/main/frontend/app/component/ReviewsSection.jsx): `frontend/app/component/ReviewsSection.jsx`
- [QR payment UI](https://github.com/sam-nisa/project-pp-year4/blob/main/frontend/app/component/KHQRModal.jsx): `frontend/app/component/KHQRModal.jsx`
- [Review state](https://github.com/sam-nisa/project-pp-year4/blob/main/frontend/app/store/useReviewStore.js): `frontend/app/store/useReviewStore.js`

### Commerce and payments

- [Cart API](https://github.com/sam-nisa/project-pp-year4/blob/main/backend/app/Http/Controllers/CartController.php): `backend/app/Http/Controllers/CartController.php`
- [Cart records](https://github.com/sam-nisa/project-pp-year4/blob/main/backend/app/Models/Cart.php): `backend/app/Models/Cart.php`
- [Order orchestration](https://github.com/sam-nisa/project-pp-year4/blob/main/backend/app/Http/Controllers/OrderController.php): `backend/app/Http/Controllers/OrderController.php`
- [Orders and items](https://github.com/sam-nisa/project-pp-year4/blob/main/backend/app/Models/Order.php): `backend/app/Models/Order.php`
- [Discount codes](https://github.com/sam-nisa/project-pp-year4/blob/main/backend/app/Models/DiscountCode.php): `backend/app/Models/DiscountCode.php`
- [Bakong payment API](https://github.com/sam-nisa/project-pp-year4/blob/main/backend/app/Http/Controllers/BakongPaymentController.php): `backend/app/Http/Controllers/BakongPaymentController.php`
- [Bakong integration](https://github.com/sam-nisa/project-pp-year4/blob/main/backend/app/Services/BakongPaymentService.php): `backend/app/Services/BakongPaymentService.php`

### Accounts and catalog

- [Session state](https://github.com/sam-nisa/project-pp-year4/blob/main/frontend/app/store/authStore.js): `frontend/app/store/authStore.js`
- [Catalog API](https://github.com/sam-nisa/project-pp-year4/blob/main/backend/app/Http/Controllers/BookController.php): `backend/app/Http/Controllers/BookController.php`
- [Books and genres](https://github.com/sam-nisa/project-pp-year4/blob/main/backend/app/Models/Book.php): `backend/app/Models/Book.php`
- [Review API](https://github.com/sam-nisa/project-pp-year4/blob/main/backend/app/Http/Controllers/ReviewController.php): `backend/app/Http/Controllers/ReviewController.php`
- [Review records](https://github.com/sam-nisa/project-pp-year4/blob/main/backend/app/Models/Review.php): `backend/app/Models/Review.php`
- [User accounts](https://github.com/sam-nisa/project-pp-year4/blob/main/backend/app/Models/User.php): `backend/app/Models/User.php`

### Author and admin operations

- [Author workflows](https://github.com/sam-nisa/project-pp-year4/blob/main/backend/app/Http/Controllers/AuthorDashboardController.php): `backend/app/Http/Controllers/AuthorDashboardController.php`
- [Author applications](https://github.com/sam-nisa/project-pp-year4/blob/main/backend/app/Http/Controllers/AuthorRequestController.php): `backend/app/Http/Controllers/AuthorRequestController.php`
- [Payout management](https://github.com/sam-nisa/project-pp-year4/blob/main/backend/app/Http/Controllers/AdminPayoutController.php): `backend/app/Http/Controllers/AdminPayoutController.php`
- [Payout processing](https://github.com/sam-nisa/project-pp-year4/blob/main/backend/app/Services/PayoutService.php): `backend/app/Services/PayoutService.php`
- [Balances and payouts](https://github.com/sam-nisa/project-pp-year4/blob/main/backend/app/Models/Payout.php): `backend/app/Models/Payout.php`
- [Messaging](https://github.com/sam-nisa/project-pp-year4/blob/main/backend/app/Http/Controllers/MessageController.php): `backend/app/Http/Controllers/MessageController.php`
- [Telegram notifications](https://github.com/sam-nisa/project-pp-year4/blob/main/backend/app/Services/TelegramService.php): `backend/app/Services/TelegramService.php`

### Shared platform

- [API request client](https://github.com/sam-nisa/project-pp-year4/blob/main/frontend/app/utils/request.js): `frontend/app/utils/request.js`
- [API routing](https://github.com/sam-nisa/project-pp-year4/blob/main/backend/routes/api.php): `backend/routes/api.php`
- [Image storage](https://github.com/sam-nisa/project-pp-year4/blob/main/backend/app/Services/ImageKitService.php): `backend/app/Services/ImageKitService.php`

### Other components

- **Customer**
- **Bakong service**
- **Telegram API**
- **ImageKit**

## Connections

- Customer → Storefront pages: browses
- Customer → Checkout flow: checks out
- Storefront pages → API request client: requests data (evidence: `frontend/app/(user)/checkout/page.jsx`)
- Checkout flow → API request client: submits checkout (evidence: `frontend/app/(user)/checkout/page.jsx`)
- Checkout flow → QR payment UI: opens QR (evidence: `frontend/app/(user)/checkout/page.jsx`)
- Session state → API request client: calls API (evidence: `frontend/app/store/authStore.js`)
- API request client → API routing: sends requests (evidence: `frontend/app/utils/request.js`)
- API routing → Catalog API: routes catalog (evidence: `backend/routes/api.php`)
- Catalog API → Books and genres: reads and writes (evidence: `backend/app/Http/Controllers/BookController.php`)
- API routing → Cart API: routes cart (evidence: `backend/routes/api.php`)
- Cart API → Cart records: reads and writes (evidence: `backend/app/Http/Controllers/CartController.php`)
- Cart API → Books and genres: checks books (evidence: `backend/app/Http/Controllers/CartController.php`)
- API routing → Order orchestration: routes orders (evidence: `backend/routes/api.php`)
- Order orchestration → Cart records: reads cart (evidence: `backend/app/Http/Controllers/OrderController.php`)
- Order orchestration → Books and genres: checks inventory (evidence: `backend/app/Http/Controllers/OrderController.php`)
- Order orchestration → Orders and items: creates orders (evidence: `backend/app/Http/Controllers/OrderController.php`)
- Order orchestration → Discount codes: records discounts (evidence: `backend/app/Http/Controllers/OrderController.php`)
- QR payment UI → API request client: checks payment
- API routing → Bakong payment API: routes payments (evidence: `backend/routes/api.php`)
- Bakong payment API → Bakong integration: generates QR (evidence: `backend/app/Http/Controllers/BakongPaymentController.php`)
- Bakong integration → Bakong service: requests payment
- Bakong payment API → Order orchestration: finalizes pending order (evidence: `backend/app/Http/Controllers/BakongPaymentController.php`)
- Review interface → Review state: uses review state (evidence: `frontend/app/component/ReviewsSection.jsx`)
- Review state → API request client: loads and submits (evidence: `frontend/app/store/useReviewStore.js`)
- API routing → Review API: routes reviews (evidence: `backend/routes/api.php`)
- Review API → Books and genres: loads book (evidence: `backend/app/Http/Controllers/ReviewController.php`)
- Review API → Review records: manages reviews (evidence: `backend/app/Http/Controllers/ReviewController.php`)
- API routing → Author workflows: routes author tools (evidence: `backend/routes/api.php`)
- Author workflows → User accounts: loads author data (evidence: `backend/app/Http/Controllers/AuthorDashboardController.php`)
- Author workflows → Books and genres: reads author books (evidence: `backend/app/Http/Controllers/AuthorDashboardController.php`)
- API routing → Author applications: routes applications (evidence: `backend/routes/api.php`)
- Author applications → Image storage: uploads documents (evidence: `backend/app/Http/Controllers/AuthorRequestController.php`)
- API routing → Payout management: routes payouts (evidence: `backend/routes/api.php`)
- Payout management → Payout processing: delegates payout (evidence: `backend/app/Http/Controllers/AdminPayoutController.php`)
- Payout management → Balances and payouts: manages balances (evidence: `backend/app/Http/Controllers/AdminPayoutController.php`)
- API routing → Messaging: routes messaging (evidence: `backend/routes/api.php`)
- Order orchestration → Telegram notifications: sends payment alerts (evidence: `backend/app/Http/Controllers/OrderController.php`)
- Telegram notifications → Telegram API: posts messages (evidence: `backend/app/Services/TelegramService.php`)
- Image storage → ImageKit: stores images
