Skip to content

kannanCodes/Chapterless

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

128 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ“š Chapterless - E-Commerce Bookstore Platform

Node.js MongoDB Express.js Bootstrap

A comprehensive e-commerce platform built with the MERN stack, specifically designed for book retail with advanced features including payment integration, order management, and promotional systems.

πŸš€ Live Demo

Repository: https://github.com/kannan-innovates/chapterless

πŸ“‹ Table of Contents

✨ Features

πŸ›’ E-Commerce Core

  • Product Catalog: Comprehensive book inventory with categories, authors, and detailed descriptions
  • Shopping Cart: Real-time cart management with quantity controls and price calculations
  • Wishlist: Save products for later with bulk cart transfer functionality
  • Search & Filter: Advanced product search with category and price filtering
  • Product Recommendations: Top-selling and new arrival sections

πŸ’³ Payment & Checkout

  • Multiple Payment Methods:
    • Cash on Delivery (COD) with order value restrictions
    • Razorpay integration for online payments
    • Wallet payments with instant processing
  • Smart Checkout: Multi-step checkout with address management
  • Order Validation: Comprehensive order verification and processing

πŸ‘€ User Management

  • Authentication System: Secure login/signup with email verification
  • OTP Verification: Email-based OTP for account security
  • Profile Management: Complete user profile with address management
  • Password Security: Secure password change functionality

🎯 Promotional System

  • Coupon Management:
    • Fixed and percentage-based discounts
    • Category and product-specific coupons
    • Usage limits and expiry management
  • Offer System:
    • Product-specific offers
    • Category-wide promotions
    • Automatic discount calculations
  • Referral Program:
    • Unique referral codes for each user
    • Wallet rewards for successful referrals (β‚Ή100 for referrer, β‚Ή50 for new user)

πŸ’° Wallet System

  • Digital Wallet: Secure wallet with transaction history
  • Refund Processing: Automatic refunds for cancellations and returns
  • Transaction Tracking: Detailed transaction logs with pagination
  • Balance Management: Real-time balance updates

πŸ“¦ Order Management

  • Order Tracking: Complete order lifecycle management
  • Cancellation System:
    • Full order cancellation
    • Individual item cancellation
    • Intelligent refund calculations
  • Return Management:
    • Return request system
    • Admin approval workflow
    • Automated refund processing
  • Invoice Generation: PDF invoice download functionality

πŸ”§ Admin Panel

  • Dashboard Analytics:
    • Sales charts with multiple time filters
    • Best-selling products, categories, and authors
    • Revenue and order statistics
  • User Management: User blocking/unblocking with search functionality
  • Product Management: Complete CRUD operations with image upload
  • Order Management: Order status updates and tracking
  • Return Processing: Bulk return request handling
  • Sales Reports: Excel and PDF export functionality

πŸ›  Tech Stack

Backend

  • Runtime: Node.js 18.x
  • Framework: Express.js 4.x
  • Database: MongoDB with Mongoose ODM
  • Authentication: Express-session with secure configuration
  • File Upload: Multer for image handling
  • Payment: Razorpay integration
  • Email: Nodemailer for OTP and notifications

Frontend

  • Template Engine: EJS (Embedded JavaScript)
  • Styling: Bootstrap 5.x with custom CSS
  • Icons: Bootstrap Icons & Remix Icons
  • Charts: Chart.js for analytics
  • Notifications: SweetAlert2 for user feedback

Security & Validation

  • Password Hashing: bcrypt
  • Input Validation: Custom validation middleware
  • Session Security: Secure session configuration
  • CSRF Protection: Built-in security measures

πŸš€ Installation

Prerequisites

  • Node.js (v18.x or higher)
  • MongoDB (v6.x or higher)
  • npm or yarn package manager

Setup Instructions

  1. Clone the repository

    git clone https://github.com/kannan-innovates/chapterless.git
    cd chapterless
  2. Install dependencies

    npm install
  3. Environment Configuration Create a .env file in the root directory:

    PORT=3001
    MONGODB_URI=mongodb://localhost:27017/chapterless
    SESSION_SECRET=your_session_secret_key
    
    # Razorpay Configuration
    RAZORPAY_KEY_ID=your_razorpay_key_id
    RAZORPAY_KEY_SECRET=your_razorpay_key_secret
    
    # Email Configuration
    EMAIL_USER=your_email@gmail.com
    EMAIL_PASS=your_app_password
  4. Start the application

    # Development mode
    npm run dev
    
    # Production mode
    npm start
  5. Access the application

    • User Interface: http://localhost:3001
    • Admin Panel: http://localhost:3001/admin/adminLogin

βš™οΈ Configuration

Database Setup

The application uses MongoDB with the following collections:

  • Users (with admin roles)
  • Products (books with categories)
  • Orders (with item-level tracking)
  • Carts & Wishlists
  • Coupons & Offers
  • Wallets (with transaction history)
  • Referrals

Admin Account

