Skip to content

rohitrath0d/WeaveFash

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

97 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

WeaveFash - E-Commerce Fashion Platform

πŸ“‹ Table of Contents

  1. Project Overview
  2. Tech Stack
  3. Architecture
  4. Project Structure
  5. Features
  6. Database Schema
  7. API Endpoints
  8. Authentication & Authorization
  9. Environment Variables
  10. Getting Started
  11. Deployment

🎯 Project Overview

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.

Key Highlights

  • 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

πŸ›  Tech Stack

Frontend (Client)

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

Backend (Server)

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

πŸ— Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                    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                         β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ“ Project Structure

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

✨ Features

Customer Features

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

Super Admin Features

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

Technical Features

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

πŸ—„ Database Schema

Entity Overview

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

Enums

Enum Values
Role USER, SUPER_ADMIN
OrderStatus PENDING, PROCESSING, SHIPPED, DELIVERED
PaymentMethod CREDIT_CARD
PaymentStatus PENDING, COMPLETED

πŸ”Œ API Endpoints

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

Products (/api/products)

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

Cart (/api/cart)

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

Coupons (/api/coupons)

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

Settings (/api/settings)

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

Orders (/api/order)

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

Address (/api/address)

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

Authentication Flow

  1. User registers/logs in β†’ Server generates access & refresh tokens
  2. Tokens stored in HTTP-only cookies
  3. Access token used for API requests
  4. Refresh token used to get new access token when expired

Route Protection

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

Middleware Chain

  1. authenticateJwt - Verifies access token from cookies
  2. 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 (server/.env)

# 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

πŸš€ Getting Started

Prerequisites

  • Node.js 18+
  • PostgreSQL database
  • Cloudinary account
  • PayPal Developer account

Installation

  1. Clone the repository
git clone https://github.com/rohitrath0d/WeaveFash.git
cd WeaveFash
  1. Setup Server
cd server
npm install
  1. Configure server environment
cp .env.example .env
# Edit .env with your values
  1. Initialize database
npx prisma generate
npx prisma migrate dev --name init
npx prisma db seed  # Optional: seed sample data
  1. Start server
npm run dev
  1. Setup Client (new terminal)
cd client
npm install
  1. Configure client environment
cp .env.example .env.local
# Edit .env.local with your values
  1. Start client
npm run dev
  1. Open browser

Available Scripts

Client

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

Server

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

🌐 Deployment

Server Deployment (Render/Railway)

  1. Connect your GitHub repository
  2. Set build command: npm run build
  3. Set start command: npm run start
  4. Configure environment variables
  5. Deploy

Client Deployment (Vercel)

  1. Import project from GitHub
  2. Set framework preset to Next.js
  3. Configure environment variables
  4. Deploy

Database (Supabase/Neon)

  1. Create PostgreSQL database
  2. Copy connection string to DATABASE_URL
  3. Run migrations: npx prisma migrate deploy

πŸ“š Reference Documentation


πŸ‘€ Author

Rohit Rathod


About

An Ecommerce Website

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages