# bangsonchau/swt_web_test architecture

> Architecture diagram of the GitHub repository bangsonchau/swt_web_test, 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/bangsonchau/swt_web_test
- Repository: https://github.com/bangsonchau/swt_web_test

## Overview

This repository combines a React login application, an Express authentication API, and an Excel-driven Playwright test system. The main user workflow runs from the login form through validation and an API request, then checks credentials, persists a JWT, and stores the returned session in the browser. The test suite separately loads Excel cases, dispatches browser actions, formats results, and writes an Excel report. Some test wiring and several server links are supported by README or source-index references rather than inspected implementation excerpts.

Main entry points: [`client/src/app/router.tsx`](https://github.com/bangsonchau/swt_web_test/blob/main/client/src/app/router.tsx) (Page router), [`client/src/feature/auth/pages/LoginPage.tsx`](https://github.com/bangsonchau/swt_web_test/blob/main/client/src/feature/auth/pages/LoginPage.tsx) (Login form), [`client/src/feature/auth/hooks/useLogin.tsx`](https://github.com/bangsonchau/swt_web_test/blob/main/client/src/feature/auth/hooks/useLogin.tsx) (Login mutation), [`server/src/modules/auth/auth.repository.js`](https://github.com/bangsonchau/swt_web_test/blob/main/server/src/modules/auth/auth.repository.js) (User repository)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["React frontend"]
  node_app["Application shell<br/>[App.tsx]"]
  node_router["Page router<br/>[router.tsx]"]
  node_layout["User layout<br/>[UserLayout.tsx]"]
  node_home["Home page<br/>[HomePage.tsx]"]
  node_guestguard["Guest guard<br/>[GuestRoute.tsx]"]
  node_loginpage["Login form<br/>[LoginPage.tsx]"]
  node_validation["Login validation<br/>[rule.ts]"]
  node_loginhook["Login mutation<br/>[useLogin.tsx]"]
  node_authservice["Auth API client<br/>[service.ts]"]
  node_axios["HTTP client<br/>[axios.ts]"]
  node_authstore["Session store<br/>[store.ts]"]
end

subgraph group_backend["Authentication API"]
  node_api["Express API<br/>[app.js]"]
  node_routes["API routes<br/>[routes.js]"]
  node_authroute["Auth route<br/>[auth.route.js]"]
  node_controller["Auth controller<br/>[auth.controller.js]"]
  node_authlogic["Credential and JWT logic<br/>[auth.service.js]"]
  node_repository["User repository<br/>[auth.repository.js]"]
  node_userentity["User response entity<br/>[user.entity.js]"]
  node_prisma["Prisma client<br/>[prisma.js]"]
end

subgraph group_e2e["Excel E2E testing"]
  node_case_runner["Case runner"]
  node_loader["Workbook loader<br/>[loader.ts]"]
  node_dispatcher["Action dispatcher"]
  node_selector["Selector resolver"]
  node_formatter["Error formatter<br/>[formatter.ts]"]
  node_reporter["Excel reporter<br/>[excel-reporter.ts]"]
  node_reportwriter["Report writer<br/>[report-writer.ts]"]
end

node_visitor(("Visitor"))
node_postgres[("PostgreSQL")]
node_workbook["Excel test cases"]
node_reportfile["Excel results"]

node_visitor -->|"opens pages"| node_router
node_app -->|"mounts"| node_router
node_router -->|"renders"| node_layout
node_router -->|"routes to"| node_home
node_router -->|"wraps login"| node_guestguard
node_guestguard -->|"renders"| node_loginpage
node_loginpage -->|"validates with"| node_validation
node_loginpage -->|"submits via"| node_loginhook
node_loginhook -->|"calls"| node_authservice
node_authservice -->|"sends request"| node_axios
node_axios -->|"POST login"| node_api
node_loginhook -->|"stores session"| node_authstore
node_api -->|"mounts routes"| node_routes
node_routes -->|"mounts auth"| node_authroute
node_authroute -->|"dispatches"| node_controller
node_controller -->|"calls"| node_authlogic
node_authlogic -->|"looks up and updates"| node_repository
node_repository -->|"queries"| node_prisma
node_prisma -.->|"reads and writes"| node_postgres
node_repository -->|"wraps records"| node_userentity
node_workbook -->|"provides cases"| node_loader
node_loader -.->|"supplies steps"| node_case_runner
node_case_runner -->|"dispatches actions"| node_dispatcher
node_dispatcher -->|"resolves selectors"| node_selector
node_dispatcher -->|"formats errors"| node_formatter
node_reporter -->|"writes results"| node_reportwriter
node_reporter -->|"reads source file"| node_workbook
node_reportwriter -->|"exports report"| node_reportfile

click node_app "https://github.com/bangsonchau/swt_web_test/blob/main/client/src/app/App.tsx"
click node_router "https://github.com/bangsonchau/swt_web_test/blob/main/client/src/app/router.tsx"
click node_layout "https://github.com/bangsonchau/swt_web_test/blob/main/client/src/shared/layouts/UserLayout.tsx"
click node_home "https://github.com/bangsonchau/swt_web_test/blob/main/client/src/shared/pages/HomePage.tsx"
click node_guestguard "https://github.com/bangsonchau/swt_web_test/blob/main/client/src/shared/common/guards/GuestRoute.tsx"
click node_loginpage "https://github.com/bangsonchau/swt_web_test/blob/main/client/src/feature/auth/pages/LoginPage.tsx"
click node_validation "https://github.com/bangsonchau/swt_web_test/blob/main/client/src/feature/auth/rule.ts"
click node_loginhook "https://github.com/bangsonchau/swt_web_test/blob/main/client/src/feature/auth/hooks/useLogin.tsx"
click node_authservice "https://github.com/bangsonchau/swt_web_test/blob/main/client/src/feature/auth/service.ts"
click node_axios "https://github.com/bangsonchau/swt_web_test/blob/main/client/src/lib/axios.ts"
click node_authstore "https://github.com/bangsonchau/swt_web_test/blob/main/client/src/feature/auth/store.ts"
click node_api "https://github.com/bangsonchau/swt_web_test/blob/main/server/src/app.js"
click node_routes "https://github.com/bangsonchau/swt_web_test/blob/main/server/src/routes.js"
click node_authroute "https://github.com/bangsonchau/swt_web_test/blob/main/server/src/modules/auth/auth.route.js"
click node_controller "https://github.com/bangsonchau/swt_web_test/blob/main/server/src/modules/auth/auth.controller.js"
click node_authlogic "https://github.com/bangsonchau/swt_web_test/blob/main/server/src/modules/auth/auth.service.js"
click node_repository "https://github.com/bangsonchau/swt_web_test/blob/main/server/src/modules/auth/auth.repository.js"
click node_userentity "https://github.com/bangsonchau/swt_web_test/blob/main/server/src/modules/auth/user.entity.js"
click node_prisma "https://github.com/bangsonchau/swt_web_test/blob/main/server/src/config/prisma.js"
click node_case_runner "https://github.com/bangsonchau/swt_web_test/blob/main/playwright-test/src/runner/test-case-runner.ts"
click node_loader "https://github.com/bangsonchau/swt_web_test/blob/main/playwright-test/src/excel/loader.ts"
click node_dispatcher "https://github.com/bangsonchau/swt_web_test/blob/main/playwright-test/src/runner/action-dispatcher.ts"
click node_selector "https://github.com/bangsonchau/swt_web_test/blob/main/playwright-test/src/runner/selector-resolver.ts"
click node_formatter "https://github.com/bangsonchau/swt_web_test/blob/main/playwright-test/src/errors/formatter.ts"
click node_reporter "https://github.com/bangsonchau/swt_web_test/blob/main/playwright-test/reporters/excel-reporter.ts"
click node_reportwriter "https://github.com/bangsonchau/swt_web_test/blob/main/playwright-test/src/excel/report-writer.ts"

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_app,node_router,node_layout,node_home,node_guestguard,node_loginpage,node_validation,node_loginhook,node_authservice,node_axios,node_authstore toneBlue
class node_api,node_routes,node_authroute,node_controller,node_authlogic,node_repository,node_userentity,node_prisma,node_postgres toneAmber
class node_case_runner,node_loader,node_dispatcher,node_selector,node_formatter,node_reporter,node_reportwriter toneMint
class node_visitor,node_workbook,node_reportfile toneIndigo
```

## Components

### React frontend

- [Application shell](https://github.com/bangsonchau/swt_web_test/blob/main/client/src/app/App.tsx): `client/src/app/App.tsx`
- [Page router](https://github.com/bangsonchau/swt_web_test/blob/main/client/src/app/router.tsx): `client/src/app/router.tsx`
- [User layout](https://github.com/bangsonchau/swt_web_test/blob/main/client/src/shared/layouts/UserLayout.tsx): `client/src/shared/layouts/UserLayout.tsx`
- [Home page](https://github.com/bangsonchau/swt_web_test/blob/main/client/src/shared/pages/HomePage.tsx): `client/src/shared/pages/HomePage.tsx`
- [Guest guard](https://github.com/bangsonchau/swt_web_test/blob/main/client/src/shared/common/guards/GuestRoute.tsx): `client/src/shared/common/guards/GuestRoute.tsx`
- [Login form](https://github.com/bangsonchau/swt_web_test/blob/main/client/src/feature/auth/pages/LoginPage.tsx): `client/src/feature/auth/pages/LoginPage.tsx`
- [Login validation](https://github.com/bangsonchau/swt_web_test/blob/main/client/src/feature/auth/rule.ts): `client/src/feature/auth/rule.ts`
- [Login mutation](https://github.com/bangsonchau/swt_web_test/blob/main/client/src/feature/auth/hooks/useLogin.tsx): `client/src/feature/auth/hooks/useLogin.tsx`
- [Auth API client](https://github.com/bangsonchau/swt_web_test/blob/main/client/src/feature/auth/service.ts): `client/src/feature/auth/service.ts`
- [HTTP client](https://github.com/bangsonchau/swt_web_test/blob/main/client/src/lib/axios.ts): `client/src/lib/axios.ts`
- [Session store](https://github.com/bangsonchau/swt_web_test/blob/main/client/src/feature/auth/store.ts): `client/src/feature/auth/store.ts`

### Authentication API

- [Express API](https://github.com/bangsonchau/swt_web_test/blob/main/server/src/app.js): `server/src/app.js`
- [API routes](https://github.com/bangsonchau/swt_web_test/blob/main/server/src/routes.js): `server/src/routes.js`
- [Auth route](https://github.com/bangsonchau/swt_web_test/blob/main/server/src/modules/auth/auth.route.js): `server/src/modules/auth/auth.route.js`
- [Auth controller](https://github.com/bangsonchau/swt_web_test/blob/main/server/src/modules/auth/auth.controller.js): `server/src/modules/auth/auth.controller.js`
- [Credential and JWT logic](https://github.com/bangsonchau/swt_web_test/blob/main/server/src/modules/auth/auth.service.js): `server/src/modules/auth/auth.service.js`
- [User repository](https://github.com/bangsonchau/swt_web_test/blob/main/server/src/modules/auth/auth.repository.js): `server/src/modules/auth/auth.repository.js`
- [User response entity](https://github.com/bangsonchau/swt_web_test/blob/main/server/src/modules/auth/user.entity.js): `server/src/modules/auth/user.entity.js`
- [Prisma client](https://github.com/bangsonchau/swt_web_test/blob/main/server/src/config/prisma.js): `server/src/config/prisma.js`

### Excel E2E testing

- [Case runner](https://github.com/bangsonchau/swt_web_test/blob/main/playwright-test/src/runner/test-case-runner.ts): `playwright-test/src/runner/test-case-runner.ts`
- [Workbook loader](https://github.com/bangsonchau/swt_web_test/blob/main/playwright-test/src/excel/loader.ts): `playwright-test/src/excel/loader.ts`
- [Action dispatcher](https://github.com/bangsonchau/swt_web_test/blob/main/playwright-test/src/runner/action-dispatcher.ts): `playwright-test/src/runner/action-dispatcher.ts`
- [Selector resolver](https://github.com/bangsonchau/swt_web_test/blob/main/playwright-test/src/runner/selector-resolver.ts): `playwright-test/src/runner/selector-resolver.ts`
- [Error formatter](https://github.com/bangsonchau/swt_web_test/blob/main/playwright-test/src/errors/formatter.ts): `playwright-test/src/errors/formatter.ts`
- [Excel reporter](https://github.com/bangsonchau/swt_web_test/blob/main/playwright-test/reporters/excel-reporter.ts): `playwright-test/reporters/excel-reporter.ts`
- [Report writer](https://github.com/bangsonchau/swt_web_test/blob/main/playwright-test/src/excel/report-writer.ts): `playwright-test/src/excel/report-writer.ts`

### Other components

- **Visitor**
- **PostgreSQL**
- **Excel test cases**
- **Excel results**

## Connections

- Visitor → Page router: opens pages (evidence: `README.md`)
- Application shell → Page router: mounts (evidence: `client/src/app/App.tsx`)
- Page router → User layout: renders (evidence: `client/src/app/router.tsx`)
- Page router → Home page: routes to (evidence: `client/src/app/router.tsx`)
- Page router → Guest guard: wraps login (evidence: `client/src/app/router.tsx`)
- Guest guard → Login form: renders (evidence: `client/src/app/router.tsx`)
- Login form → Login validation: validates with (evidence: `client/src/feature/auth/pages/LoginPage.tsx`)
- Login form → Login mutation: submits via (evidence: `client/src/feature/auth/pages/LoginPage.tsx`)
- Login mutation → Auth API client: calls (evidence: `client/src/feature/auth/hooks/useLogin.tsx`)
- Auth API client → HTTP client: sends request (evidence: `client/src/feature/auth/service.ts`)
- HTTP client → Express API: POST login (evidence: `README.md`)
- Login mutation → Session store: stores session (evidence: `client/src/feature/auth/hooks/useLogin.tsx`)
- Express API → API routes: mounts routes (evidence: `server/src/app.js`)
- API routes → Auth route: mounts auth (evidence: `server/src/routes.js`)
- Auth route → Auth controller: dispatches (evidence: `server/src/modules/auth/auth.route.js`)
- Auth controller → Credential and JWT logic: calls (evidence: `server/src/modules/auth/auth.controller.js`)
- Credential and JWT logic → User repository: looks up and updates (evidence: `server/src/modules/auth/auth.service.js`)
- User repository → Prisma client: queries (evidence: `server/src/modules/auth/auth.repository.js`)
- Prisma client → PostgreSQL: reads and writes (evidence: `README.md`)
- User repository → User response entity: wraps records (evidence: `server/src/modules/auth/auth.repository.js`)
- Excel test cases → Workbook loader: provides cases (evidence: `README.md`)
- Workbook loader → Case runner: supplies steps (evidence: `README.md`)
- Case runner → Action dispatcher: dispatches actions (evidence: `playwright-test/src/runner/test-case-runner.ts`)
- Action dispatcher → Selector resolver: resolves selectors (evidence: `playwright-test/src/runner/action-dispatcher.ts`)
- Action dispatcher → Error formatter: formats errors (evidence: `playwright-test/src/runner/action-dispatcher.ts`)
- Excel reporter → Report writer: writes results (evidence: `playwright-test/reporters/excel-reporter.ts`)
- Excel reporter → Excel test cases: reads source file (evidence: `README.md`)
- Report writer → Excel results: exports report (evidence: `README.md`)
