FlashTrade is a modern, full‑stack multi‑vendor e‑commerce platform built with the latest technologies. It features role‑based workflows for Customers, Sellers, and Admins and promotes rapid development, scalable architecture, and a friendly developer experience.
- Frontend: React 19 ⚛️ (functional components/hooks), TypeScript, Vite, Tailwind CSS
- Backend: Node.js (v20) 🟢, Express 5, TypeScript, MongoDB & Mongoose
- API pattern: RESTful with middleware for auth, roles, and error handling
- Authentication: JWT access + refresh tokens + secure route guards
- Business logic highlights: multi‑role workflows, seller approval, activation/inactivation, commission rules, COD payment state
Both client and server live in the same monorepo with clear separation:
FlashTrade/
Client/ # React + Vite front-end single-page app
public/ # static assets and index.html
src/ # source code
components/
pages/
context/
service/ # API calls, utility functions
types/ # shared TypeScript interfaces
router.tsx
main.tsx
Server/ # Express back-end
src/
controllers/ # request handlers
models/ # Mongoose schemas
routes/ # express routers (linked below)
middlewares/ # auth, error handling, role checks
db/ # Mongo connection & sample data
utils/ # helper functions
tsconfig.json
package.json
README.md
The codebase opts for strict TypeScript, ESLint setups in the client, and Nodemon+ts-node for development on the backend. The front-end communicates with the API via a lightweight apiClient wrapper.
- 🔑 Multi-role UX
- Customer: browse, filter, add to cart, checkout, order history, reviews
- Seller: manage own products/orders/reviews, view analytics
- Admin: approve/disable sellers, manage categories & commissions, view analytics
- 📦 Category commission rules based on total quantity
- 💰 Commission applied at order-time or when COD payment is marked paid
- 🔒 Seller isolation ensures data privacy
- 🗑️ Admin tools to remove sellers + related data
FlashTrade/
Client/ # React + Vite frontend
Server/ # Express + MongoDB backend
README.md
| Feature | Customer | Seller | Admin |
|---|---|---|---|
| Browse products/categories | ✅ | ✅ | ✅ |
| Add to cart / place order | ✅ | ❌ | ❌ |
| Manage own products | ❌ | ✅ | ❌ |
| Manage seller orders | ❌ | ✅ | ❌ |
| Approve product reviews | ❌ | ✅ | ❌ |
| Approve/inactivate/remove sellers | ❌ | ❌ | ✅ |
| Manage categories | ❌ | ❌ | ✅ |
| Manage commission rules | ❌ | ❌ | ✅ |
| View admin analytics | ❌ | ❌ | ✅ |
- Node.js 20+
- npm 10+
- MongoDB (local/Atlas)
mongoimport(optional, for sample data)
Create .env in Server/:
PORT=3000
CLIENT_ORIGIN=http://localhost:5173
DB_URL=mongodb://127.0.0.1:27017/flashtrade
ACCESS_TOKEN_SECRET=replace_with_secure_secret
REFRESH_TOKEN_SECRET=replace_with_secure_secret
NODE_ENV=development
EMAIL_USER=your_email@example.com
EMAIL_PASS=your_email_app_password
ADMIN_SETUP_SECRET=set_bootstrap_secret
FRONTEND_URL=http://localhost:5173Note:
DB_URLis required byServer/src/db/mongo.ts. Keep secrets out of source control.
- Install dependencies
cd Server && npm install
cd ../Client && npm install- Start backend
cd Server
npm run dev- Start frontend
cd Client
npm run devFrontend: http://localhost:5173
API base: http://localhost:3000/api
Client/src/service/apiClient.ts currently hardcodes:
export const BASE_URL = "http://localhost:3000/api";Change or move to a Vite env variable if needed.
Below is a breakdown of every route group, the endpoints they expose, and who can access them.
| Endpoint | Method | Description | Auth / Role |
|---|---|---|---|
/auth/signup |
POST | Register new user (customer or seller) | Public |
/auth/login |
POST | Login, receive access & refresh tokens | Public |
/auth/refresh-token |
POST | Obtain new access token | Public |
/auth/logout |
POST | Revoke refresh token | Public |
/auth/profile |
GET | Get current user profile | Authenticated |
/auth/change-password |
PUT | Change own password | Authenticated |
/auth/update-profile |
PUT | Update own profile | Authenticated |
/auth/forgot-password |
POST | Start password reset flow | Public |
/auth/reset-password/:token |
POST | Complete password reset | Public |
| Endpoint | Method | Description |
| ------------------------------- | ------ | ------------------------------- | ----- |
| /auth/bootstrap-admin | POST | Create first admin using secret |
| /auth/admins | POST | Create additional admin | Admin |
| /auth/admins/:userId/promote | PATCH | Promote user to admin | Admin |
| /auth/users | GET | List all users | Admin |
| /auth/sellers/pending | GET | List sellers awaiting approval | Admin |
| /auth/sellers/:userId/approve | PATCH | Approve a seller | Admin |
| /auth/sellers/approved | GET | List approved sellers | Admin |
| /auth/sellers/:userId | GET | Get seller by id | Admin |
| /auth/sellers/:userId/status | PATCH | Activate/inactivate seller | Admin |
| /auth/sellers/:userId | DELETE | Remove seller and related data | Admin |
| Endpoint | Method | Access | Description |
|---|---|---|---|
/products |
GET | Public | Browse all products |
/products/:id |
GET | Public | Product details |
/products/category/:categoryId |
GET | Public | Products filtered by category |
/products/seller/me |
GET | Seller (approved) | Seller's own products |
/products/admin/seller/:sellerId |
GET | Admin | View products of a seller |
/products |
POST | Seller (approved) | Create new product |
/products/:id |
PUT | Seller (approved) | Update own product |
/products/:id |
DELETE | Seller (approved) | Delete own product |
/products/admin/:id |
DELETE | Admin | Force-delete any product |
| Endpoint | Method | Access | Description |
|---|---|---|---|
/categories |
GET | Public | List categories |
/categories |
POST | Admin | Create category |
/categories/:id |
PUT | Admin | Update category |
/categories/:id |
DELETE | Admin | Delete category |
| Endpoint | Method | Access | Description |
|---|---|---|---|
/cart/my |
GET | Customer | Get current cart |
/cart/my/add |
POST | Customer | Add item to cart |
/cart/my/remove |
POST | Customer | Remove item from cart |
| Endpoint | Method | Access | Description |
|---|---|---|---|
/orders |
POST | Customer | Place new order (checkout) |
/orders/my |
GET | Customer | List own orders |
/orders/my/:orderId |
GET | Customer | Order details |
/orders/seller |
GET | Seller | Seller's orders |
/orders/seller/analytics |
GET | Seller | Seller analytics data |
/orders/admin |
GET | Admin | All orders list |
/orders/:orderId/status |
PATCH | Seller | Update shipment status |
/orders/:orderId/payment-status |
PATCH | Seller | Mark COD payment paid |
| Endpoint | Method | Access | Description |
|---|---|---|---|
/reviews |
POST | Public | Submit a review |
/reviews |
GET | Public | Browse all reviews |
/reviews/seller/pending |
GET | Seller | Seller's un‑approved reviews |
/reviews/seller/:reviewId/approve |
PATCH | Seller | Approve a review |
| Endpoint | Method | Access | Description |
|---|---|---|---|
/commissions/estimate |
GET | Authenticated | Estimate commission for cart/order |
/commissions |
GET | Admin | List rules |
/commissions |
POST | Admin | Create rule |
/commissions/:id |
PUT | Admin | Update rule |
/commissions/:id |
DELETE | Admin | Remove rule |
| Endpoint | Method | Access | Description |
|---|---|---|---|
/offers |
GET | Public | Get active offers |
| Endpoint | Method | Access | Description |
|---|---|---|---|
/email/contact |
POST | Public | Send contact form email |
This section provides full visibility into the API surface for developers or integrators.
- Rules per category:
minQty,ratePercent,isActive - Category matching is case‑insensitive
- Commission quantity = total qty per category in the order
- Non‑COD: commission applied on order creation
- COD: commission applied when seller marks payment
paid
Example:
Rule: Sneakers,minQty=2,ratePercent=8
Order contains 5 sneakers → rule applies.
Files under Server/src/db. Import order to maintain referential integrity:
SampleUsers.jsonSampleCategoory.jsonSampleProduts.jsonSampleCommissionRules.jsonSampleOrders.jsonSampleReviews.jsonSampeCustomerMessage .json
Refer to Server/src/db/IMPORT_ORDER.md for commands.
- Backend: strict TypeScript, Mongoose
- Some filenames intentionally misspelled (e.g.
SampleProduts.json) - Role checks + approval/active middleware protect seller APIs
- Linting:
Client/npm run lintuses ESLint with TypeScript rules. - Formatting: follow Prettier config in workspace (not checkedin? may use vscode settings).
- Type checking: client build runs
tscduringnpm run build. - Environment switching: update
Client/vite.config.tsandapiClientas needed. - Sample data import: see
Server/src/db/IMPORT_ORDER.md; usesmongoimport. - Testing placeholder: no automated tests yet – planned roadmap item.
- Rotate secrets
- Restrict CORS origins
- Enable HTTPS & secure cookies
- Externalize API URL
- Add rate limiting & validation
- Build automated tests
Client
npm run dev– Vite dev servernpm run build– type-check + production buildnpm run lint– lint sourcenpm run preview– preview build
Server
npm run dev– Express with nodemon & ts-node
- MongoDB fails: ensure
DB_URLis set - Frontend can't reach API: verify backend port &
BASE_URL - 403 on seller pages: seller must be approved & active
- No commission on COD: seller must mark payment
paid
- Env‑based API URL
- Automated test suite (API + UI)
- Pagination for large tables
- Centralized audit log
Thank you for exploring FlashTrade! 💡
Contributions welcome – open a PR or raise an issue 😉.
DB_URLis required byServer/src/db/mongo.ts.- Keep secrets out of git.
cd Server && npm install
cd ../Client && npm installcd Server
npm run devBackend default API base: http://localhost:3000/api
cd Client
npm run devFrontend default: http://localhost:5173
Client/src/service/apiClient.ts currently uses a hardcoded base URL:
export const BASE_URL = "http://localhost:3000/api";If your backend runs elsewhere, update this value (or move it to a Vite env variable).
Base prefix: /api
/auth- signup/login/profile/admin/seller approval and management/products- public catalog + seller CRUD + admin seller product view/delete/categories- public list + admin create/update/delete/cart- customer-only cart operations/orders- customer checkout/history, seller order management, seller analytics, admin order list/reviews- customer review create + seller review approval/commissions- admin commission rules + commission estimation/offers- public offers/email/contact- contact form email sending
- Commission rules are set per category with:
minQty(starting quantity threshold)ratePercentisActive
- Matching is case-insensitive by category name where needed.
- At order time, commission quantity is evaluated by total quantity per category in the order.
- For non-COD payments, commission is applied during order creation.
- For COD (
paymentMethod: cash), commission is zero initially and applied when seller updates payment status topaid.
Example:
- Rule A: category
Sneakers,minQty=2,ratePercent=8 - Customer buys 3 different sneaker products, qty total in sneakers = 5
- Rule applies because 5 >= 2
Sample JSON files are in Server/src/db.
Import order (to avoid relation issues):
SampleUsers.jsonSampleCategoory.jsonSampleProduts.jsonSampleCommissionRules.jsonSampleOrders.jsonSampleReviews.jsonSampeCustomerMessage .json
See detailed commands in:
Server/src/db/IMPORT_ORDER.md
- Backend uses strict TypeScript and Mongoose models.
- Some filenames are intentionally preserved with existing project naming (e.g.,
SampleProduts.json). - Seller-protected APIs use auth + role checks + approval/active checks.
Before production:
- Rotate
ACCESS_TOKEN_SECRET,REFRESH_TOKEN_SECRET,ADMIN_SETUP_SECRET - Use production CORS origin(s) only
- Secure cookies and HTTPS
- Remove hardcoded frontend API URL and use env configuration
- Add rate limiting and request validation hardening
- Add automated tests (unit + integration)
npm run dev- start Vite dev servernpm run build- type-check + production buildnpm run lint- lint sourcenpm run preview- preview built app
npm run dev- start Express server with nodemon + ts-node
- MongoDB connection fails
- Confirm
DB_URLexists inServer/.env
- Confirm
- Frontend cannot reach API
- Verify backend port and
BASE_URLinClient/src/service/apiClient.ts
- Verify backend port and
- 403 on seller pages
- Seller must be approved and active by admin
- No commission appears for COD order
- Seller must mark payment status as
paid
- Seller must mark payment status as
- Replace hardcoded API URL with env-based config
- Add test suite (API + UI)
- Add pagination for admin/seller tables
- Add centralized audit log for seller/admin actions