Digikala-style e-commerce & blog built with Next.js 14, TypeScript, Tailwind, Prisma, MongoDB, Redis, NextAuth, Zod, React Hook Form, shadcn/ui & MUI.
Digikala-style e-commerce & blog built with Next.js 14, TypeScript, Tailwind, Prisma, MongoDB, Redis, NextAuth, Zod, React Hook Form, shadcn/ui & MUI.
…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
---
## Getting Started
### 1. Prerequisites
* **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)
---
### 2. Installation
```bash
# Clone the repository
git clone taraneh-v1
cd taraneh-v1
# Install dependencies
npm install
```
> `postinstall` will automatically run `prisma generate`.
---
### 3. Environment Variables
Create a `.env` file in the project root.
> ⚠️ **Never commit `.env` to version control.**
> The `.gitignore` is already configured to ignore `.env` and `.env*.local`.
Use this as a template (replace all placeholder values with your own):
```env
# ===== 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:
```text
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`.
---
### 4. Database Setup (Prisma + MongoDB)
This project uses Prisma with a **MongoDB** provider.
1. Ensure `DATABASE_URL` in `.env` points to a valid MongoDB database.
2. Open `prisma/schema.prisma` and confirm the datasource is configured for MongoDB, for example:
```prisma
datasource db {
provider = "mongodb"
url = env("DATABASE_URL")
}
```
3. Push the schema to the database:
```bash
npx prisma db push
```
4. (Optional) Inspect data using Prisma Studio:
```bash
npx prisma studio
```
---
### 5. Running the App
#### Development
```bash
npm run dev
```
Then open: [http://localhost:3000](http://localhost:3000)
#### Production Build
```bash
npm run build
npm start
```
…
```
bash
npm run build
npm start
```
2. Open the site in Chrome.
3. Check **Application → Manifest / Service Workers** in DevTools.
4. You should see installable PWA information and an active service worker.
---
## Development
### Scripts
From `package.json`:
```json
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint",
"postinstall": "prisma generate"
}
```
…
```
text
MIT License
Copyright (c)
```
Create a `LICENSE` file in the project root to make it explicit.
---No open issues yet, or sync has not completed.