# hueyzaa/carsaleswebsitesystem architecture

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

- Interactive diagram: https://gitdiagram.com/hueyzaa/carsaleswebsitesystem
- Repository: https://github.com/hueyzaa/carsaleswebsitesystem

## Overview

Car Sales Website System is a role-based servlet application for browsing and selling cars, with staff and admin operations. The customer path spans discovery, cart and checkout, order handling, and payment; authentication, promotions, and email are supporting capabilities. DAOs persist application data through the shared JDBC connection pool. The map combines README-level capability links with relationships shown in indexed source references; unsampled controller-to-service calls are marked dashed and unverified.

Main entry points: [`src/main/java/util/DBContext.java`](https://github.com/hueyzaa/carsaleswebsitesystem/blob/master/src/main/java/util/DBContext.java) (Connection pool), [`src/main/java/controller/customer/AuthServlet.java`](https://github.com/hueyzaa/carsaleswebsitesystem/blob/master/src/main/java/controller/customer/AuthServlet.java) (Authentication), [`src/main/java/dao/CarDAO.java`](https://github.com/hueyzaa/carsaleswebsitesystem/blob/master/src/main/java/dao/CarDAO.java) (Car and brand data), [`src/main/java/controller/admin`](https://github.com/hueyzaa/carsaleswebsitesystem/tree/master/src/main/java/controller/admin) (Admin tools)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web workflows"]
  node_catalog["Car discovery"]
  node_cartcheckout["Cart and checkout"]
  node_orders["Order handling"]
  node_payments["Payment endpoints"]
  node_adminops["Admin tools"]
  node_staffops["Staff tools"]
  node_auth["Authentication<br/>[AuthServlet.java]"]
  node_oauth["Google OAuth"]
end

subgraph group_business["Business services"]
  node_checkoutservice["Checkout logic"]
  node_promotionservice["Promotion logic"]
  node_orderservice["Order service<br/>[OrderService.java]"]
  node_vnpay["VNPay integration<br/>[VNPayService.java]"]
  node_email["Email service<br/>[EmailService.java]"]
end

subgraph group_persistence["Persistence"]
  node_catalogdao["Car and brand data<br/>[CarDAO.java]"]
  node_cartdao["Cart data<br/>[CartDAO.java]"]
  node_promotiondao["Promotion data<br/>[PromotionDAO.java]"]
  node_orderdao["Orders and transactions<br/>[OrdersDAO.java]"]
  node_authdao["Identity data<br/>[AuthDAO.java]"]
end

subgraph group_platform["Identity and safeguards"]
  node_dbcontext["Connection pool<br/>[DBContext.java]"]
  node_session["Session utilities<br/>[SessionUtils.java]"]
  node_filters["Access and security filters"]
end

node_customer(("Customer"))
node_admin(("Admin"))
node_staff(("Staff"))
node_sqlserver[("SQL Server")]
node_google["Google identity"]
node_vnpayservice["VNPay"]

node_customer -->|"browses"| node_catalog
node_customer -->|"checks out"| node_cartcheckout
node_cartcheckout -.->|"delegates to"| node_checkoutservice
node_checkoutservice -->|"reads cart"| node_cartdao
node_checkoutservice -->|"requests discounts"| node_promotionservice
node_customer -->|"manages orders"| node_orders
node_orders -.->|"uses"| node_orderservice
node_orderservice -.->|"loads order data"| node_orderdao
node_customer -->|"pays"| node_payments
node_payments -.->|"uses"| node_vnpay
node_vnpay -->|"communicates with"| node_vnpayservice
node_customer -->|"signs in"| node_auth
node_auth -->|"accesses identity data"| node_authdao
node_auth -->|"sends notifications"| node_email
node_auth -->|"manages session"| node_session
node_customer -->|"uses optional login"| node_oauth
node_oauth -->|"exchanges identity"| node_google
node_oauth -->|"looks up account"| node_authdao
node_promotionservice -->|"loads promotions"| node_promotiondao
node_promotionservice -->|"loads cars"| node_catalogdao
node_admin -->|"manages catalog"| node_adminops
node_staff -->|"manages inventory"| node_staffops
node_adminops -->|"updates cars"| node_catalogdao
node_adminops -->|"manages promotions"| node_promotiondao
node_staffops -->|"updates cars"| node_catalogdao
node_catalogdao -->|"gets connections"| node_dbcontext
node_cartdao -.->|"gets connections"| node_dbcontext
node_promotiondao -->|"gets connections"| node_dbcontext
node_orderdao -->|"gets connections"| node_dbcontext
node_authdao -->|"gets connections"| node_dbcontext
node_dbcontext -->|"opens JDBC connections"| node_sqlserver
node_filters -.->|"guards requests"| node_auth

click node_catalog "https://github.com/hueyzaa/carsaleswebsitesystem/tree/master/src/main/java/controller/customer"
click node_cartcheckout "https://github.com/hueyzaa/carsaleswebsitesystem/blob/master/src/main/java/controller/customer/CheckoutServlet.java"
click node_orders "https://github.com/hueyzaa/carsaleswebsitesystem/tree/master/src/main/java/controller/customer"
click node_payments "https://github.com/hueyzaa/carsaleswebsitesystem/blob/master/src/main/java/controller/customer/PaymentServlet.java"
click node_adminops "https://github.com/hueyzaa/carsaleswebsitesystem/tree/master/src/main/java/controller/admin"
click node_staffops "https://github.com/hueyzaa/carsaleswebsitesystem/tree/master/src/main/java/controller/staff"
click node_auth "https://github.com/hueyzaa/carsaleswebsitesystem/blob/master/src/main/java/controller/customer/AuthServlet.java"
click node_oauth "https://github.com/hueyzaa/carsaleswebsitesystem/blob/master/src/main/java/controller/customer/GoogleOAuthServlet.java"
click node_checkoutservice "https://github.com/hueyzaa/carsaleswebsitesystem/blob/master/src/main/java/service/CheckoutService.java"
click node_promotionservice "https://github.com/hueyzaa/carsaleswebsitesystem/blob/master/src/main/java/service/PromotionService.java"
click node_orderservice "https://github.com/hueyzaa/carsaleswebsitesystem/blob/master/src/main/java/service/OrderService.java"
click node_vnpay "https://github.com/hueyzaa/carsaleswebsitesystem/blob/master/src/main/java/service/VNPayService.java"
click node_email "https://github.com/hueyzaa/carsaleswebsitesystem/blob/master/src/main/java/service/EmailService.java"
click node_catalogdao "https://github.com/hueyzaa/carsaleswebsitesystem/blob/master/src/main/java/dao/CarDAO.java"
click node_cartdao "https://github.com/hueyzaa/carsaleswebsitesystem/blob/master/src/main/java/dao/CartDAO.java"
click node_promotiondao "https://github.com/hueyzaa/carsaleswebsitesystem/blob/master/src/main/java/dao/PromotionDAO.java"
click node_orderdao "https://github.com/hueyzaa/carsaleswebsitesystem/blob/master/src/main/java/dao/OrdersDAO.java"
click node_authdao "https://github.com/hueyzaa/carsaleswebsitesystem/blob/master/src/main/java/dao/AuthDAO.java"
click node_dbcontext "https://github.com/hueyzaa/carsaleswebsitesystem/blob/master/src/main/java/util/DBContext.java"
click node_session "https://github.com/hueyzaa/carsaleswebsitesystem/blob/master/src/main/java/util/SessionUtils.java"
click node_filters "https://github.com/hueyzaa/carsaleswebsitesystem/tree/master/src/main/java/filter"

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_catalog,node_cartcheckout,node_orders,node_payments,node_adminops,node_staffops,node_auth,node_oauth toneBlue
class node_checkoutservice,node_promotionservice,node_orderservice,node_vnpay,node_email,node_sqlserver toneAmber
class node_catalogdao,node_cartdao,node_promotiondao,node_orderdao,node_authdao toneMint
class node_dbcontext,node_session,node_filters toneRose
class node_customer,node_admin,node_staff,node_google,node_vnpayservice toneIndigo
```

## Components

### Web workflows

- [Car discovery](https://github.com/hueyzaa/carsaleswebsitesystem/tree/master/src/main/java/controller/customer): `src/main/java/controller/customer`
- [Cart and checkout](https://github.com/hueyzaa/carsaleswebsitesystem/blob/master/src/main/java/controller/customer/CheckoutServlet.java): `src/main/java/controller/customer/CheckoutServlet.java`
- [Order handling](https://github.com/hueyzaa/carsaleswebsitesystem/tree/master/src/main/java/controller/customer): `src/main/java/controller/customer`
- [Payment endpoints](https://github.com/hueyzaa/carsaleswebsitesystem/blob/master/src/main/java/controller/customer/PaymentServlet.java): `src/main/java/controller/customer/PaymentServlet.java`
- [Admin tools](https://github.com/hueyzaa/carsaleswebsitesystem/tree/master/src/main/java/controller/admin): `src/main/java/controller/admin`
- [Staff tools](https://github.com/hueyzaa/carsaleswebsitesystem/tree/master/src/main/java/controller/staff): `src/main/java/controller/staff`
- [Authentication](https://github.com/hueyzaa/carsaleswebsitesystem/blob/master/src/main/java/controller/customer/AuthServlet.java): `src/main/java/controller/customer/AuthServlet.java`
- [Google OAuth](https://github.com/hueyzaa/carsaleswebsitesystem/blob/master/src/main/java/controller/customer/GoogleOAuthServlet.java): `src/main/java/controller/customer/GoogleOAuthServlet.java`

### Business services

- [Checkout logic](https://github.com/hueyzaa/carsaleswebsitesystem/blob/master/src/main/java/service/CheckoutService.java): `src/main/java/service/CheckoutService.java`
- [Promotion logic](https://github.com/hueyzaa/carsaleswebsitesystem/blob/master/src/main/java/service/PromotionService.java): `src/main/java/service/PromotionService.java`
- [Order service](https://github.com/hueyzaa/carsaleswebsitesystem/blob/master/src/main/java/service/OrderService.java): `src/main/java/service/OrderService.java`
- [VNPay integration](https://github.com/hueyzaa/carsaleswebsitesystem/blob/master/src/main/java/service/VNPayService.java): `src/main/java/service/VNPayService.java`
- [Email service](https://github.com/hueyzaa/carsaleswebsitesystem/blob/master/src/main/java/service/EmailService.java): `src/main/java/service/EmailService.java`

### Persistence

- [Car and brand data](https://github.com/hueyzaa/carsaleswebsitesystem/blob/master/src/main/java/dao/CarDAO.java): `src/main/java/dao/CarDAO.java`
- [Cart data](https://github.com/hueyzaa/carsaleswebsitesystem/blob/master/src/main/java/dao/CartDAO.java): `src/main/java/dao/CartDAO.java`
- [Promotion data](https://github.com/hueyzaa/carsaleswebsitesystem/blob/master/src/main/java/dao/PromotionDAO.java): `src/main/java/dao/PromotionDAO.java`
- [Orders and transactions](https://github.com/hueyzaa/carsaleswebsitesystem/blob/master/src/main/java/dao/OrdersDAO.java): `src/main/java/dao/OrdersDAO.java`
- [Identity data](https://github.com/hueyzaa/carsaleswebsitesystem/blob/master/src/main/java/dao/AuthDAO.java): `src/main/java/dao/AuthDAO.java`

### Identity and safeguards

- [Connection pool](https://github.com/hueyzaa/carsaleswebsitesystem/blob/master/src/main/java/util/DBContext.java): `src/main/java/util/DBContext.java`
- [Session utilities](https://github.com/hueyzaa/carsaleswebsitesystem/blob/master/src/main/java/util/SessionUtils.java): `src/main/java/util/SessionUtils.java`
- [Access and security filters](https://github.com/hueyzaa/carsaleswebsitesystem/tree/master/src/main/java/filter): `src/main/java/filter`

### Other components

- **Customer**
- **Admin**
- **Staff**
- **SQL Server**
- **Google identity**
- **VNPay**

## Connections

- Customer → Car discovery: browses
- Customer → Cart and checkout: checks out
- Cart and checkout → Checkout logic: delegates to
- Checkout logic → Cart data: reads cart (evidence: `src/main/java/service/CheckoutService.java`)
- Checkout logic → Promotion logic: requests discounts (evidence: `src/main/java/service/CheckoutService.java`)
- Customer → Order handling: manages orders
- Order handling → Order service: uses
- Order service → Orders and transactions: loads order data
- Customer → Payment endpoints: pays
- Payment endpoints → VNPay integration: uses
- VNPay integration → VNPay: communicates with
- Customer → Authentication: signs in
- Authentication → Identity data: accesses identity data (evidence: `src/main/java/controller/customer/AuthServlet.java`)
- Authentication → Email service: sends notifications (evidence: `src/main/java/controller/customer/AuthServlet.java`)
- Authentication → Session utilities: manages session (evidence: `src/main/java/controller/customer/AuthServlet.java`)
- Customer → Google OAuth: uses optional login
- Google OAuth → Google identity: exchanges identity
- Google OAuth → Identity data: looks up account (evidence: `src/main/java/controller/customer/GoogleOAuthServlet.java`)
- Promotion logic → Promotion data: loads promotions (evidence: `src/main/java/service/PromotionService.java`)
- Promotion logic → Car and brand data: loads cars (evidence: `src/main/java/service/PromotionService.java`)
- Admin → Admin tools: manages catalog
- Staff → Staff tools: manages inventory
- Admin tools → Car and brand data: updates cars (evidence: `src/main/java/controller/admin/AddCarServlet.java`)
- Admin tools → Promotion data: manages promotions (evidence: `src/main/java/controller/admin/AddPromotionServlet.java`)
- Staff tools → Car and brand data: updates cars (evidence: `src/main/java/controller/staff/UpdateCarServlet.java`)
- Car and brand data → Connection pool: gets connections (evidence: `src/main/java/dao/CarDAO.java`)
- Cart data → Connection pool: gets connections
- Promotion data → Connection pool: gets connections (evidence: `src/main/java/dao/PromotionDAO.java`)
- Orders and transactions → Connection pool: gets connections (evidence: `src/main/java/dao/OrdersDAO.java`)
- Identity data → Connection pool: gets connections (evidence: `src/main/java/dao/AuthDAO.java`)
- Connection pool → SQL Server: opens JDBC connections (evidence: `src/main/java/util/DBContext.java`)
- Access and security filters → Authentication: guards requests