Create an admin user in MongoDB:

{
  fullName: "Admin User",
  email: "admin@chapterless.com",
  password: "hashed_password", // Use bcrypt
  isAdmin: true,
  isBlocked: false
}

πŸ“ Project Structure

chapterless/
β”œβ”€β”€ controllers/           # Business logic
β”‚   β”œβ”€β”€ adminController/   # Admin panel controllers
β”‚   └── userController/    # User-facing controllers
β”œβ”€β”€ models/               # MongoDB schemas
β”œβ”€β”€ routes/               # Express route definitions
β”‚   β”œβ”€β”€ adminRoutes/      # Admin panel routes
β”‚   └── userRoutes/       # User-facing routes
β”œβ”€β”€ views/                # EJS templates
β”‚   β”œβ”€β”€ admin/            # Admin panel views
β”‚   β”œβ”€β”€ user/             # User interface views
β”‚   └── partials/         # Reusable components
β”œβ”€β”€ middlewares/          # Custom middleware
β”œβ”€β”€ validators/           # Input validation
β”œβ”€β”€ helpers/              # Utility functions
β”œβ”€β”€ utils/                # Helper utilities
β”œβ”€β”€ config/               # Configuration files
β”œβ”€β”€ public/               # Static assets
β”‚   β”œβ”€β”€ assets/           # Images and media
β”‚   β”œβ”€β”€ styles/           # CSS files
β”‚   └── js/               # Client-side JavaScript
└── app.js               # Application entry point

πŸ” Security Features

  • Session Management: Secure session configuration with httpOnly cookies
  • Password Security: bcrypt hashing with salt rounds
  • Input Validation: Comprehensive server-side validation
  • XSS Protection: Input sanitization and output encoding
  • Authentication Middleware: Route-level access control
  • Admin Protection: Separate admin authentication system

πŸ“Š Key Metrics & Analytics

  • Dashboard Analytics: Real-time sales and order statistics
  • Best Sellers: Top 10 products, categories, and authors
  • Sales Reports: Exportable reports in Excel and PDF formats
  • User Analytics: User registration and activity tracking
  • Revenue Tracking: Detailed financial reporting

🎯 Business Logic Highlights

Smart Pricing System

  • Offer Integration: Automatic application of best available offers
  • Coupon Stacking: Intelligent coupon and offer combination
  • Tax Calculation: 8% GST calculation on final amounts
  • COD Restrictions: Orders above β‚Ή1000 require online payment

Inventory Management

  • Stock Tracking: Real-time inventory updates
  • Product Variants: Support for different book editions
  • Category Management: Hierarchical category system
  • Image Management: Multiple product images with optimization

Order Processing

  • Multi-step Checkout: Address β†’ Payment β†’ Confirmation
  • Payment Verification: Razorpay signature validation
  • Order States: Placed β†’ Processing β†’ Shipped β†’ Delivered
  • Cancellation Logic: Time-based cancellation rules

Refund System

  • Intelligent Calculations: Proportional refunds for partial cancellations
  • Payment Method Aware: Different refund flows for COD vs Online payments
  • Wallet Integration: Automatic wallet credits for eligible refunds
  • Tax Handling: Proper tax refund calculations

πŸ”§ Advanced Features

Email System

  • OTP Verification: 60-second expiry with resend functionality
  • Masked Email Display: Privacy-focused email masking (abc***@example.com)
  • Order Notifications: Automated order status updates
  • Welcome Emails: New user onboarding

Session Management

  • Secure Sessions: httpOnly, secure cookie configuration
  • Auto-logout: Session timeout handling
  • Multi-device Support: Concurrent session management
  • Cache Control: Proper browser cache headers

Data Export

  • Excel Reports: Comprehensive sales data in XLSX format
  • PDF Generation: Professional invoice and report PDFs
  • Date Range Filtering: Custom date range selections
  • Bulk Operations: Mass data processing capabilities

πŸš€ Performance Optimizations

  • Database Indexing: Optimized MongoDB queries
  • Image Optimization: Compressed image storage
  • Pagination: Efficient data loading with pagination
  • Caching: Strategic caching for frequently accessed data
  • Lazy Loading: On-demand content loading

πŸ§ͺ Testing & Quality

  • Input Validation: Comprehensive server-side validation
  • Error Handling: Graceful error management
  • Logging: Detailed application logging
  • Code Organization: Modular, maintainable code structure

🀝 Contributing

  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

πŸ“ž Support

For support and queries:

πŸ“„ License

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

πŸ™ Acknowledgments

  • Bootstrap Team for the excellent UI framework
  • MongoDB for the robust database solution
  • Razorpay for seamless payment integration
  • Node.js Community for the amazing ecosystem

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

Kannan S - GitHub Profile

Always curious, always improving


⭐ If you found this project helpful, please give it a star!

Built with ❀️ for book lovers everywhere

About

E-commerce web app for buying and selling books | Node.js, Express, MongoDB, EJS.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors