Skip to content

awhvish/PetroShopIndia

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

109 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

PetroShopIndia

A production-grade e-commerce platform and custom CMS built with Next.js and Express, featuring automated payment (Razorpay) and logistics (Shiprocket) pipelines.

Live Demo TypeScript Next.js Express

πŸ“‹ Table of Contents

🎯 Overview

PetroShopIndia is a full-stack e-commerce platform specifically designed for petroleum products and energy solutions. The platform provides a seamless shopping experience with robust backend management, automated payment processing, and integrated logistics solutions.

Live Website: www.petroshopsindia.in

✨ Features

Customer-Facing Features

Shopping Experience

  • Product Browsing & Search

    • Advanced product search with filters
    • Category-based product organization
    • Sort by price, date, popularity
    • Best sellers section
    • New arrivals showcase
    • Today's deals and special offers
    • Product wishlist functionality
  • Product Details

    • Comprehensive product information
    • High-quality product images
    • Price display with discounts
    • Stock availability status
    • Product specifications
    • Related products suggestions

User Account Management

  • Authentication & Authorization

    • Secure user registration
    • Email/password login
    • Session management
    • Password reset functionality
    • Account verification
  • User Profile

    • Profile information management
    • Address book management
    • Order history tracking
    • Account deletion option
    • Saved preferences

Shopping Cart & Checkout

  • Shopping Cart

    • Add/remove/update cart items
    • Real-time cart updates
    • Cart persistence across sessions
    • Cart item quantity management
    • Price calculation with taxes
  • Checkout Process

    • Multi-step checkout flow
    • Address selection/addition
    • Payment method selection
    • Order summary review
    • Order confirmation

Payment Integration

  • Razorpay Payment Gateway
    • Secure payment processing
    • Multiple payment methods support
    • Real-time payment verification
    • Payment failure handling
    • Transaction tracking
    • Automated payment receipts

Order Management

  • Order Tracking

    • Real-time order status updates
    • Order history view
    • Order details page
    • Invoice generation
    • Return/refund initiation
  • Shipping Integration

    • Shiprocket logistics integration
    • Automated shipment creation
    • Real-time tracking information
    • Delivery status updates
    • Shipping cost calculation

Customer Support

  • Support System
    • Support ticket creation
    • Ticket status tracking
    • Support center access
    • Contact information
    • FAQ section

Admin Features (CMS)

