Skip to content

OdayIbrahimDev/mawjaa

Repository files navigation

Mawjaa - Multi-tenant E-commerce (Node.js, Express, MongoDB, Next.js)

Production-ready SaaS scaffolding with subdomain multi-tenancy. Backend (Express + TS + MongoDB) and Frontend (Next.js) in a monorepo.

Prerequisites

  • Node.js 18+
  • MongoDB 6+

Setup

  1. Backend
  • Create backend/.env:
PORT=4000
MONGODB_URI=mongodb://localhost:27017
MONGODB_DB=mawjaa
JWT_SECRET=change-me
JWT_EXPIRES_IN=7d
MAIN_DOMAIN=localhost
CORS_ORIGIN=http://localhost:3000
  • Install and run:
cd backend
npm install
npm run dev
  1. Frontend
  • Create frontend/.env.local:
NEXT_PUBLIC_API_URL=http://localhost:4000
NEXT_PUBLIC_MAIN_DOMAIN=localhost
  • Install and run:
cd frontend
npm install
npm run dev

Development URLs

  • App landing: http://localhost:3000/
  • Storefront: http://localhost:3000/mystore (or configure DNS/hosts to use mystore.localhost)
  • API base: http://localhost:4000

Basic Flow

  1. Register: POST /api/auth/register or via UI /register
  2. Create store /create-store (enforces single store per user)
  3. Dashboard /dashboard to manage products
  4. Storefront /[subdomain] lists products scoped by storeId

Deployment Notes

  • Use a wildcard DNS record *.myapp.com to your frontend and route via Next.js middleware.
  • Set NEXT_PUBLIC_MAIN_DOMAIN=myapp.com and MAIN_DOMAIN=myapp.com in envs.
  • Place backend behind HTTPS reverse proxy; allow CORS from your frontend origin.
  • Configure process manager (PM2) or containerize; set proper secrets.

mawjaa-01

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published