Skip to content

Repository files navigation

🛍️ Shop Platform

A modern full-stack e-commerce platform | NestJS + Next.js + Turborepo

CI NestJS Next.js Prisma PostgreSQL Tailwind CSS Turborepo TypeScript PWA License

A full-stack e-commerce platform with product management, order processing, Iranian payment gateways, vendor panel, admin dashboard, PWA support, blog, and SEO — all in a professional monorepo structure. Fully customizable via environment variables.


✨ Features

🏪 Storefront (Customer)

  • Homepage — Banner slider, featured products, category showcase, page builder
  • Product Listing — Search, category/price filters, sorting, pagination
  • Product Detail — Image gallery, reviews, ratings, JSON-LD structured data
  • Shopping Cart — localStorage-based, quantity management, saved items
  • Checkout — Shipping method selection, coupon codes, payment gateway choice
  • User Profile — Personal info, order history, wallet, wishlist, addresses
  • Authentication — Register/Login with JWT, OTP via SMS/console
  • Compare Products — Side-by-side product comparison
  • PWA — Installable, offline fallback page, service worker with runtime caching

📝 Blog & SEO

  • Blog — Posts with categories, tags, comments, pagination
  • SEO Metadata — Per-page OG, Twitter cards, canonical URLs
  • JSON-LD — Organization, WebSite (SearchAction), Article, BreadcrumbList, Product schemas
  • Sitemap — Auto-generated XML with products, categories, pages, blog posts
  • robots.txt — Configurable via env var

👑 Admin Panel

  • Dashboard — Real-time sales, orders, users, products stats
  • Product Management — Full CRUD with image upload, pricing, categorization
  • Category Management — Hierarchical parent/child categories
  • Order Management — View, status updates (confirm/ship/deliver/cancel), advanced filters
  • Discount Management — Percentage & fixed coupons with expiration
  • User Management — User list, details, order history per user
  • Vendor Management — Active vendor shops management
  • Reports — Sales & performance analytics
  • Settings — Store configuration, SEO, contact info
  • Rich Text Editor — Tiptap-based content editing

🧑‍💼 Vendor Panel

  • Vendor Dashboard — Personal store stats (products, orders, revenue)
  • My Products — Manage your own products
  • My Orders — View orders for your products

💳 Payment Gateways

  • Zarinpal — Live integration with API v4
  • Mellat Bank — Simulated (ready for real integration)
  • Saman Bank — Simulated (ready for real integration)

📦 Shipping Methods

  • Express / Standard Post
  • TIPAX, MAHEX, Snapp Box

🌐 Persian Language Support

  • RTL — Full right-to-left support
  • Jalali Date — Using date-fns-jalali
  • Persian Numerals — Native numeral display
  • Full Persian UI — All interfaces in Persian

🔒 Security

  • Helmet — Security headers (CSP, HSTS, XSS, etc.)
  • Rate Limiting — 4 layers (Nginx → NestJS → Edge middleware → Client backoff)
  • CORS — Configured with credentials support
  • Trust Proxy — Correct IP detection behind Nginx
  • Input Validation — class-validator + sanitize-html + DOMPurify

🐳 Docker

  • Dockerfile per service (API, Store, Admin)
  • docker-compose.yml with Nginx reverse proxy
  • Production-ready deployment

🔄 CI/CD

  • GitHub Actions — Lint, build, test, E2E, CodeQL, publish
  • Dependabot — Automated dependency updates

🏗️ Architecture

shop-platform/
├── apps/
│   ├── api/          # NestJS API — port 8000
│   ├── web/          # Storefront (Next.js) — port 3000
│   └── admin/        # Admin Panel (Next.js) — port 3001
├── packages/
│   ├── shared-types/ # Shared TypeScript types
│   ├── api-client/   # Auto-generated API client
│   └── eslint-config/# Shared ESLint configuration
├── docker-compose.yml
├── nginx/
│   └── nginx.conf
├── .github/
│   └── workflows/    # CI/CD pipelines
└── turbo.json        # Turborepo configuration

