A full-featured e-commerce web application for cosmetics, built with React + TypeScript + Vite. The platform supports three roles: Customer, Admin, and Shipper, each with their own dedicated portal.
- Features
- Screenshots
- Demo Accounts
- Tech Stack
- Project Structure
- Getting Started
- Environment Variables
- Available Scripts
- Routing Overview
- Modules
- Code Quality
- Browse products with filter by category, brand, and price
- View detailed product information
- Add to cart and manage cart items
- Checkout with payment integration
- User authentication (login, register, forgot/reset password)
- Personal profile management
- Dashboard with revenue charts, order statistics, and recent orders
- Manage products (create, edit, delete)
- Manage orders and track order status
- Manage shipments
- Manage user accounts
- View and moderate product reviews
- Sales reports
- View assigned delivery list
- Update delivery status in real time
- View delivery history
Users can view and edit their personal details (full name, phone number, email, address) directly from the profile page.
Users fill in shipping information, review their order summary (items, subtotal, shipping fee, total), choose a payment method, and place the order.
Admins can view inventory stats (total, available, low stock, out of stock, warehouse value), search and filter products by category and status, and perform actions (view, edit, disable) on each product.
The system supports three roles. Use the accounts below to log in and explore each portal:
| Role | Portal | Password | |
|---|---|---|---|
| Customer | /auth |
user@cosmetic.com | (your password) |
| Admin | /admin |
admin@cosmetic.com | (your password) |
| Shipper | /shipper-management |
shipper@cosmetic.com | (your password) |
These accounts must exist in your database. Ask your backend team for the actual credentials or seed them via the backend setup scripts.
| Category | Library / Tool |
|---|---|
| Framework | React 18 |
| Language | TypeScript 4 |
| Build Tool | Vite 2 |
| Styling | Tailwind CSS 3, Ant Design 5 |
| Routing | React Router DOM v7 |
| State Management | Zustand 5 |
| Data Fetching | TanStack React Query 5 + Axios |
| Charts | Recharts 3 |
| Icons | Lucide React, FontAwesome |
| Auth | JWT via jwt-decode |
| Linting | ESLint 8 + Prettier 2 |
| Git Hooks | Husky 9 + lint-staged |
cosmetic-react-store/
├── src/
│ ├── app/
│ │ └── router.tsx # All route definitions
│ ├── assets/
│ │ └── imgs/ # Static images and banners
│ ├── components/
│ │ └── Layout/
│ │ ├── Header.tsx
│ │ └── Footer.tsx
│ ├── data/ # Mock/seed data
│ ├── lib/
│ │ ├── axios.ts # Axios client with JWT interceptor
│ │ └── utils.ts
│ ├── modules/
│ │ ├── Admin/ # Admin portal
│ │ ├── Auth/ # Authentication flows
│ │ ├── Customer/ # Customer-facing storefront
│ │ └── Shipper/ # Shipper delivery portal
│ ├── App.tsx
│ ├── main.tsx
│ └── index.css
├── index.html
├── package.json
├── tsconfig.json
├── postcss.config.js
├── .eslintrc
└── .prettierrc
Each module follows a consistent internal structure:
modules/<Module>/
├── api/ # API call functions (axios)
├── component/ # UI components
├── views/ # Page-level view components
├── hooks/ # Custom React hooks
└── <Module>Page.tsx # Module entry / layout component
- Clone the repository:
git clone https://github.com/HongDiep18/Cosmetic-react-store.git
cd Cosmetic-react-store- Install dependencies:
npm install
# or
yarn install- Create your environment file and set the API base URL:
# Create a .env file in the project root
VITE_API_BASE_URL=http://localhost:8000- Start the development server:
npm run dev
# or
yarn dev- Open your browser at the link just run
Note: The frontend fetches all product, order, and user data from the backend API (
http://localhost:8000). Make sure the backend server is running before you open the app — without it, pages will load but all data will be empty or show errors. See Run the Backend (FastAPI) for setup instructions.
You have to clone this project: https://github.com/HongDiep18/Cosmetic-api-store.git
Create a .env file in the project root:
VITE_API_BASE_URL=http://localhost:8000| Variable | Description | Default |
|---|---|---|
VITE_API_BASE_URL |
Base URL for the backend API | http://localhost:8000 |
| Command | Description |
|---|---|
npm run dev |
Start development server |
npm run build |
Type-check and build for production |
npm run preview |
Preview the production build locally |
npm run lint |
Check for lint errors |
npm run lint:fix |
Auto-fix lint errors |
npm run prettier |
Check code formatting |
npm run prettier:fix |
Auto-fix code formatting |
npm run format |
Fix both lint and formatting |
| Path | Role | Description |
|---|---|---|
/ |
Customer | Homepage / hero banner |
/products |
Customer | Product listing with filters |
/products/:productId |
Customer | Product detail page |
/cart |
Customer | Shopping cart |
/checkout |
Customer | Checkout & payment |
/auth |
Public | Login / Register |
/auth/forgot-password |
Public | Forgot password |
/auth/reset-password |
Public | Reset password |
/profile |
Customer (auth required) | User profile |
/admin |
Admin | Dashboard overview |
/admin/orders |
Admin | Order management |
/admin/products |
Admin | Product management |
/admin/shipments |
Admin | Shipment tracking |
/admin/accounts |
Admin | User account management |
/admin/reviews |
Admin | Review moderation |
/admin/reports |
Admin | Sales reports |
/shipper-management |
Shipper (auth required) | Delivery list |
/shipper-management/deliveries |
Shipper | Active deliveries |
/shipper-management/history |
Shipper | Delivery history |
Handles all authentication flows. JWT access tokens are stored in localStorage and automatically attached to every API request via an Axios interceptor. On a 401 response, the token is cleared and the user is redirected to /auth.
- Login / Register form
- Forgot password (email-based)
- Reset password
RequireAuthwrapper component for protected routes
The main storefront. Uses React Query for server-state caching and Zustand (via CartContext) for local cart state.
HomeView— hero banner, featured productsProductPage— filterable product grid (by category, brand)ProductDetail— images, description, add to cartCart— cart items, quantity control, totalsCheckout— address input, paymentProfile— user info and order history
Full back-office panel with sidebar navigation.
DashboardView— stat cards, revenue chart (Recharts), recent orders tableOrdersView— paginated order list, status updatesProductsView— product CRUD with inline formShipmentsView— shipment trackingAccountView— user account listReviewsView— product review moderationReportsView— sales reports and data export
Lightweight portal for delivery personnel.
DeliveryListView— list of active assigned ordersDeliveryHistoryView— completed delivery history- Status update actions per delivery
The project enforces consistent code style automatically.
On every commit (via Husky + lint-staged), all staged .ts/.tsx files are:
- Auto-fixed with ESLint
- Formatted with Prettier
ESLint rules include:
@typescript-eslintrecommended rulesreact-hooksrules (exhaustive deps, rules of hooks)jsx-a11yaccessibility rules- Import order enforcement
Path aliases — use ~/ to import from src/:
import apiClient from '~/lib/axios';
import HomeView from '~/modules/Customer/views/HomeView';Configured in both tsconfig.json and vite.config.ts via vite-tsconfig-paths.
Manual checks:
# Check lint
yarn lint
# Fix lint
yarn lint:fix
# Check prettier
yarn prettier
# Fix prettier
yarn prettier:fix
# Fix both lint and prettier
yarn format

