# Taraneh v1 ☕
A modern **Next.js 14** e-commerce PWA focused on coffee drinks & tools.
Taraneh v1 includes:
- Full product browsing (drinks & equipment)
- Cart and checkout flow
- Orders & order details
- User account area (profile, addresses, personal info)
- Admin dashboard for products
- Authentication (phone/OTP, password, and optional Google OAuth)
- PWA support with offline capabilities
---
## Table of Contents
- [Features](#features)
- [Tech Stack](#tech-stack)
- [Project Structure](#project-structure)
- [Getting Started](#getting-started)
- [1. Prerequisites](#1-prerequisites)
- [2. Installation](#2-installation)
- [3. Environment Variables](#3-environment-variables)
- [4. Database Setup (Prisma + MongoDB)](#4-database-setup-prisma--mongodb)
- [5. Running the App](#5-running-the-app)
- [Core Architecture](#core-architecture)
- [Routing & Layouts](#routing--layouts)
- [Authentication & Sessions](#authentication--sessions)
- [Cart, Orders & Checkout](#cart-orders--checkout)
- [UI & Styling](#ui--styling)
- [PWA & Offline Support](#pwa--offline-support)
- [Development](#development)
- [Scripts](#scripts)
- [Code Style & Linting](#code-style--linting)
- [Customization](#customization)
- [Deployment](#deployment)
- [Security Notes](#security-notes)
- [License](#license)
---
## Features
- ⚛️ **Next.js 14 App Router**
- App Router architecture under `src/app` with route groups for:
- Public storefront (home, products, search)
- Auth & checkout flows
- User profile portal
- Admin dashboard
- 🔐 **Authentication**
- Credentials / password-based login
- Phone & **OTP** login flow
- Optional **Google OAuth** (if you configure Google client credentials)
- Session handling via **NextAuth**
- 🛒 **E-commerce Flow**
- Add to cart, update quantities, remove items
- Guest cart with local cart ID, merge with user cart
- Checkout with:
- Shipping information
- Delivery date selection
- Payment step
- Success payment screen
- Order listing and order details (status, items, tracking info)
- 👤 **User Account**
- Profile dashboard
- Order history with order detail view
- Address book management
- Personal info (name, national code, etc.)
- Phone change flow (with redis-backed OTP)
- Add email and password
- 📦 **Product & Catalog**
- Product detail pages with:
- Gallery and sub images
- Specifications and attributes
- Introduction text
- Reviews, likes/dislikes
- Similar products slider
- Category pages:
- Drinks
- Tools
- Search/filter pages:
- Drinks search
- Tools search
- Brand/category/price filters
- 📊 **Admin Dashboard**
- Products table and pagination
- Overview components ready for extension
- Utility functions for chart data
- 📱 **PWA-Ready**
- Service worker and manifest configured via **next-pwa**
- PWA icons for installable experience
- Runtime caching strategy
- 🎨 **Rich UI**
- TailwindCSS + DaisyUI theme
- Shadcn/Radix UI components
- Custom icon set
- Hero sliders, product sliders, and advertising banners
- Loading skeletons and smooth transitions
- 🌐 **Persian / RTL Friendly**
- Persian fonts: IRANSans, IRANYekan, Yekan
- Number translation helpers
- Persian-friendly layout and design
---
## Tech Stack
**Frontend**
- [Next.js](https://nextjs.org/) `^14.2.3` (App Router)
- [React](https://react.dev/) `^18.2.0`
- [TypeScript](https://www.typescriptlang.org/) `5.1.6`
- TailwindCSS `^3.4.1`
- DaisyUI `^3.5.0`
- Shadcn-style components + Radix UI
- MUI (`@mui/material`, icons, base)
- Swiper, Embla Carousel, PhotoSwipe for carousels/galleries
**Backend & Data**
- Prisma ORM `^5.8.1`
- **MongoDB** (via Prisma) – configured through `DATABASE_URL`
- Upstash Redis (`@upstash/redis`) for OTP and temporary state
- JSON mock data and local images for products
**Auth & Security**
- `next-auth` `^4.24.5`
- Optional Google OAuth (`GOOGLE_CLIENT_ID/SECRET`)
- `bcrypt` / `argon2` for password hashing
- `jsonwebtoken` for token handling
- Custom crypto utilities
**State & Data Fetching**
- TanStack React Query (`@tanstack/react-query`)
- Legacy `react-query` v3
- `swr` for lightweight fetching
**Tooling**
- ESLint (`next/core-web-vitals`)
- Prettier + `prettier-plugin-tailwindcss`
- PostCSS + Autoprefixer
- `next-pwa`
- Netlify Next.js plugin (optional deployment target)
---
## Project Structure
High-level structure:
```text
.
├── prisma/ # Prisma schema & metadata
├── public/
│ ├── image/ # Public product/category assets
│ ├── pwa_icons/ # PWA icons
│ ├── manifest.json # PWA manifest
│ ├── service-worker.js # Service worker entry
│ └── ... # Default Next.js public files
├── src/
│ ├── actions/ # Server actions (auth, OTP, cart, orders, user info, products)
│ ├── app/ # Next.js App Router
│ │ ├── (main_root)/ # User-facing routes
│ │ │ ├── (with_footer)/ # Home, products, search, checkout, etc.
│ │ │ └── (without_footer)/# Profile area
│ │ ├── (focus)/ # Login, shipping, payment, success flows
│ │ ├── (dash)/ # Admin dashboard
│ │ └── api/ # API routes (auth, products)
│ ├── assets/ # Images & static content (non-public)
│ ├── components/ # UI components
│ │ ├── Pages/ # Page / route-specific components
│ │ └── Util/ # Layouts, shadcn ui, icons, product cards, sliders
│ ├── constants/ # Shared constants & configuration
│ ├── hook/ # Custom React hooks
│ ├── lib/ # Auth, DB, Redis and common utilities
│ ├── style/ # Global styles & fonts
│ ├── types_validation/ # Env & schema validation (zod)
│ └── util_functions/ # Pure helper functions
├── .vscode/ # Editor configuration
├── next.config.js # Next.js + PWA configuration
├── tailwind.config.js # Tailwind theme & DaisyUI config
├── postcss.config.js
├── tsconfig.json
├── package.json
└── README.md- Node.js ≥ 18
- npm / yarn / pnpm (examples use
npm) - A MongoDB database (local or hosted, e.g. MongoDB Atlas)
- An Upstash Redis instance (or any compatible HTTP Redis) if you want OTP / phone flows
- (Optional) Google Cloud project with OAuth 2.0 credentials (for Google login)
# Clone the repository
git clone <your-repo-url> taraneh-v1
cd taraneh-v1
# Install dependencies
npm install
postinstallwill automatically runprisma generate.
Create a .env file in the project root.
⚠️ Never commit.envto version control. The.gitignoreis already configured to ignore.envand.env*.local.
Use this as a template (replace all placeholder values with your own):
# ===== Database (MongoDB via Prisma) =====
DATABASE_URL="YOUR_MONGODB_CONNECTION_STRING"
# Example (do NOT use in production):
# mongodb+srv://user:[email protected]/taraneh_db?retryWrites=true&w=majority
# ===== Google OAuth (optional; used by NextAuth) =====
GOOGLE_CLIENT_ID="YOUR_GOOGLE_OAUTH_CLIENT_ID"
GOOGLE_CLIENT_SECRET="YOUR_GOOGLE_OAUTH_CLIENT_SECRET"
# ===== NextAuth configuration =====
# Base URL of your app (in development, keep localhost)
NEXTAUTH_URL="http://localhost:3000"
# Strong random secret (e.g., `openssl rand -base64 32`)
NEXTAUTH_SECRET="YOUR_NEXTAUTH_SECRET"
# ===== Custom crypto / application secrets =====
# Used by internal crypto utilities for encryption/decryption
CRYPT_SECRET="YOUR_STRONG_CRYPTO_SECRET"
# Used for payment / external API integration (e.g., Meli gateway)
MELI_KEY="YOUR_MELI_API_KEY"
# ===== Redis (Upstash) for OTP & temporary state =====
REDIS_URL="YOUR_UPSTASH_REDIS_REST_URL"
REDIS_TOKEN="YOUR_UPSTASH_REDIS_REST_TOKEN"Additional required or optional environment variables may be validated in:
src/types_validation/env.ts
If the app logs an error about missing env vars, check that file and add any missing keys to .env.
This project uses Prisma with a MongoDB provider.
-
Ensure
DATABASE_URLin.envpoints to a valid MongoDB database. -
Open
prisma/schema.prismaand confirm the datasource is configured for MongoDB, for example:datasource db { provider = "mongodb" url = env("DATABASE_URL") }
-
Push the schema to the database:
npx prisma db push
-
(Optional) Inspect data using Prisma Studio:
npx prisma studio
npm run devThen open: http://localhost:3000
npm run build
npm startUse production mode to properly test PWA features (service worker, offline caching, install prompt, etc.).
The app uses the Next.js App Router.
Key entry points:
-
src/app/layout.tsxGlobal layout: fonts,<html>and<body>, theme, providers. -
src/app/(main_root)/(with_footer)/Public storefront with footer:page.tsx– home pagedrinks/page.tsx– drinks listingtools/page.tsx– tools listingproduct/[...slug]/page.tsx– product detailscheckout/page.tsx– checkoutsearch/*– search & filter pages
-
src/app/(main_root)/(without_footer)/profile/*User profile portal:- Dashboard
- Orders & order details
- Addresses
- Personal info
-
src/app/(focus)/Focused flows with specialized layout:users/login/*– login, OTP, password formsshipping/page.tsx– shipping steppayment/page.tsx– payment stepsuccessPayment/page.tsx– payment success
-
src/app/(dash)/dashboard/*Admin dashboard with products table and overview. -
SEO & Infra:
src/app/robots.ts– robots.txt generatorsrc/app/sitemap.ts– sitemap generatorsrc/app/not-found.tsx– 404 pagesrc/app/loading.tsx– root loading state
-
NextAuth configuration
src/lib/auth/authOptions.ts– providers, callbacks, session strategysrc/app/api/auth/[...nextauth]/route.ts– NextAuth API route
-
Session provider
src/app/SessionProvider.tswraps the app with<SessionProvider>for client components.
-
Login flows (UI)
-
src/components/Pages/Login_page/*LoginForm.tsxPhoneForm.tsxOtpForm.tsxPasswordForm.tsx
-
-
OTP & phone logic
src/actions/OTP/sendOtp.tssrc/actions/OTP/redisActions/*src/actions/userInfo/changePhone/*
-
User checks
src/actions/util/checkUser.tssrc/actions/util/getUserPhone.ts
Protected routes typically rely on next-auth session checks and these helpers.
-
Cart
-
src/actions/ordering/cart/*- Create, get, delete cart
- Local cart ID helpers:
functions/getLocalCartId.ts,setLocalCartId.ts,deleteLocalCartId.ts
-
-
Cart items
-
src/actions/ordering/cart_item/*- Add/update/remove items
- Clear cart
- Merge carts on login
-
-
Orders
-
src/actions/ordering/order/*createOrder.tsgetOrders.tsgetOrder.tscancelOrder.ts
-
-
Checkout UI
src/components/Pages/CheckOut_page/*src/components/Pages/Shipping_page/*src/components/Pages/Payment_page/*src/components/Pages/SuccessPayment_page/Success_payment.tsx
These actions are used by page components under src/app/(main_root)/(with_footer)/checkout, shipping, and payment.
-
Global styles
src/style/globals.scss
-
Tailwind configuration
-
tailwind.config.js- Custom color palette: success/error/info, multiple gray scales, brand palettes (
g1_*,g2_*,g3_*). - Custom fonts:
iransans,iransansnum,iranyekan,yekan. - Screens:
xs,sm,md,lg,xl,xxl. - Animations: accordion open/close.
- DaisyUI theme
lightTheme.
- Custom color palette: success/error/info, multiple gray scales, brand palettes (
-
-
Layout
-
Header:
src/components/Util/layouts/header/Header.tsxcomponentsfor navigation, cart menu, mobile menu, user menu
-
Footer:
src/components/Util/layouts/footer/Footer.tsx- Info, social links, newsletter, advantages
-
-
Component libraries
-
Shadcn UI components in:
src/components/Util/shadcn/ui/*(button, dialog, tooltip, toast, table, etc.)
-
Custom icon set:
src/components/Util/ui/icons/*
-
-
Product cards & sliders
-
Grid & slide variants:
src/components/Util/product_card/*
-
Home page sections:
src/components/Pages/Home_page/*
-
Ad and hero sliders:
src/components/Util/components/ad_slider/*src/components/Pages/Home_page/MainCatsSlider/*
-
PWA is configured using next-pwa in next.config.js:
- Service worker target:
dest: "public" disable: process.env.NODE_ENV === "development"→ PWA is disabled in dev, enabled in production.
Key files:
next.config.jspublic/manifest.jsonpublic/service-worker.jspublic/pwa_icons/*
To test PWA:
-
Build and start in production mode:
npm run build npm start
-
Open the site in Chrome.
-
Check Application → Manifest / Service Workers in DevTools.
-
You should see installable PWA information and an active service worker.
From package.json:
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint",
"postinstall": "prisma generate"
}npm run dev– Start Next.js development server.npm run build– Build for production.npm start– Run the production build.npm run lint– Run ESLint checks.
-
ESLint
- Config:
.eslintrc.json - Extends:
next/core-web-vitals
- Config:
-
Prettier
- Config:
prettier.config.js - Plugin:
prettier-plugin-tailwindcss(auto-sorts Tailwind classes)
- Config:
-
Tailwind
-
Purges classes from:
./src/pages/**/*.{js,ts,jsx,tsx,mdx}./src/components/**/*.{js,ts,jsx,tsx,mdx}./src/app/**/*.{js,ts,jsx,tsx,mdx}./src/**/*.{ts,tsx}
-
You can customize almost every part of the app:
-
Branding & colors
- Edit
colorsanddaisyui.themesintailwind.config.jsto match your brand.
- Edit
-
Fonts & typography
-
Replace or extend fonts under:
src/style/fonts/iransanssrc/style/fonts/iranyekan
-
Update
fontFamilyintailwind.config.js.
-
-
Categories & images
-
Category images in:
src/assets/images/categories/*public/image/categories/*
-
Hero images:
- Home:
src/components/Pages/Home_page/hero/Hero.tsx - Drinks/Tools:
src/components/Pages/DrinkAndTools_page/*
- Home:
-
-
Copy & static text
- Update
src/assets/json/base.jsonand text inside page components undersrc/components/Pages/*.
- Update
-
Business logic
- Adjust cart/order behavior in
src/actions/ordering/*. - Modify OTP / phone / user management in
src/actions/userInfo/*andsrc/actions/OTP/*. - Customize product introduction/specification/review logic in
src/actions/product/*.
- Adjust cart/order behavior in
You can deploy this Next.js app to any platform that supports Node.js, such as Vercel or Netlify.
- Push your repository to GitHub/GitLab/Bitbucket.
- Import the project into Vercel.
- Set environment variables in the Vercel dashboard (copy from your local
.env, but never copy secrets into public places). - Vercel will automatically run
npm install,npm run build, and start the app. - Update
NEXTAUTH_URLto your production URL (e.g.https://your-domain.com).
The project includes @netlify/plugin-nextjs in devDependencies.
- Connect the repo to Netlify.
- Build command:
npm run build - Publish directory:
.next - Add plugin configuration in
netlify.tomlif needed for SSR and advanced routing.
- Never commit
.envor any secrets to version control. - Use different secrets for development and production.
- Rotate credentials immediately if they are ever exposed.
- Review any obfuscated or unfamiliar code in configuration files (for example, at the bottom of
next.config.js) before deploying to production. If you do not know why a code block is there, remove it or replace the file with a clean version. - Restrict database and Redis access by IP / network rules where possible.
- Always serve your production app over HTTPS.
Specify your license here (for example, MIT):
MIT License
Copyright (c) <year> <your-name>
Create a LICENSE file in the project root to make it explicit.