How slowfound/next-prisma-tailwind-ecommerce works
Project Type and Purpose
• This is a monorepo full-stack e-commerce platform composed of two separate Next.js 14 apps:
• Admin Panel (apps/admin) – for managing products, orders, users, payments.
• Storefront (apps/storefront) – customer-facing shopping experience with blog, cart, checkout, profile.
• Shared code lives under packages/* (mail, oauth, regex, rng, slugify, sms, zarinpal) and is consumed by both apps.
• Both apps use TypeScript, Prisma ORM (PostgreSQL), TailwindCSS, shadcn/ui (Radix), Zod for validation, and Next.js App Router with React Server Components.
File Structure
• Top-level: linting/config files, apps/, packages/, bun.lockb, package.json.
• apps/admin & apps/storefront: each has Next.js source (src/app, src/components, src/lib, src/api routes), Prisma schema, Dockerfiles, .env.example.
• packages/*: lightweight utility modules (email templates & sending, OAuth helpers, regex/rng/slugify utilities, SMS gateway, Zarinpal payment).
• Authentication handled via middleware.ts in each app (verifies JWT in httpOnly cookie, injects X-USER-ID header).
• External services: Cloudinary (file uploads), email transporter (packages/mail), SMS (packages/sms), OAuth providers (Google, Apple via packages/oauth), Payment (Zarinpal via packages/zarinpal).
README Insights
• Two separate deployments (admin vs storefront).
• Uses dynamic API routes for CRUD (brands, categories, products, orders, payments, cart, profile, wishlist, subscription).
• Uses React Email Tailwind Templates for email; MDX for blog.
• Environment stored in .env, DB URL (Postgres/Supabase).
a. Main Components
• Admin Next.js App (apps/admin)
• Storefront Next.js App (apps/storefront)
• Shared Packages (mail, oauth, sms, zarinpal, etc.)
• Prisma ORM Layer
• PostgreSQL Database
• External Services:
– Cloudinary (file storage)
– SMTP/email provider
– SMS gateway
– OAuth providers (Google, Apple)
– Payment gateway (Zarinpal)
b. Relationships & Data Flow
• User → Next.js App (browser HTTP/HTTPS)
• Next.js API routes ↔ Prisma ORM ↔ PostgreSQL
• Next.js App Server (middleware.ts) injects auth context via JWT cookie
• Server Actions / API endpoints call Shared Packages → External Services
• Client-side state (app/providers, React Server Components)
c. Architectural Patterns
• Monorepo with two deployable Next.js services
• App Router pattern (folder-based routing for UI and API routes)
• Middleware for authentication (JWT in cookies)
• Shared library modules for reusability
• React Server Components & Server Actions for data fetching
d. Key Technologies
• Next.js 14 App Router, React Server Components
• Prisma ORM (PostgreSQL)
• TailwindCSS, shadcn/ui (Radix)
• Zod for schema validation
• Bun as the runtime and package manager
• Docker for containerization