Premium Audio E-Commerce Platform
Overview โข Architecture โข Tech Stack โข Features โข Structure โข Configuration
Audify is a full-featured e-commerce platform specialized in premium audio products. Built with modern web technologies, it provides a seamless shopping experience with robust authentication, dynamic product management, and secure payment integration.
- Multi-Role Access: Separate interfaces for administrators and customers with role-based access control
- Secure Authentication: Google OAuth2 integration with traditional email/password authentication
- Advanced Shopping Cart: Real-time cart management with discount calculations
- Flexible Payment Options: Razorpay integration, Wallet, and Cash on Delivery (COD)
- Smart Promotions: Dynamic coupon and offer management system
- Digital Wallet: Built-in wallet system with transaction history
- Comprehensive Admin Panel: Product, category, order, user, and sales management
Audify follows a Layered MVC Architecture with clear separation of concerns, ensuring maintainability and scalability.
graph TD
%% Client Layer
Client[๐ Client Browser] -->|HTTP Requests| Router[Express Router]
%% Routing Layer
Router --> UserRoutes[User Routes]
Router --> AdminRoutes[Admin Routes]
Router --> ShopRoutes[Shop Routes]
Router --> CheckoutRoutes[Checkout Routes]
%% Middleware Layer
subgraph Middleware ["๐ก๏ธ Middleware Layer"]
direction TB
Auth[Authentication]
RateLimit[Rate Limiting]
Validation[Request Validation]
ErrorHandler[Error Handler]
XSS[XSS Protection]
end
UserRoutes --> Middleware
AdminRoutes --> Middleware
ShopRoutes --> Middleware
CheckoutRoutes --> Middleware
%% Controller Layer
subgraph Controllers ["๐ฎ Controller Layer"]
direction TB
AuthCtrl[Auth Controller]
ProductCtrl[Product Controller]
CartCtrl[Cart Controller]
OrderCtrl[Order Controller]
CouponCtrl[Coupon Controller]
PaymentCtrl[Payment Controller]
AdminCtrl[Admin Controllers]
end
Middleware --> Controllers
%% Service Layer
subgraph Services ["โ๏ธ Service Layer"]
direction TB
AuthService[Auth Service]
ProductService[Product Service]
CartService[Cart Service]
OrderService[Order Service]
CouponService[Coupon Service]
PaymentService[Payment Service]
UploadService[Upload Service]
end
Controllers --> Services
%% Data Layer
subgraph DataLayer ["๐พ Data Access Layer"]
direction TB
UserModel[(User Model)]
ProductModel[(Product Model)]
OrderModel[(Order Model)]
CartModel[(Cart Model)]
CouponModel[(Coupon Model)]
end
Services --> DataLayer
%% External Services
subgraph External ["๐ External Services"]
direction TB
MongoDB[(MongoDB Database)]
Cloudinary[Cloudinary CDN]
Razorpay[Razorpay Gateway]
GoogleAuth[Google OAuth2]
EmailService[Nodemailer]
end
DataLayer --> MongoDB
UploadService -.->|Image Upload| Cloudinary
PaymentService -.->|Payment| Razorpay
AuthService -.->|OAuth| GoogleAuth
AuthService -.->|Notifications| EmailService
%% Styling
classDef default fill:none,stroke:#30363d,stroke-width:1px,color:#c9d1d9;
classDef client fill:#388bfd26,stroke:#388bfd,stroke-width:2px,color:#c9d1d9,rx:5,ry:5;
classDef routing fill:#388bfd26,stroke:#388bfd,stroke-width:2px,color:#c9d1d9,rx:5,ry:5;
classDef controller fill:#2386362e,stroke:#2ea043,stroke-width:2px,color:#c9d1d9,rx:5,ry:5;
classDef service fill:#d2992226,stroke:#d29922,stroke-width:2px,color:#c9d1d9,rx:5,ry:5;
classDef data fill:#f8514926,stroke:#f85149,stroke-width:2px,color:#c9d1d9,rx:5,ry:5;
classDef external fill:#9e6a0326,stroke:#9e6a03,stroke-width:2px,color:#c9d1d9,rx:5,ry:5;
class Client client;
class Router,UserRoutes,AdminRoutes,ShopRoutes,CheckoutRoutes routing;
class AuthCtrl,ProductCtrl,CartCtrl,OrderCtrl,CouponCtrl,PaymentCtrl,AdminCtrl controller;
class AuthService,ProductService,CartService,OrderService,CouponService,PaymentService,UploadService service;
class UserModel,ProductModel,OrderModel,CartModel,CouponModel data;
class MongoDB,Cloudinary,Razorpay,GoogleAuth,EmailService external;
style Middleware fill:#1b1e23ff,stroke:#388bfd,stroke-width:2px,rx:10,ry:10
style Controllers fill:#1b1e23ff,stroke:#2ea043,stroke-width:2px,rx:10,ry:10
style Services fill:#1b1e23ff,stroke:#d29922,stroke-width:2px,rx:10,ry:10
style DataLayer fill:#1b1e23ff,stroke:#f85149,stroke-width:2px,rx:10,ry:10
style External fill:#1b1e23ff,stroke:#9e6a03,stroke-width:2px,rx:10,ry:10
- MVC Architecture: Clear separation between Models, Views, and Controllers
- Service Layer Pattern: Business logic encapsulated in reusable service classes
- Middleware Pattern: Request processing pipeline for authentication, validation, and error handling
- Repository Pattern: Data access abstraction through Mongoose models
| Tool | Technology | Purpose |
|---|---|---|
| Linter | ESLint | Code quality and style checking |
| Formatter | Prettier | Code formatting |
| Development Server | Nodemon | Auto-restart on file changes |
| Logger | Winston | Application logging |
| Validation | express-validator | Request data validation |
| Rate Limiting | express-rate-limit | API rate limiting protection |
| Git Hooks | Husky | Automated pre-commit checks |
| Staged Linting | lint-staged | Run linters on staged files only |
- โ User registration with email/password
- โ Google OAuth2 social login
- โ Secure password hashing with bcrypt
- โ Session-based authentication
- โ Account status management (Active/Inactive)
- โ Profile management with personal details
- โ Product Browse & Search: Explore audio products with detailed descriptions
- โ Product Filtering: Filter by category, price, and availability
- โ Wishlist Management: Save products for later
- โ Shopping Cart: Real-time cart updates with quantity management
- โ Multiple Addresses: Save and manage multiple delivery addresses
- โ Stock Validation: Real-time stock availability checks
- โ
Multiple Payment Methods:
- Razorpay online payment gateway
- Digital wallet
- Cash on Delivery (COD)
- โ Coupon System: Apply discount coupons at checkout
- โ Dynamic Pricing: Automatic discount and offer calculations
- โ Order Confirmation: Email notifications on successful order placement
- โ Wallet balance management
- โ Credit/Debit transaction tracking
- โ Transaction history with descriptions
- โ Order tracking with status updates
- โ Order history with detailed information
- โ Order cancellation with automatic refunds to wallet
- โ Invoice generation (PDF download)
- โ Sales Dashboard: Visual sales analytics with Chart.js
- โ Sales Reports: Generate reports by day, week, month, year, or custom date range
- โ Report Export: Download reports as PDF or Excel
- โ Revenue Tracking: Monitor total revenue and order statistics
- โ CRUD Operations: Create, Read, Update, Delete products
- โ Image Management: Upload product images via Cloudinary
- โ Stock Management: Track and update product inventory
- โ Product Activation: Enable/disable product visibility
- โ Category Association: Link products to specific categories
- โ Category CRUD: Full category lifecycle management
- โ Category-based Organization: Organize products by audio categories
- โ Order Overview: View all customer orders
- โ Status Updates: Update order status (Pending โ Processed โ Shipped โ Delivered)
- โ Order Cancellation: Process order cancellations
- โ User Listing: View all registered customers
- โ Account Control: Block/Unblock user accounts
- โ User Activity Monitoring: Track user status and activity
- โ
Coupon Management:
- Create discount coupons (percentage or fixed amount)
- Set minimum cart value requirements
- Define validity periods
- Usage limit controls
- Track coupon usage by users
- โ
Offer Management:
- Product-specific offers
- Category-wide offers
- Referral bonuses
- Dynamic discount calculations
- โ XSS Protection: Input sanitization with xss-clean
- โ Rate Limiting: Protection against brute-force attacks
- โ Secure Sessions: HTTP-only cookies with secure flags
- โ Password Security: bcrypt hashing with salt rounds
- โ Input Validation: express-validator for request validation
- โ Error Handling: Centralized error handling middleware
audify-ejs/
โโโ src/
โ โโโ config/ # โ๏ธ Configuration files
โ โ โโโ cloudinary.js # Cloudinary setup
โ โ โโโ database.js # MongoDB connection
โ โ โโโ logger.js # Winston logger configuration
โ โ โโโ razorpay.js # Razorpay payment gateway
โ โ
โ โโโ constants/ # ๐ Application constants
โ โ โโโ statusCodes.js # HTTP status code constants
โ โ
โ โโโ controllers/ # ๐ฎ Route handlers
โ โ โโโ admin/ # Admin-specific controllers
โ โ โ โโโ adminAuthController.js
โ โ โ โโโ couponManagementController.js
โ โ โ โโโ offerManagementController.js
โ โ โ โโโ orderManagementController.js
โ โ โ โโโ salesReportController.js
โ โ โ โโโ userManagementController.js
โ โ โโโ accountController.js
โ โ โโโ authController.js
โ โ โโโ cartController.js
โ โ โโโ categoryController.js
โ โ โโโ checkoutController.js
โ โ โโโ couponController.js
โ โ โโโ orderController.js
โ โ โโโ paymentController.js
โ โ โโโ productController.js
โ โ โโโ shopController.js
โ โ
โ โโโ middleware/ # ๐ก๏ธ Custom middleware
โ โ โโโ validators/ # Validation schemas
โ โ โโโ adminAuth.js # Admin authentication
โ โ โโโ errorHandler.js # Error handling
โ โ โโโ multer.js # File upload configuration
โ โ โโโ rateLimiter.js # Rate limiting rules
โ โ โโโ requestLogger.js # Request logging
โ โ โโโ userAuth.js # User authentication
โ โ
โ โโโ models/ # ๐๏ธ Mongoose schemas
โ โ โโโ address.js # Address schema
โ โ โโโ adminModel.js # Admin user schema
โ โ โโโ cart.js # Shopping cart schema
โ โ โโโ categories.js # Category schema
โ โ โโโ coupon.js # Coupon schema
โ โ โโโ offer.js # Offer schema
โ โ โโโ order.js # Order schema
โ โ โโโ orderItem.js # Order item schema
โ โ โโโ products.js # Product schema
โ โ โโโ userModel.js # User schema
โ โ
โ โโโ routes/ # ๐ฃ๏ธ API route definitions
โ โ โโโ accountRoutes.js # User account routes
โ โ โโโ adminRoutes.js # Admin panel routes
โ โ โโโ categoryRoutes.js # Category routes
โ โ โโโ checkoutRoutes.js # Checkout flow routes
โ โ โโโ index.js # Main router
โ โ โโโ productRoutes.js # Product routes
โ โ โโโ shopRoutes.js # Shopping routes
โ โ โโโ userRoutes.js # User authentication routes
โ โ
โ โโโ services/ # ๐ง Business logic layer
โ โ โโโ accountService.js # Account operations
โ โ โโโ authService.js # Authentication logic
โ โ โโโ cartService.js # Cart operations
โ โ โโโ categoryService.js# Category operations
โ โ โโโ couponService.js # Coupon validation & application
โ โ โโโ offerService.js # Offer calculations
โ โ โโโ orderService.js # Order processing
โ โ โโโ passport.js # Passport strategy configuration
โ โ โโโ paymentService.js # Payment processing
โ โ โโโ productService.js # Product operations
โ โ โโโ uploadService.js # Cloudinary image uploads
โ โ
โ โโโ views/ # ๐จ EJS templates
โ โ โโโ admin/ # Admin panel views
โ โ โโโ user/ # Customer-facing views
โ โ โโโ partials/ # Reusable view components
โ โ
โ โโโ public/ # ๐ Static assets
โ โ โโโ css/ # Stylesheets
โ โ โโโ js/ # Client-side JavaScript
โ โ โโโ images/ # Static images
โ โ
โ โโโ app.js # ๐ Express app configuration
โ โโโ server.js # ๐ Server entry point
โ
โโโ .env # ๐ Environment variables (not in repo)
โโโ .env.example # ๐ Environment template
โโโ .eslintrc.json # ESLint configuration
โโโ .prettierrc # Prettier configuration
โโโ .gitignore # Git ignore rules
โโโ package.json # Node.js dependencies
โโโ README.md # This file-
Clone the repository:
git clone https://github.com/ijas9118/audify-ejs.git cd audify-ejs -
Install dependencies:
npm install
-
Set up environment variables:
cp .env.example .env
Copy .env.example to .env and configure the following variables:
| Variable | Description | Example |
|---|---|---|
MONGO_URI |
MongoDB connection string | mongodb://localhost:27017/audify |
PORT |
Server port | 3000 |
SESSION_SECRET |
Secret key for session encryption | Generate with: openssl rand -base64 32 |
NODE_ENV |
Application environment | development or production |
CLOUDINARY_CLOUD_NAME |
Cloudinary cloud name | Get from Cloudinary dashboard |
CLOUDINARY_API_KEY |
Cloudinary API key | Get from Cloudinary dashboard |
CLOUDINARY_API_SECRET |
Cloudinary API secret | Get from Cloudinary dashboard |
RAZORPAY_KEY_ID |
Razorpay key ID for payments | Get from Razorpay dashboard |
RAZORPAY_SECRET |
Razorpay secret key | Get from Razorpay dashboard |
GOOGLE_CLIENT_ID |
Google OAuth2 client ID | Get from Google Cloud Console |
GOOGLE_CLIENT_SECRET |
Google OAuth2 client secret | Get from Google Cloud Console |
EMAIL_USER |
Email address for Nodemailer | SMTP email address |
EMAIL_PASS |
Email password/app password | SMTP password |
Development mode (with auto-restart):
npm run devProduction mode:
npm startLinting:
npm run lint # Check for issues
npm run lint:fix # Auto-fix issuesCode formatting:
npm run formatThe application will be available at http://localhost:3000 (or your configured PORT).
graph LR
Start([Visit Site]) --> Browse[Browse Products]
Browse --> Login{Logged In?}
Login -->|No| Auth[Sign Up / Login]
Login -->|Yes| Cart[Add to Cart]
Auth --> Cart
Cart --> Checkout[Checkout]
Checkout --> Payment[Select Payment]
Payment --> Order[Order Placed]
Order --> Track[Track Order]
style Start fill:#388bfd26,stroke:#388bfd
style Auth fill:#d2992226,stroke:#d29922
style Order fill:#2386362e,stroke:#2ea043
style Track fill:#f8514926,stroke:#f85149
graph LR
AdminLogin([Admin Login]) --> Dashboard[Dashboard]
Dashboard --> Products[Manage Products]
Dashboard --> Orders[Manage Orders]
Dashboard --> Users[Manage Users]
Dashboard --> Reports[Sales Reports]
Dashboard --> Promotions[Coupons & Offers]
Products --> CRUD[Create/Update/Delete]
Orders --> Status[Update Status]
Users --> Block[Block/Unblock]
Reports --> Export[Export PDF/Excel]
Promotions --> CreateOffer[Create Offers]
style AdminLogin fill:#388bfd26,stroke:#388bfd
style Dashboard fill:#2386362e,stroke:#2ea043
style Reports fill:#d2992226,stroke:#d29922
style Promotions fill:#f8514926,stroke:#f85149
This project is licensed under the MIT License.
Made with โค๏ธ for audio enthusiasts