How mdazfar2/ezyshop works
Project Type and Purpose
• EzyShop is a full-stack, multi-tenant e-commerce platform built on Next.js (App Router).
• It serves three user roles—Shopper (Customer), Store Manager (Seller), and Admin—each with its own UI, routes, and permissions.
• Key features include role-based auth (NextAuth), product/catalog management, cart/checkout with Razorpay, real-time updates, and media uploads via Cloudinary.
File Structure
• Top-level “app/” directory uses Next.js App Router to organize pages by role:
• app/(Customer)/…
• app/(Seller)/…
• app/admin/…
• app/api/… (serverless functions for REST endpoints)
• “components/” houses shared React UI components (Blog, Navbar, Modals, UI primitives).
• “actions/” contains client-side functions (e.g., fetch products, chat).
• “lib/” holds database configuration (Prisma → MongoDB), auth helpers, email utilities.
• “context/” and “providers/” implement React Context for theme, cart, flash alerts, sessions.
• “prisma/” defines schema.prisma and seed scripts.
• Config & infra: Dockerfile, docker-compose.yml, GitHub workflows, .env.example.
Extract Architecture Insights from README
• Tech Stack:
• Next.js + React (SSR + Client Components)
• TypeScript, Tailwind CSS
• Prisma ORM backed by MongoDB
• NextAuth for auth
• Razorpay for payments
• Cloudinary for image hosting
• Nodemailer for transactional emails
• Deployment target: Vercel (serverless functions) or Docker containers.
Main Components & Their Relationships
a. Frontend (Next.js)
– App Router pages (Customer/Seller/Admin layouts & pages)
– React Contexts & Hooks manage local UI state
– “actions/” functions invoked from UI to call API routes
b. API Layer (Next.js serverless under app/api/…)
– REST endpoints for auth, products, categories, chat, FAQ, orders, webhooks
– Uses NextAuth handlers for signup/login flows
c. Business Logic & Data Access
– “lib/prismadb.ts” exports Prisma client
– CRUD operations on MongoDB collections (stores, products, users, chats, orders)
d. External Services
– Razorpay: payment intent creation & verification
– Cloudinary: upload and serve product/store images
– Email (Nodemailer): newsletters, contact form, OTP emails
e. Database
– MongoDB collections accessed via Prisma
– Seed data lives in prisma/seed.ts and public/data/ JSON files
Architectural Patterns & Design Principles
• Separation of Concerns: UI components vs. serverless API vs. data layer
• Role-Based Routing: Folder conventions in app/ to isolate routes per user type
• Server/Client Components: Leverage Next.js App Router’s layouts, loading, error, and server components
• Context Providers: Decouple cross-cutting concerns (theme, cart, flash alerts)
• Infra as Code: Docker + GitHub Actions automate builds and deployments