Product Management

  • Product CRUD Operations
    • Create new products
    • Edit product information
    • Delete products
    • Bulk product operations
    • Product image upload/management
    • Inventory management
    • SKU management
    • Category assignment
    • Tag management (Best Seller, New Arrival, Today's Deals)

Order Management

  • Order Processing
    • View all orders dashboard
    • Order status management
    • Order details view
    • Customer information access
    • Payment verification
    • Shipping label generation
    • Bulk order processing
    • Order analytics

User Management

  • Customer Database
    • User listing and search
    • User details view
    • User activity tracking
    • Account management
    • Permission controls

Content Management

  • Static Pages
    • About Us page editor
    • Contact Us page management
    • Policy pages (Return, Shipping, Privacy, Terms)
    • Custom page creation
    • SEO metadata management

Analytics & Reporting

  • Business Intelligence
    • Sales analytics
    • Revenue tracking
    • Product performance metrics
    • Customer insights
    • Order statistics
    • Conversion tracking

Settings & Configuration

  • Platform Settings
    • Payment gateway configuration
    • Shipping provider settings
    • Tax configuration
    • Email templates
    • Notification settings
    • Theme customization

Technical Features

Performance Optimization

  • Frontend Optimization

    • Server-side rendering (SSR)
    • Static site generation (SSG)
    • Image optimization
    • Code splitting
    • Lazy loading
    • Caching strategies
  • Backend Optimization

    • Database query optimization
    • API response caching
    • Connection pooling
    • Load balancing ready

Security Features

  • Data Protection
    • HTTPS encryption
    • Secure authentication
    • Password hashing
    • XSS protection
    • CSRF protection
    • SQL injection prevention
    • Rate limiting
    • Input validation
    • Secure session management

SEO Features

  • Search Engine Optimization
    • Meta tags management
    • Structured data markup
    • Sitemap generation
    • Canonical URLs

Responsive Design

  • Multi-Device Support
    • Mobile-first design
    • Tablet optimization
    • Desktop layouts
    • Touch-friendly interface
    • Adaptive images

Email Notifications

  • Automated Emails
    • Order confirmation emails
    • Shipping notifications
    • Payment receipts
    • Password reset emails
    • Account verification
    • Promotional emails

API Integration

  • Third-Party Services
    • Razorpay payment gateway
    • Shiprocket shipping API
    • Email service integration
    • SMS notifications
    • Analytics integration

πŸ›  Tech Stack

Frontend (Client)

  • Framework: Next.js (React)
  • Language: TypeScript
  • Styling: CSS Modules / Tailwind CSS
  • State Management: Zustand
  • HTTP Client: Axios
  • Forms: React Hook Form
  • Validation: Zod

Backend (Server)

  • Runtime: Node.js
  • Framework: Express.js
  • Language: TypeScript
  • Database: MongoDB
  • ORM: Prisma
  • Authentication: JWT / Session-based
  • File Upload: Multer
  • Validation: Express Validator

Third-Party Integrations

  • Payment: Razorpay
  • Shipping: Shiprocket
  • Email: NodeMailer
  • Cloud Storage: Cloudinary

DevOps & Deployment

  • CI/CD: GitHub Actions
  • Hosting: Vercel
  • Containerization: Docker

πŸ— Architecture

Monorepo Structure

PetroShopIndia/
β”œβ”€β”€ client/                 # Next.js frontend application
β”‚   β”œβ”€β”€ components/         # Reusable React components
β”‚   β”œβ”€β”€ pages/             # Next.js pages and routes
β”‚   β”œβ”€β”€ styles/            # CSS/styling files
β”‚   β”œβ”€β”€ utils/             # Utility functions
β”‚   β”œβ”€β”€ hooks/             # Custom React hooks
β”‚   β”œβ”€β”€ context/           # React Context providers
β”‚   β”œβ”€β”€ services/          # API service layer
β”‚   └── public/            # Static assets
β”‚
β”œβ”€β”€ server/                # Express backend application
β”‚   β”œβ”€β”€ controllers/       # Route controllers
β”‚   β”œβ”€β”€ models/           # Database models
β”‚   β”œβ”€β”€ routes/           # API routes
β”‚   β”œβ”€β”€ middleware/       # Express middleware
β”‚   β”œβ”€β”€ services/         # Business logic
β”‚   β”œβ”€β”€ utils/            # Utility functions
β”‚   β”œβ”€β”€ config/           # Configuration files
β”‚   └── integrations/     # Third-party integrations
β”‚
β”œβ”€β”€ .github/workflows/     # CI/CD workflows
β”œβ”€β”€ .gitignore
β”œβ”€β”€ package.json
└── README.md

Data Flow

  1. Client Request β†’ Next.js frontend
  2. API Call β†’ Express backend
  3. Business Logic β†’ Service layer
  4. Data Access β†’ ORM
  5. External Services β†’ Razorpay/Shiprocket APIs
  6. Response β†’ Client

πŸš€ Getting Started

Prerequisites

  • Node.js (v16 or higher)
  • npm or yarn
  • MongoDB
  • Razorpay account
  • Shiprocket account

Installation

  1. Clone the repository
git clone https://github.com/awhvish/PetroShopIndia.git
cd PetroShopIndia
  1. Install dependencies
# Install root dependencies
npm install

# Install client dependencies
cd client
npm install

# Install server dependencies
cd ../server
npm install
  1. Environment Configuration

Create .env files in both client and server directories:

Server .env:

# Database
DATABASE_URL=your_database_url

# Server
PORT=5000
NODE_ENV=development

# JWT
JWT_SECRET=your_jwt_secret
JWT_EXPIRES_IN=7d

# Razorpay
RAZORPAY_KEY_ID=your_razorpay_key_id
RAZORPAY_KEY_SECRET=your_razorpay_key_secret

# Shiprocket
SHIPROCKET_EMAIL=your_shiprocket_email
SHIPROCKET_PASSWORD=your_shiprocket_password

# Email
EMAIL_HOST=smtp.gmail.com
EMAIL_PORT=587
EMAIL_USER=your_email
EMAIL_PASSWORD=your_email_password

# Client URL
CLIENT_URL=http://localhost:3000

Client .env:

# API
NEXT_PUBLIC_API_URL=http://localhost:5000/api

# Razorpay
NEXT_PUBLIC_RAZORPAY_KEY_ID=your_razorpay_key_id
  1. Database Setup
cd server
npm run migrate  # Run database migrations
npm run seed     # Seed initial data (if available)
  1. Run the application

Development mode:

# Terminal 1 - Run server
cd server
npm run dev

# Terminal 2 - Run client
cd client
npm run dev

Production mode:

# Build client
cd client
npm run build
npm start

# Build server
cd server
npm run build
npm start
  1. Access the application

πŸ“ Project Structure

Client Structure

client/
β”œβ”€β”€ components/
β”‚   β”œβ”€β”€ layout/           # Header, Footer, Navigation
β”‚   β”œβ”€β”€ product/          # Product cards, lists
β”‚   β”œβ”€β”€ cart/             # Cart components
β”‚   β”œβ”€β”€ checkout/         # Checkout flow
β”‚   β”œβ”€β”€ user/             # User profile, auth
β”‚   └── common/           # Buttons, inputs, modals
β”œβ”€β”€ pages/
β”‚   β”œβ”€β”€ index.tsx         # Homepage
β”‚   β”œβ”€β”€ search.tsx        # Product search
β”‚   β”œβ”€β”€ auth.tsx          # Authentication
β”‚   β”œβ”€β”€ cart.tsx          # Shopping cart
β”‚   β”œβ”€β”€ orders.tsx        # Order history
β”‚   β”œβ”€β”€ profile.tsx       # User profile
β”‚   └── [slug].tsx        # Dynamic routes
└── styles/
    └── globals.css       # Global styles

Server Structure

server/
β”œβ”€β”€ controllers/
β”‚   β”œβ”€β”€ auth.controller.ts
β”‚   β”œβ”€β”€ product.controller.ts
β”‚   β”œβ”€β”€ order.controller.ts
β”‚   β”œβ”€β”€ user.controller.ts
β”‚   └── payment.controller.ts
β”œβ”€β”€ models/
β”‚   β”œβ”€β”€ User.model.ts
β”‚   β”œβ”€β”€ Product.model.ts
β”‚   β”œβ”€β”€ Order.model.ts
β”‚   └── Payment.model.ts
β”œβ”€β”€ routes/
β”‚   β”œβ”€β”€ auth.routes.ts
β”‚   β”œβ”€β”€ product.routes.ts
β”‚   β”œβ”€β”€ order.routes.ts
β”‚   └── payment.routes.ts
β”œβ”€β”€ middleware/
β”‚   β”œβ”€β”€ auth.middleware.ts
β”‚   β”œβ”€β”€ validation.middleware.ts
β”‚   └── error.middleware.ts
└── services/
    β”œβ”€β”€ razorpay.service.ts
    β”œβ”€β”€ shiprocket.service.ts
    └── email.service.ts

πŸ“š API Documentation

Authentication Endpoints

POST   /api/auth/register          # User registration
POST   /api/auth/login             # User login
POST   /api/auth/logout            # User logout
POST   /api/auth/forgot-password   # Password reset request
POST   /api/auth/reset-password    # Password reset
GET    /api/auth/verify-email      # Email verification

Product Endpoints

GET    /api/products               # Get all products (with filters)
GET    /api/products/:id           # Get product by ID
POST   /api/products               # Create product (Admin)
PUT    /api/products/:id           # Update product (Admin)
DELETE /api/products/:id           # Delete product (Admin)
GET    /api/products/search        # Search products
GET    /api/products/categories    # Get categories

Cart Endpoints

GET    /api/cart                   # Get user cart
POST   /api/cart/add               # Add item to cart
PUT    /api/cart/update/:id        # Update cart item
DELETE /api/cart/remove/:id        # Remove cart item
DELETE /api/cart/clear             # Clear cart

Order Endpoints

GET    /api/orders                 # Get user orders
GET    /api/orders/:id             # Get order details
POST   /api/orders                 # Create order
PUT    /api/orders/:id/cancel      # Cancel order
GET    /api/orders/:id/track       # Track order

Payment Endpoints

POST   /api/payment/create-order   # Create Razorpay order
POST   /api/payment/verify         # Verify payment
POST   /api/payment/refund         # Process refund (Admin)

User Endpoints

GET    /api/users/profile          # Get user profile
PUT    /api/users/profile          # Update profile
GET    /api/users/addresses        # Get addresses
POST   /api/users/addresses        # Add address
DELETE /api/users/addresses/:id    # Delete address
DELETE /api/users/account          # Delete account

Support Endpoints

GET    /api/tickets                # Get user tickets
POST   /api/tickets                # Create ticket
GET    /api/tickets/:id            # Get ticket details
PUT    /api/tickets/:id            # Update ticket

🚒 Deployment

Frontend Deployment (Vercel)

  1. Connect GitHub repository to Vercel
  2. Configure environment variables
  3. Deploy automatically on push to main

Backend Deployment Options

Option 1: DigitalOcean/AWS

# Build the application
npm run build

# Use PM2 for process management
pm2 start dist/server.js --name petroshop-api

Option 2: Docker

# Dockerfile example
FROM node:16-alpine
WORKDIR /app
COPY package*.json ./
RUN npm install --production
COPY . .
RUN npm run build
EXPOSE 5000
CMD ["npm", "start"]

Database Deployment

  • Use managed database services (AWS RDS, MongoDB Atlas)
  • Configure connection pooling
  • Set up automated backups

CI/CD Pipeline

The project uses GitHub Actions for automated testing and deployment:

  • Automated testing on pull requests
  • Deployment on merge to main branch
  • Environment-specific deployments

🀝 Contributing

Contributions are welcome! Please follow these guidelines:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

Code Style

  • Follow TypeScript best practices
  • Use ESLint and Prettier
  • Write meaningful commit messages
  • Add tests for new features

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ‘¨β€πŸ’» Author

Awhvish

πŸ“ž Contact

πŸ™ Acknowledgments

  • Next.js team for the amazing framework
  • Razorpay for payment processing
  • Shiprocket for logistics integration
  • All contributors and users of the platform

Note: This is a production-grade application. Make sure to properly configure all environment variables and security settings before deployment.

About

A production-grade e-commerce platform and custom CMS built with Next.js and Express, featuring automated payment (Razorpay) and logistics (Shiprocket) pipelines.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages