# yiheng-471/final-year-project architecture

> Architecture diagram of the GitHub repository yiheng-471/final-year-project, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/yiheng-471/final-year-project
- Repository: https://github.com/yiheng-471/final-year-project

## Overview

FYP is a Laravel/Inertia perfume storefront with account and address management, product discovery, cart and Stripe checkout, reviews, and questionnaire-based recommendations. The main customer flow is browser requests through web routes to controllers, which read or update domain models; checkout creates order/payment state before opening Stripe Checkout, with a webhook handling payment events. The tree also contains a separate Python ML directory, but the supplied evidence does not establish how it connects to Laravel. Unsampled page and model internals are represented only where the tree or source index supports them.

Main entry points: [`FYP/routes/web.php`](https://github.com/yiheng-471/final-year-project/blob/main/FYP/routes/web.php) (Web routes), [`FYP/app/Http/Controllers/OrderController.php`](https://github.com/yiheng-471/final-year-project/blob/main/FYP/app/Http/Controllers/OrderController.php) (Order checkout), [`FYP/app/Http/Controllers/Auth/RegisterController.php`](https://github.com/yiheng-471/final-year-project/blob/main/FYP/app/Http/Controllers/Auth/RegisterController.php) (Registration), [`FYP/app/Models/User.php`](https://github.com/yiheng-471/final-year-project/blob/main/FYP/app/Models/User.php) (User account)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["Storefront experience"]
  node_web["Web routes<br/>[web.php]"]
end

subgraph group_commerce["Commerce domain"]
  node_catalog["Product catalog"]
  node_perfume[("Perfume items<br/>[PerfumeItem.php]")]
  node_cart["Cart handling<br/>[CartController.php]"]
  node_cartdata[("Cart records<br/>[Cart.php]")]
  node_cartitem[("Cart items<br/>[CartItem.php]")]
  node_checkout["Order checkout"]
  node_order[("Orders<br/>[Order.php]")]
  node_orderitem[("Order items<br/>[OrderItem.php]")]
  node_payment[("Payments<br/>[Payment.php]")]
  node_stripe_service["Stripe checkout"]
  node_webhook["Payment webhook"]
  node_reviews["Review handling"]
  node_reviewdata[("Perfume reviews<br/>[PerfumeReview.php]")]
end

subgraph group_accounts["Customer accounts"]
  node_auth["Authentication"]
  node_registration["Registration"]
  node_profile["Profile management"]
  node_user[("User account<br/>[User.php]")]
  node_address[("Addresses<br/>[Address.php]")]
  node_state[("States<br/>[State.php]")]
  node_verification["Email verification"]
end

subgraph group_recommendations["Recommendations"]
  node_recommend_controller["Recommendation flow"]
  node_questionnaire["Preference questionnaire"]
  node_recommend_service["Recommendation service"]
  node_preferences[("Questionnaire preferences")]
  node_ml_api["ML API<br/>[api.py]"]
end

node_customer(("Customer"))
node_stripe{{"Stripe"}}

node_customer -->|"requests"| node_web
node_web -->|"routes to"| node_catalog
node_web -->|"routes to"| node_cart
node_web -->|"routes to"| node_checkout
node_web -->|"routes to"| node_webhook
node_web -->|"routes to"| node_reviews
node_web -->|"routes to"| node_auth
node_web -->|"routes to"| node_registration
node_web -->|"routes to"| node_profile
node_web -->|"routes to"| node_verification
node_web -->|"routes to"| node_recommend_controller
node_web -->|"routes to"| node_questionnaire
node_catalog -->|"queries"| node_perfume
node_cart -->|"queries"| node_cartdata
node_cart -->|"updates"| node_cartitem
node_checkout -->|"loads"| node_cartdata
node_checkout -->|"creates"| node_order
node_checkout -->|"inserts"| node_orderitem
node_checkout -->|"creates"| node_payment
node_checkout -->|"opens checkout"| node_stripe_service
node_stripe_service -->|"creates session"| node_stripe
node_webhook -->|"constructs event"| node_stripe_service
node_webhook -->|"updates"| node_payment
node_reviews -->|"checks purchase"| node_order
node_reviews -->|"writes"| node_reviewdata
node_auth -->|"authenticates"| node_user
node_registration -->|"creates"| node_user
node_registration -->|"optionally creates"| node_address
node_registration -->|"loads"| node_state
node_profile -->|"updates"| node_user
node_profile -->|"manages"| node_address
node_verification -->|"verifies"| node_user
node_recommend_controller -->|"calls"| node_recommend_service
node_recommend_controller -->|"queries"| node_perfume
node_recommend_service -->|"reads"| node_preferences
node_questionnaire -.->|"manages"| node_preferences

click node_web "https://github.com/yiheng-471/final-year-project/blob/main/FYP/routes/web.php"
click node_catalog "https://github.com/yiheng-471/final-year-project/blob/main/FYP/app/Http/Controllers/ProductController.php"
click node_perfume "https://github.com/yiheng-471/final-year-project/blob/main/FYP/app/Models/PerfumeItem.php"
click node_cart "https://github.com/yiheng-471/final-year-project/blob/main/FYP/app/Http/Controllers/CartController.php"
click node_cartdata "https://github.com/yiheng-471/final-year-project/blob/main/FYP/app/Models/Cart.php"
click node_cartitem "https://github.com/yiheng-471/final-year-project/blob/main/FYP/app/Models/CartItem.php"
click node_checkout "https://github.com/yiheng-471/final-year-project/blob/main/FYP/app/Http/Controllers/OrderController.php"
click node_order "https://github.com/yiheng-471/final-year-project/blob/main/FYP/app/Models/Order.php"
click node_orderitem "https://github.com/yiheng-471/final-year-project/blob/main/FYP/app/Models/OrderItem.php"
click node_payment "https://github.com/yiheng-471/final-year-project/blob/main/FYP/app/Models/Payment.php"
click node_stripe_service "https://github.com/yiheng-471/final-year-project/blob/main/FYP/app/Services/StripeCheckoutService.php"
click node_webhook "https://github.com/yiheng-471/final-year-project/blob/main/FYP/app/Http/Controllers/StripeWebhookController.php"
click node_reviews "https://github.com/yiheng-471/final-year-project/blob/main/FYP/app/Http/Controllers/ReviewController.php"
click node_reviewdata "https://github.com/yiheng-471/final-year-project/blob/main/FYP/app/Models/PerfumeReview.php"
click node_auth "https://github.com/yiheng-471/final-year-project/blob/main/FYP/app/Http/Controllers/Auth/LoginController.php"
click node_registration "https://github.com/yiheng-471/final-year-project/blob/main/FYP/app/Http/Controllers/Auth/RegisterController.php"
click node_profile "https://github.com/yiheng-471/final-year-project/blob/main/FYP/app/Http/Controllers/ProfileController.php"
click node_user "https://github.com/yiheng-471/final-year-project/blob/main/FYP/app/Models/User.php"
click node_address "https://github.com/yiheng-471/final-year-project/blob/main/FYP/app/Models/Address.php"
click node_state "https://github.com/yiheng-471/final-year-project/blob/main/FYP/app/Models/State.php"
click node_verification "https://github.com/yiheng-471/final-year-project/blob/main/FYP/app/Http/Controllers/VerificationController.php"
click node_recommend_controller "https://github.com/yiheng-471/final-year-project/blob/main/FYP/app/Http/Controllers/RecommendationController.php"
click node_questionnaire "https://github.com/yiheng-471/final-year-project/blob/main/FYP/app/Http/Controllers/QuestionnaireController.php"
click node_recommend_service "https://github.com/yiheng-471/final-year-project/blob/main/FYP/app/Services/RecommendationService.php"
click node_preferences "https://github.com/yiheng-471/final-year-project/blob/main/FYP/app/Models/QuestionnairePreference.php"
click node_ml_api "https://github.com/yiheng-471/final-year-project/blob/main/ml/api.py"

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_web toneBlue
class node_catalog,node_perfume,node_cart,node_cartdata,node_cartitem,node_checkout,node_order,node_orderitem,node_payment,node_stripe_service,node_webhook,node_reviews,node_reviewdata toneAmber
class node_auth,node_registration,node_profile,node_user,node_address,node_state,node_verification toneMint
class node_recommend_controller,node_questionnaire,node_recommend_service,node_preferences,node_ml_api toneRose
class node_customer,node_stripe toneIndigo
```

## Components

### Storefront experience

- [Web routes](https://github.com/yiheng-471/final-year-project/blob/main/FYP/routes/web.php): `FYP/routes/web.php`

### Commerce domain

- [Product catalog](https://github.com/yiheng-471/final-year-project/blob/main/FYP/app/Http/Controllers/ProductController.php): `FYP/app/Http/Controllers/ProductController.php`
- [Perfume items](https://github.com/yiheng-471/final-year-project/blob/main/FYP/app/Models/PerfumeItem.php): `FYP/app/Models/PerfumeItem.php`
- [Cart handling](https://github.com/yiheng-471/final-year-project/blob/main/FYP/app/Http/Controllers/CartController.php): `FYP/app/Http/Controllers/CartController.php`
- [Cart records](https://github.com/yiheng-471/final-year-project/blob/main/FYP/app/Models/Cart.php): `FYP/app/Models/Cart.php`
- [Cart items](https://github.com/yiheng-471/final-year-project/blob/main/FYP/app/Models/CartItem.php): `FYP/app/Models/CartItem.php`
- [Order checkout](https://github.com/yiheng-471/final-year-project/blob/main/FYP/app/Http/Controllers/OrderController.php): `FYP/app/Http/Controllers/OrderController.php`
- [Orders](https://github.com/yiheng-471/final-year-project/blob/main/FYP/app/Models/Order.php): `FYP/app/Models/Order.php`
- [Order items](https://github.com/yiheng-471/final-year-project/blob/main/FYP/app/Models/OrderItem.php): `FYP/app/Models/OrderItem.php`
- [Payments](https://github.com/yiheng-471/final-year-project/blob/main/FYP/app/Models/Payment.php): `FYP/app/Models/Payment.php`
- [Stripe checkout](https://github.com/yiheng-471/final-year-project/blob/main/FYP/app/Services/StripeCheckoutService.php): `FYP/app/Services/StripeCheckoutService.php`
- [Payment webhook](https://github.com/yiheng-471/final-year-project/blob/main/FYP/app/Http/Controllers/StripeWebhookController.php): `FYP/app/Http/Controllers/StripeWebhookController.php`
- [Review handling](https://github.com/yiheng-471/final-year-project/blob/main/FYP/app/Http/Controllers/ReviewController.php): `FYP/app/Http/Controllers/ReviewController.php`
- [Perfume reviews](https://github.com/yiheng-471/final-year-project/blob/main/FYP/app/Models/PerfumeReview.php): `FYP/app/Models/PerfumeReview.php`

### Customer accounts

- [Authentication](https://github.com/yiheng-471/final-year-project/blob/main/FYP/app/Http/Controllers/Auth/LoginController.php): `FYP/app/Http/Controllers/Auth/LoginController.php`
- [Registration](https://github.com/yiheng-471/final-year-project/blob/main/FYP/app/Http/Controllers/Auth/RegisterController.php): `FYP/app/Http/Controllers/Auth/RegisterController.php`
- [Profile management](https://github.com/yiheng-471/final-year-project/blob/main/FYP/app/Http/Controllers/ProfileController.php): `FYP/app/Http/Controllers/ProfileController.php`
- [User account](https://github.com/yiheng-471/final-year-project/blob/main/FYP/app/Models/User.php): `FYP/app/Models/User.php`
- [Addresses](https://github.com/yiheng-471/final-year-project/blob/main/FYP/app/Models/Address.php): `FYP/app/Models/Address.php`
- [States](https://github.com/yiheng-471/final-year-project/blob/main/FYP/app/Models/State.php): `FYP/app/Models/State.php`
- [Email verification](https://github.com/yiheng-471/final-year-project/blob/main/FYP/app/Http/Controllers/VerificationController.php): `FYP/app/Http/Controllers/VerificationController.php`

### Recommendations

- [Recommendation flow](https://github.com/yiheng-471/final-year-project/blob/main/FYP/app/Http/Controllers/RecommendationController.php): `FYP/app/Http/Controllers/RecommendationController.php`
- [Preference questionnaire](https://github.com/yiheng-471/final-year-project/blob/main/FYP/app/Http/Controllers/QuestionnaireController.php): `FYP/app/Http/Controllers/QuestionnaireController.php`
- [Recommendation service](https://github.com/yiheng-471/final-year-project/blob/main/FYP/app/Services/RecommendationService.php): `FYP/app/Services/RecommendationService.php`
- [Questionnaire preferences](https://github.com/yiheng-471/final-year-project/blob/main/FYP/app/Models/QuestionnairePreference.php): `FYP/app/Models/QuestionnairePreference.php`
- [ML API](https://github.com/yiheng-471/final-year-project/blob/main/ml/api.py): `ml/api.py`

### Other components

- **Customer**
- **Stripe**

## Connections

- Customer → Web routes: requests (evidence: `FYP/routes/web.php`)
- Web routes → Product catalog: routes to (evidence: `FYP/routes/web.php`)
- Web routes → Cart handling: routes to (evidence: `FYP/routes/web.php`)
- Web routes → Order checkout: routes to (evidence: `FYP/routes/web.php`)
- Web routes → Payment webhook: routes to (evidence: `FYP/routes/web.php`)
- Web routes → Review handling: routes to (evidence: `FYP/routes/web.php`)
- Web routes → Authentication: routes to (evidence: `FYP/routes/web.php`)
- Web routes → Registration: routes to (evidence: `FYP/routes/web.php`)
- Web routes → Profile management: routes to (evidence: `FYP/routes/web.php`)
- Web routes → Email verification: routes to (evidence: `FYP/routes/web.php`)
- Web routes → Recommendation flow: routes to (evidence: `FYP/routes/web.php`)
- Web routes → Preference questionnaire: routes to (evidence: `FYP/routes/web.php`)
- Product catalog → Perfume items: queries (evidence: `FYP/app/Http/Controllers/ProductController.php`)
- Cart handling → Cart records: queries (evidence: `FYP/app/Http/Controllers/CartController.php`)
- Cart handling → Cart items: updates (evidence: `FYP/app/Http/Controllers/CartController.php`)
- Order checkout → Cart records: loads (evidence: `FYP/app/Http/Controllers/OrderController.php`)
- Order checkout → Orders: creates (evidence: `FYP/app/Http/Controllers/OrderController.php`)
- Order checkout → Order items: inserts (evidence: `FYP/app/Http/Controllers/OrderController.php`)
- Order checkout → Payments: creates (evidence: `FYP/app/Http/Controllers/OrderController.php`)
- Order checkout → Stripe checkout: opens checkout (evidence: `FYP/app/Http/Controllers/OrderController.php`)
- Stripe checkout → Stripe: creates session (evidence: `FYP/app/Services/StripeCheckoutService.php`)
- Payment webhook → Stripe checkout: constructs event (evidence: `FYP/app/Http/Controllers/StripeWebhookController.php`)
- Payment webhook → Payments: updates (evidence: `FYP/app/Http/Controllers/StripeWebhookController.php`)
- Review handling → Orders: checks purchase (evidence: `FYP/app/Http/Controllers/ReviewController.php`)
- Review handling → Perfume reviews: writes (evidence: `FYP/app/Http/Controllers/ReviewController.php`)
- Authentication → User account: authenticates (evidence: `FYP/app/Http/Controllers/Auth/LoginController.php`)
- Registration → User account: creates (evidence: `FYP/app/Http/Controllers/Auth/RegisterController.php`)
- Registration → Addresses: optionally creates (evidence: `FYP/app/Http/Controllers/Auth/RegisterController.php`)
- Registration → States: loads (evidence: `FYP/app/Http/Controllers/Auth/RegisterController.php`)
- Profile management → User account: updates (evidence: `FYP/app/Http/Controllers/ProfileController.php`)
- Profile management → Addresses: manages (evidence: `FYP/app/Http/Controllers/ProfileController.php`)
- Email verification → User account: verifies (evidence: `FYP/app/Http/Controllers/VerificationController.php`)
- Recommendation flow → Recommendation service: calls (evidence: `FYP/app/Http/Controllers/RecommendationController.php`)
- Recommendation flow → Perfume items: queries (evidence: `FYP/app/Http/Controllers/RecommendationController.php`)
- Recommendation service → Questionnaire preferences: reads (evidence: `FYP/app/Services/RecommendationService.php`)
- Preference questionnaire → Questionnaire preferences: manages
