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ầnCông nghệGhi chú
FrameworkNext.js 14+ (App Router)TypeScript bắt buộc
StylingTailwind CSS + shadcn/uiKhông sửa trực tiếp file shadcn/ui
State (client)ZustandStore nhẹ, đơn giản
State (server)TanStack QueryCache, refetch, optimistic updates
FormsReact Hook Form + ZodValidation bằng schema
TestingVitest + React Testing LibraryUnit + component tests
E2EPlaywrightEnd-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ầnCông nghệGhi chú
Primary APINestJS + TypeScriptModule-based architecture
AI/ML ServicesPython + FastAPICho các dịch vụ AI
DatabasePostgreSQLDatabase chính
Cache/QueueRedisCache + BullMQ queue
ORM (NestJS)PrismaType-safe queries
ORM (FastAPI)SQLAlchemyPython ORM
AuthJWT + Refresh tokensNextAuth cho Next.js
Message QueueBullMQRedis-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ầnCông nghệ
FrameworkExpo (React Native) + TypeScript
NavigationExpo Router
StateZustand + TanStack Query

Infrastructure

Thành phầnCông nghệ
CI/CDGitHub Actions
ContainerDocker + Docker Compose
CloudTùy dự án (ghi trong CLAUDE.md riêng)
MonitoringTù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