WeaveFash - E-Commerce Fashion Platform
Project Overview
Tech Stack
Architecture
Project Structure
Features
Database Schema
API Endpoints
Authentication & Authorization
Environment Variables
Getting Started
Deployment
WeaveFash is a full-stack e-commerce fashion platform that provides a seamless online shopping experience for fashion enthusiasts. The platform features a modern, responsive design with a complete shopping workflow including product browsing, cart management, secure checkout with PayPal integration, and order tracking.
Modern E-Commerce Platform : Complete shopping experience from browsing to checkout
Role-Based Access : Separate interfaces for customers and super admins
PayPal Integration : Secure payment processing
Cloud Storage : Product images stored on Cloudinary
Real-time Cart Management : Persistent cart with quantity management
Coupon System : Discount codes with usage limits and validity periods
Order Management : Track orders from placement to delivery
Technology
Purpose
Next.js 15
React framework with App Router
React 18
UI library
TypeScript
Type safety
Tailwind CSS
Styling
Radix UI
Accessible UI components
Zustand
State management
Axios
HTTP client
Lucide React
Icons
PayPal React SDK
Payment integration
Jose
JWT verification in middleware
Technology
Purpose
Node.js
Runtime environment
Express.js
Web framework
TypeScript
Type safety
Prisma
ORM & database management
PostgreSQL
Primary database
Cloudinary
Image storage & CDN
JWT (Jose)
Authentication tokens
bcryptjs
Password hashing
Multer
File upload handling
Cookie-Parser
Cookie management
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β CLIENT (Next.js 15 - App Router) β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Pages (App Router) β State Management (Zustand) β
β βββ / (Home) β βββ useAuthStore β
β βββ /auth/login β βββ useProductStore β
β βββ /auth/register β βββ useCartStore β
β βββ /listing β βββ useCouponStore β
β βββ /listing/[id] β βββ useSettingsStore β
β βββ /cart β βββ useAddressStore β
β βββ /checkout β βββ useOrderStore β
β βββ /orders β β
β βββ /super-admin/* β β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Middleware (JWT Verification) β
β Route Protection: Public | User | Super Admin β
βββββββββββββββββββββββββββββββββ¬ββββββββββββββββββββββββββββββββββ
β
HTTP (REST)
β
βββββββββββββββββββββββββββββββββ΄ββββββββββββββββββββββββββββββββββ
β SERVER (Express.js + TypeScript) β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β API Routes β Middlewares β
β βββ /api/auth β βββ authenticateJwt β
β βββ /api/products β βββ isSuperAdmin β
β βββ /api/cart β βββ upload (Multer) β
β βββ /api/coupons β β
β βββ /api/settings β External Services β
β βββ /api/address β βββ Cloudinary (Images) β
β βββ /api/order β βββ PayPal (Payments) β
βββββββββββββββββββββββββββββββββ¬ββββββββββββββββββββββββββββββββββ
β
Prisma ORM
β
βββββββββββββββββββββββββββββββββ΄ββββββββββββββββββββββββββββββββββ
β PostgreSQL Database β
β Tables: User, Product, Cart, CartItem, Order, OrderItem, β
β Address, Coupon, FeatureBanner β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
WeaveFash/
βββ client/ # Frontend (Next.js)
β βββ public/
β β βββ images/ # Static images
β βββ src/
β β βββ app/ # App Router pages
β β β βββ auth/
β β β β βββ login/
β β β β βββ register/
β β β βββ cart/
β β β βββ checkout/
β β β βββ home-page/
β β β βββ listing/
β β β β βββ [id]/ # Dynamic product page
β β β βββ orders/
β β β βββ super-admin/
β β β β βββ coupons/
β β β β βββ orders/
β β β β βββ products/
β β β β βββ settings/
β β β βββ layout.tsx
β β β βββ page.tsx
β β βββ components/
β β β βββ common/
β β β βββ super-admin/
β β β βββ ui/ # Radix UI components
β β β βββ user/
β β βββ hooks/
β β βββ lib/
β β βββ store/ # Zustand stores
β β β βββ useAuthStore.ts
β β β βββ useProductStore.ts
β β β βββ useCartStore.ts
β β β βββ useCouponStore.ts
β β β βββ useSettingStore.ts
β β β βββ useAddressStore.ts
β β β βββ useOrderStore.ts
β β βββ utils/
β β β βββ api.ts # API routes config
β β β βββ config.ts
β β βββ middleware.ts # Route protection
β βββ next.config.ts
β βββ package.json
β
βββ server/ # Backend (Express)
β βββ prisma/
β β βββ schema.prisma # Database schema
β β βββ seed.ts # Database seeding
β βββ src/
β β βββ controllers/
β β β βββ authController.ts
β β β βββ productController.ts
β β β βββ cartController.ts
β β β βββ couponController.ts
β β β βββ settingController.ts
β β β βββ addressController.ts
β β β βββ orderController.ts
β β βββ middlewares/
β β β βββ authMiddleware.ts # JWT & role verification
β β β βββ uploadMiddleware.ts # Multer config
β β βββ routes/
β β β βββ authRoutes.ts
β β β βββ productRoutes.ts
β β β βββ cartRoutes.ts
β β β βββ couponRoutes.ts
β β β βββ settingRoutes.ts
β β β βββ addressRoutes.ts
β β β βββ orderRoutes.ts
β β βββ server.ts # Express app entry
β βββ package.json
βββ README.md
Feature
Description
ποΈ Product Browsing
Browse products with filters (category, brand, size, color, price)
π Product Search
Search and sort products
π Product Details
View detailed product information with multiple images
π Shopping Cart
Add/remove items, update quantities
π³ Secure Checkout
PayPal payment integration
ποΈ Coupon Codes
Apply discount coupons at checkout
π Address Management
Save and manage delivery addresses
π¦ Order Tracking
View order history and status
π Authentication
Register, login, logout with JWT
Feature
Description
π Dashboard
Admin control panel
π¦ Product Management
Add, edit, delete products
πΌοΈ Banner Management
Upload and manage homepage banners
β Featured Products
Select up to 8 featured products
ποΈ Coupon Management
Create and manage discount coupons
π Order Management
View all orders, update status
Feature
Description
π Route Protection
Middleware-based access control
πͺ Cookie Authentication
Secure HTTP-only cookies for tokens
π Token Refresh
Automatic access token refresh
βοΈ Cloud Storage
Cloudinary for image hosting
π± Responsive Design
Mobile-first responsive UI
β‘ State Management
Zustand for efficient state handling
π Password Security
bcrypt password hashing
Model
Description
User
Customer/Admin accounts with role-based access
Product
Fashion items with variants (sizes, colors)
Cart
User shopping cart
CartItem
Individual items in cart
Order
Customer orders
OrderItem
Products within an order
Address
Delivery addresses
Coupon
Discount codes
FeatureBanner
Homepage banner images
Enum
Values
Role
USER, SUPER_ADMIN
OrderStatus
PENDING, PROCESSING, SHIPPED, DELIVERED
PaymentMethod
CREDIT_CARD
PaymentStatus
PENDING, COMPLETED
Authentication (/api/auth)
Method
Endpoint
Description
Access
POST
/register
Create new user account
Public
POST
/login
User login
Public
POST
/logout
User logout
Public
POST
/refresh-token
Refresh access token
Public
Method
Endpoint
Description
Access
GET
/fetch-admin-products
Get all products (admin)
Super Admin
GET
/fetch-client-products
Get products with filters
Authenticated
GET
/:id
Get product by ID
Authenticated
POST
/create-new-product
Create product
Super Admin
PUT
/:id
Update product
Super Admin
DELETE
/:id
Delete product
Super Admin
Method
Endpoint
Description
Access
GET
/fetch-cart
Get user's cart
Authenticated
POST
/add-to-cart
Add item to cart
Authenticated
PUT
/update/:id
Update item quantity
Authenticated
DELETE
/remove/:id
Remove item from cart
Authenticated
POST
/clear-cart
Clear entire cart
Authenticated
Method
Endpoint
Description
Access
GET
/fetch-all-coupons
Get all coupons
Super Admin
POST
/create-coupon
Create new coupon
Super Admin
DELETE
/:id
Delete coupon
Super Admin
Method
Endpoint
Description
Access
GET
/get-banners
Get homepage banners
Public
POST
/banners
Upload banners
Super Admin
GET
/fetch-feature-products
Get featured products
Public
POST
/update-feature-products
Update featured products
Super Admin
Method
Endpoint
Description
Access
POST
/create-paypal-order
Create PayPal order
Authenticated
POST
/capture-paypal-order
Capture PayPal payment
Authenticated
POST
/create-final-order
Create order after payment
Authenticated
GET
/get-single-order/:orderId
Get order details
Authenticated
GET
/get-order-by-user-id
Get user's orders
Authenticated
GET
/get-all-orders-for-admin
Get all orders
Super Admin
PUT
/:orderId/status
Update order status
Super Admin
Method
Endpoint
Description
Access
GET
/
Get user's addresses
Authenticated
POST
/
Create new address
Authenticated
PUT
/:id
Update address
Authenticated
DELETE
/:id
Delete address
Authenticated
π Authentication & Authorization
User registers/logs in β Server generates access & refresh tokens
Tokens stored in HTTP-only cookies
Access token used for API requests
Refresh token used to get new access token when expired
Route Type
Examples
Access
Public
/auth/login, /auth/register, /
Anyone
User
/cart, /checkout, /orders, /listing
Authenticated users
Super Admin
/super-admin/*
Super Admin role only
authenticateJwt - Verifies access token from cookies
isSuperAdmin - Checks if user has SUPER_ADMIN role
βοΈ Environment Variables
Client (client/.env.local)
NEXT_PUBLIC_API_BASE_URL = http://localhost:3001
JWT_SECRET_BACKEND = your-jwt-secret
# Server
PORT = 3001
CLIENT_BASE_URL = http://localhost:3000
# Database
DATABASE_URL = postgresql://username:password@localhost:5432/weavefash_db
# JWT
JWT_SECRET_BACKEND = your-jwt-secret
JWT_REFRESH_SECRET = your-refresh-secret
# Cloudinary
CLOUDINARY_CLOUD_NAME = your-cloud-name
CLOUDINARY_API_KEY = your-api-key
CLOUDINARY_API_SECRET = your-api-secret
# PayPal
PAYPAL_CLIENT_ID = your-paypal-client-id
PAYPAL_CLIENT_SECRET = your-paypal-client-secret
Node.js 18+
PostgreSQL database
Cloudinary account
PayPal Developer account
Clone the repository
git clone https://github.com/rohitrath0d/WeaveFash.git
cd WeaveFash
Setup Server
Configure server environment
cp .env.example .env
# Edit .env with your values
Initialize database
npx prisma generate
npx prisma migrate dev --name init
npx prisma db seed # Optional: seed sample data
Start server
Setup Client (new terminal)
Configure client environment
cp .env.example .env.local
# Edit .env.local with your values
Start client
Open browser
Script
Description
npm run dev
Start development server
npm run build
Build for production
npm run start
Start production server
npm run lint
Run ESLint
Script
Description
npm run dev
Start development server (nodemon)
npm run build
Compile TypeScript
npm run start
Start production server
npm run prisma:generate
Generate Prisma client
npm run prisma:migrate
Run database migrations
npm run prisma:seed
Seed database
Server Deployment (Render/Railway)
Connect your GitHub repository
Set build command: npm run build
Set start command: npm run start
Configure environment variables
Deploy
Client Deployment (Vercel)
Import project from GitHub
Set framework preset to Next.js
Configure environment variables
Deploy
Create PostgreSQL database
Copy connection string to DATABASE_URL
Run migrations: npx prisma migrate deploy
π Reference Documentation
Rohit Rathod