Files
aplp.frontend.web/README.md
T

84 lines
3.0 KiB
Markdown
Raw Normal View History

2026-08-11 21:09:32 +07:00
# aplp.frontend.react
2026-08-10 20:25:30 +07:00
2026-08-11 21:09:32 +07:00
Frontend (React) cho **APLP — Adaptive Personal Learning Platform** (learner application `aplp-web`).
2026-08-10 20:25:30 +07:00
2026-08-11 21:42:34 +07:00
React 19 + TypeScript + Vite · Client mỏng (thin client) gọi API của backend `aplp.backend.web`. Frontend **không** chứa business rules; mọi quyết định domain (mastery, progress, adaptive) đến từ backend.
2026-08-10 20:25:30 +07:00
2026-08-11 21:09:32 +07:00
## Stack
2026-08-10 20:25:30 +07:00
2026-08-11 21:09:32 +07:00
| Lĩnh vực | Công nghệ |
| --- | --- |
| Framework | React 19 |
| Language | TypeScript |
| Build | Vite 8 |
| Routing | React Router 7 |
| HTTP client | Axios (wrapper tại `src/api`) |
| Server-state | TanStack Query |
| Client-state | Zustand |
| Styling | Tailwind CSS 4 |
| Lint | oxlint |
| Format | Prettier |
| Test | Vitest + Testing Library |
2026-08-10 20:25:30 +07:00
2026-08-11 21:09:32 +07:00
## Quick Start
2026-08-10 20:25:30 +07:00
2026-08-11 21:09:32 +07:00
Prerequisite: Node.js 18+ (LTS khuyến nghị).
2026-08-10 20:25:30 +07:00
2026-08-11 21:09:32 +07:00
```bash
npm install
cp .env.example .env # chỉnh VITE_API_BASE_URL nếu cần
npm run dev # mở địa chỉ Vite (mặc định http://localhost:5173)
2026-08-10 20:25:30 +07:00
```
2026-08-11 21:09:32 +07:00
Backend chạy local để API hoạt động (xem `docs/SETUP.md`).
2026-08-10 20:25:30 +07:00
2026-08-11 21:09:32 +07:00
## Scripts
2026-08-10 20:25:30 +07:00
2026-08-11 21:09:32 +07:00
| Lệnh | Mô tả |
| --- | --- |
| `npm run dev` | Dev server (Vite) |
| `npm run build` | Typecheck + production build |
| `npm run preview` | Preview production build |
| `npm run lint` | Lint (oxlint) |
| `npm run format` / `format:check` | Format bằng Prettier |
| `npm run typecheck` | Typecheck (tsc) |
| `npm test` / `test:watch` | Unit test (Vitest) |
2026-08-10 20:25:30 +07:00
2026-08-11 21:09:32 +07:00
## Structure
2026-08-10 20:25:30 +07:00
2026-08-11 21:09:32 +07:00
```text
src/
├── app/ # app entry, router, providers, layout, pages
├── api/ # api client (axios), token storage
├── features/ # feature modules (auth, learner, course, ...)
│ └── auth/ # api, components, hooks, pages, store
├── shared/ # shared components, hooks, config
└── types/ # shared types / DTO contracts
```
2026-08-10 20:25:30 +07:00
2026-08-11 21:09:32 +07:00
Chi tiết: [docs/ARCHITECTURE.md](./docs/ARCHITECTURE.md), [docs/CONVENTIONS.md](./docs/CONVENTIONS.md).
2026-08-10 20:25:30 +07:00
2026-08-11 21:09:32 +07:00
## Auth Flow
2026-08-10 20:25:30 +07:00
2026-08-11 21:09:32 +07:00
- Access token lưu **in-memory** (`src/api/tokenStorage.ts`), không persist vào storage trình duyệt.
- Refresh token do backend quản lý (HttpOnly cookie); client không chạm tới.
- `401` → api client tự gọi `/auth/refresh` rồi retry request gốc (không loop trên endpoint auth).
- Route bảo vệ qua `ProtectedRoute` (redirect `/login` nếu chưa đăng nhập).
2026-08-10 20:25:30 +07:00
2026-08-11 21:09:32 +07:00
Chi tiết: [docs/PHASES.md](./docs/PHASES.md) (Phase 0).
2026-08-10 20:25:30 +07:00
2026-08-11 21:09:32 +07:00
## Documents
2026-08-10 20:25:30 +07:00
2026-08-11 21:09:32 +07:00
| Tài liệu | Mô tả |
| --- | --- |
| [docs/PHASES.md](./docs/PHASES.md) | Công việc frontend theo từng phase APLP |
| [docs/ARCHITECTURE.md](./docs/ARCHITECTURE.md) | Kiến trúc: folder structure, data flow, auth |
| [docs/CONVENTIONS.md](./docs/CONVENTIONS.md) | Coding conventions |
| [docs/SETUP.md](./docs/SETUP.md) | Setup / khởi tạo dự án |
2026-08-10 20:25:30 +07:00
2026-08-11 21:09:32 +07:00
Backend: [aplp.backend.spring](../aplp.backend.spring) — kế hoạch phase tổng thể: [APLP-Project-Phases.md](../aplp.backend.spring/APLP-Project-Phases.md).
2026-08-10 20:25:30 +07:00
2026-08-11 21:09:32 +07:00
## Status
2026-08-10 20:25:30 +07:00
2026-08-11 21:09:32 +07:00
Phase 0 (Foundation) — hoàn tất. Xem danh sách completion criteria tại [docs/PHASES.md](./docs/PHASES.md).