Tech Stack
Toàn bộ stack công nghệ chuẩn của PrimeCommerce, áp dụng cho mọi dự án mới.
Frontend
Next.js 14+
App Router + TypeScript. Framework chính cho web.
Tailwind CSS + shadcn/ui
Styling nhanh, component library sẵn dùng.
| Thành phần | Công nghệ | Ghi chú |
|---|
| Framework | Next.js 14+ (App Router) | TypeScript bắt buộc |
| Styling | Tailwind CSS + shadcn/ui | Không sửa trực tiếp file shadcn/ui |
| State (client) | Zustand | Store nhẹ, đơn giản |
| State (server) | TanStack Query | Cache, refetch, optimistic updates |
| Forms | React Hook Form + Zod | Validation bằng schema |
| Testing | Vitest + React Testing Library | Unit + component tests |
| E2E | Playwright | End-to-end tests |
Cấu trúc thư mục Next.js
src/
├── app/ # App Router pages & layouts
│ ├── (auth)/ # Route groups
│ ├── (dashboard)/
│ └── api/ # API routes (lightweight)
├── components/
│ ├── ui/ # shadcn/ui (KHÔNG sửa trực tiếp)
│ └── [feature]/ # Components theo tính năng
├── lib/
│ ├── api/ # API client, fetchers
│ ├── hooks/ # Custom hooks
│ ├── stores/ # Zustand stores
│ ├── utils/ # Hàm tiện ích
│ └── validations/ # Zod schemas
├── types/ # TypeScript types dùng chung
└── config/ # Cấu hình ứng dụng
Backend
NestJS
Primary API. TypeScript + module architecture.
FastAPI
AI/ML services. Python + async.
| Thành phần | Công nghệ | Ghi chú |
|---|
| Primary API | NestJS + TypeScript | Module-based architecture |
| AI/ML Services | Python + FastAPI | Cho các dịch vụ AI |
| Database | PostgreSQL | Database chính |
| Cache/Queue | Redis | Cache + BullMQ queue |
| ORM (NestJS) | Prisma | Type-safe queries |
| ORM (FastAPI) | SQLAlchemy | Python ORM |
| Auth | JWT + Refresh tokens | NextAuth cho Next.js |
| Message Queue | BullMQ | Redis-backed |
Cấu trúc thư mục NestJS
src/
├── modules/
│ └── [feature]/
│ ├── dto/ # Request/Response DTOs
│ ├── entities/ # Prisma models
│ ├── [feature].controller.ts
│ ├── [feature].service.ts
│ ├── [feature].module.ts
│ └── [feature].spec.ts
├── common/
│ ├── decorators/
│ ├── filters/ # Exception filters
│ ├── guards/ # Auth guards
│ ├── interceptors/
│ └── pipes/
├── config/
├── database/
│ └── migrations/
└── main.ts
Cấu trúc thư mục FastAPI
app/
├── api/v1/routes/ # Route handlers
├── core/
│ ├── config.py # pydantic-settings
│ ├── security.py
│ └── dependencies.py
├── models/ # SQLAlchemy models
├── schemas/ # Pydantic schemas
├── services/ # Business logic
├── repositories/ # Data access
└── main.py
Mobile
| Thành phần | Công nghệ |
|---|
| Framework | Expo (React Native) + TypeScript |
| Navigation | Expo Router |
| State | Zustand + TanStack Query |
Infrastructure
| Thành phần | Công nghệ |
|---|
| CI/CD | GitHub Actions |
| Container | Docker + Docker Compose |
| Cloud | Tùy dự án (ghi trong CLAUDE.md riêng) |
| Monitoring | Tùy dự án |
Database Schema
Luôn sử dụng migrations khi thay đổi schema. Không bao giờ sửa trực tiếp database.
# Prisma migrations
npx prisma migrate dev --name add_user_profiles
npx prisma generate
# SQLAlchemy migrations
alembic revision --autogenerate -m "add user profiles"
alembic upgrade head
Monorepo Layout (Khuyên dùng)
project/
├── apps/
│ ├── web/ # Next.js frontend
│ ├── api/ # NestJS backend
│ └── worker/ # Background jobs
├── packages/
│ ├── shared/ # Shared types, utils
│ └── ui/ # Shared UI components
├── infra/ # Docker, k8s configs
├── docs/ # Documentation
└── CLAUDE.md # Project-level instructions