Architecture Diagram

🌐 User
   │
   ▼
┌──────────────────────────────────────────────────┐
│                  Nginx (port 80)                   │
│   / → web:3000  /admin/* → admin:3001  /api → api │
│   PWA headers  |  Rate limiting  |  SSL           │
└──────────────────────────────────────────────────┘
   │           │            │
   ▼           ▼            ▼
┌──────┐  ┌────────┐  ┌──────────────┐
│ Web  │  │ Admin  │  │ API           │
│:3000 │  │:3001   │  │:8000          │
│ PWA  │  │        │  │ Helmet        │
│ SW   │  │        │  │ Rate Limit    │
└──────┘  └────────┘  └──────┬───────┘
                             │
                             ▼
                      ┌──────────────┐
                      │   Prisma     │
                      │ (PostgreSQL) │
                      └──────────────┘

🛠️ Tech Stack

Layer Technology
Backend NestJS 11, Prisma 5, Passport JWT, Swagger, Multer
Frontend (Store) Next.js 16, React 19, Tailwind CSS 4, Serwist
Frontend (Admin) Next.js 16, React 19, Tailwind CSS 4, Tiptap
Database PostgreSQL 16
Monorepo Turborepo 2, npm workspaces
Language TypeScript 5 (entire codebase)
State (Client) TanStack Query + Zustand
Authentication JWT (bcryptjs), httpOnly cookies
API Docs Swagger (OpenAPI)
CI/CD GitHub Actions + Dependabot
Container Docker + docker-compose
Jalali Date date-fns-jalali
Payment Gateway Zarinpal API v4
SMS Kavenegar (production) / Console (development)
Email Nodemailer

🚀 Quick Start

Prerequisites

  • Node.js ≥ 22
  • npm ≥ 10
  • PostgreSQL ≥ 16 (create an empty database)

Installation

# 1. Clone the repository
git clone <https://github.com/Hordekiller/Atlas-Shop>
cd shop-platform

# 2. Set up environment variables
cp .env.example .env
# Edit .env and fill in the values (database URL, JWT secret, etc.)

# 3. Install dependencies
npm install

# 4. Generate Prisma client & run migrations
npx prisma generate -w @atlas-shop/api
npx prisma migrate dev -w @atlas-shop/api

# 5. Seed the database with initial data
npm run db:seed -w @atlas-shop/api

# 6. Run all services
npm run dev

Default Credentials

Role Email Password
Super Admin admin@example.com admin123
Customer Register via website —

The first user to register automatically gets the SUPER_ADMIN role.

Service URLs

Service URL
Storefront http://localhost:3000
Admin Panel http://localhost:3001
API http://localhost:8000/api/v1
API Docs http://localhost:8000/api/docs

🐳 Docker Deployment

# Full deployment
docker compose up -d

# Services:
#   - Nginx: port 80
#   - API: port 8000
#   - Storefront: port 3000
#   - Admin Panel: port 3001

🔧 Environment Variables

Variable Required Default Description
DATABASE_URL ✅ — PostgreSQL connection string
JWT_SECRET ✅ — Secret for signing JWT tokens
ENCRYPTION_KEY ✅ — 32-char key for encrypting sensitive data
NEXT_PUBLIC_SITE_URL — http://localhost:3000 Public site URL for SEO, sitemap, PWA
NEXT_PUBLIC_SITE_NAME — فروشگاه من Brand name (titles, metadata, JSON-LD)
NEXT_PUBLIC_SITE_SHORT_NAME — فروشگاه Short brand name (PWA manifest, footer)
NEXT_PUBLIC_SITE_DESCRIPTION — Generic description Site description (OG, metadata)
NEXT_PUBLIC_API_URL — http://localhost:8000/... Client-side API URL
SITE_NAME — فروشگاه من Brand name for API (email, SMS, invoices)
SUPPORT_EMAIL — info@example.com Support email for notifications
MAIL_* — — SMTP configuration
ZARINPAL_MERCHANT_ID — — Zarinpal merchant ID
SMS_PROVIDER — console console or kavenegar
SMS_API_KEY — — Kavenegar API key

Full list in .env.example.


📸 Screenshots

🏪 Storefront

Store Store Store Store Store Store Store Store Store Store Store Store

👑 Admin Panel

Admin Admin Admin Admin Admin Admin Admin Admin Admin Admin Admin Admin Admin Admin Admin Admin Admin Admin Admin


🧪 CI/CD

The project has 4 GitHub Actions workflows:

1. CI (ci.yml)

Runs on every push/PR to main:

  • 🔍 Lint & TypeCheck — ESLint for API, tsc --noEmit for all apps
  • 🏗️ Build All Apps — Prisma generate + Turborepo build
  • 🧪 Unit Tests — Jest (AuthService tests)
  • 🧪 E2E Tests — API smoke test with PostgreSQL service

2. CodeQL (codeql.yml)

Weekly security analysis + on push/PR to main.

3. Publish (publish.yml)

Publishes packages to GitHub Packages on release.

4. Dependabot

Automated dependency updates.


🧪 Running Tests

# Unit tests (API)
npm test -w @atlas-shop/api

# E2E tests (requires PostgreSQL)
npm run test:e2e -w @atlas-shop/api

# Coverage
npm run test:cov -w @atlas-shop/api

📁 Key Scripts

Script Description
npm run dev Run all apps in development mode
npm run build Build all apps for production
npm run lint Lint and type-check all apps
npm run dev:api Run API only
npm run dev:web Run storefront only
npm run dev:admin Run admin panel only
npm run db:migrate Run Prisma migrations
npm run db:seed Seed database with sample data

🗺️ Roadmap

✅ Done

  • JWT authentication with register/login
  • Product management (CRUD + image upload)
  • Hierarchical categories
  • Shopping cart & checkout
  • Full admin panel (dashboard, orders, users, discounts)
  • Vendor panel
  • Zarinpal payment gateway
  • Shipping methods (post, TIPAX, MAHEX, SnappBox)
  • Jalali date & full RTL support
  • Docker + docker-compose
  • CI/CD with GitHub Actions + Dependabot + CodeQL
  • SQLite → PostgreSQL migration
  • Email delivery with Nodemailer
  • Security hardening (Helmet, rate limiting, trust proxy, CORS)
  • Code quality (ConfigModule, exception filter, logging)
  • Rate limiting (4 layers: Nginx → NestJS → Edge → Client)
  • PWA (installable with service worker + offline fallback)
  • Blog with hybrid Server/Client pattern
  • SEO (JSON-LD, OG, Twitter cards, sitemap, robots.txt)
  • SMS (Kavenegar + console fallback)
  • Invoice PDF generation

🔜 Planned

  • Real-time notifications (WebSockets)
  • Advanced discount system (smart coupons)
  • Inventory & warehouse management
  • Returns & refunds system
  • Multi-vendor marketplace
  • Affiliate system
  • Wishlist sharing
  • PWA push notifications
  • i18n / multi-language support

🤝 Contributing

  1. Fork it 🍴
  2. Create a feature branch (git checkout -b feature/amazing)
  3. Commit (git commit -m 'feat: add amazing feature')
  4. Push (git push origin feature/amazing)
  5. Open a Pull Request 🎉

See CONTRIBUTING.md for more details.


📜 License

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


Made with ❤️

About

Atlas Shop — Modern e-commerce platform (NestJS 11, Next.js 16, Prisma 5, Turborepo) with PWA, SEO, Zarinpal payment gateway, admin panel, SMS OTP, and 4-layer rate limiting

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

11 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages