create-luff-app 1.0.7 โ†’ 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. package/NOTES.md +110 -124
  2. package/README.md +165 -138
  3. package/bin/cli.js +35 -1
  4. package/package.json +1 -1
package/NOTES.md CHANGED
@@ -1,44 +1,50 @@
1
- # Luff Boilerplate
1
+ # ๐Ÿ“˜ LUFF. Operational Manual
2
2
 
3
- This repository contains a full-stack Next.js + Node.js Microservices architecture boilerplate, ready for local execution and seamless Kubernetes (K8s) deployment via ArgoCD.
3
+ <p align="center">
4
+ <img src="https://img.shields.io/badge/Mode-Local_Dev-6366f1?style=for-the-badge" />
5
+ <img src="https://img.shields.io/badge/Mode-Kubernetes-34d399?style=for-the-badge" />
6
+ <img src="https://img.shields.io/badge/CI/CD-GitHub_Actions-f59e0b?style=for-the-badge" />
7
+ </p>
4
8
 
5
- Everything is containerized, fully configured for Google OAuth authentication, and automatically validated with CI/CD.
9
+ > Everything you need to run, deploy, and maintain the LUFF. ecosystem โ€” from local dev to production Kubernetes.
6
10
 
7
11
  ---
8
12
 
9
- ## ๐Ÿš€ 1. Initial Setup Required
13
+ ## ๐Ÿš€ 1. Initial Setup
10
14
 
11
- Before running this project for the first time, you must configure your environment locally.
15
+ ### Prerequisites
12
16
 
13
- ### Prerequisites:
17
+ | Tool | Version | Purpose |
18
+ |:---:|:---:|:---|
19
+ | Node.js | `โ‰ฅ 20.x` | Runtime for all services |
20
+ | Docker Desktop | `โ‰ฅ 24.x` | Database containers |
21
+ | kubectl | Latest | Kubernetes management |
22
+ | ArgoCD | Latest | GitOps agent (K8s mode only) |
14
23
 
15
- - **Node.js** (v20+)
16
- - **Docker** and **Docker Desktop / Minikube**
17
- - **kubectl** (connected to your local Kubernetes cluster)
18
- - **ArgoCD** (must be installed on your local Kubernetes cluster)
19
-
20
- ### Step 1: Install Dependencies & Setup Env Files
21
-
22
- We have an automated setup script that installs NPM packages and copies the required `.env.example` files to `.env`.
24
+ ### One-Time Setup
23
25
 
24
26
  ```bash
25
- npm run setup
27
+ npm run setup # Installs packages + copies .env files
26
28
  ```
27
29
 
28
- Wait for `npm install` and Husky to finish.
30
+ ---
29
31
 
30
- ### Step 2: Configure Environment Variables
32
+ ## โš™๏ธ 2. Environment Variables
31
33
 
32
- You MUST explicitly provide Google OAuth credentials and URLs for the frontend build and backend authentication to work. Check these three `.env` files and verify their values.
34
+ You **must** configure these `.env` files before the app will fully function:
33
35
 
34
- **1. `frontend/.env`**
36
+ <details>
37
+ <summary><b>frontend/.env</b></summary>
35
38
 
36
39
  ```env
37
40
  NEXT_PUBLIC_API_URL=http://localhost:4000
38
41
  NEXT_PUBLIC_GOOGLE_CLIENT_ID=your_client_id.apps.googleusercontent.com
42
+ NEXT_PUBLIC_RAZORPAY_KEY_ID=rzp_test_your_id
39
43
  ```
44
+ </details>
40
45
 
41
- **2. `backend/auth/.env`**
46
+ <details>
47
+ <summary><b>backend/auth/.env</b></summary>
42
48
 
43
49
  ```env
44
50
  PORT=4001
@@ -46,18 +52,24 @@ JWT_SECRET="your-jwt-secret-change-in-production"
46
52
  GOOGLE_CLIENT_ID=your_client_id.apps.googleusercontent.com
47
53
  GOOGLE_CLIENT_SECRET=your_client_secret
48
54
  FRONTEND_URL=http://localhost:3000
55
+ DATABASE_URL="postgresql://postgres:postgres@localhost:5433/auth_db"
49
56
  NODE_ENV=development
50
57
  ```
58
+ </details>
51
59
 
52
- **3. `backend/posts/.env`**
60
+ <details>
61
+ <summary><b>backend/posts/.env</b></summary>
53
62
 
54
63
  ```env
55
64
  PORT=4002
56
65
  JWT_SECRET="your-jwt-secret"
66
+ DATABASE_URL="postgresql://postgres:postgres@localhost:5434/posts_db"
57
67
  NODE_ENV=development
58
68
  ```
69
+ </details>
59
70
 
60
- **4. `backend/payment/.env`**
71
+ <details>
72
+ <summary><b>backend/payment/.env</b></summary>
61
73
 
62
74
  ```env
63
75
  PORT=4003
@@ -67,150 +79,124 @@ DATABASE_URL="postgresql://postgres:postgres@localhost:5435/payment_db"
67
79
  JWT_SECRET="your-jwt-secret"
68
80
  NODE_ENV=development
69
81
  ```
82
+ </details>
70
83
 
71
- ### Step 3: Kubernetes Secrets
84
+ <details>
85
+ <summary><b>backend/ai-service/.env</b></summary>
72
86
 
73
- ```bash
74
- # App, Auth & Posts Secrets (...)
75
-
76
- # Create Payment Secrets
77
- kubectl create secret generic payment-secrets \
78
- --from-literal=database-url="postgresql://postgres:postgres@payment-db-service:5432/payment_db" \
79
- --from-literal=razorpay-key-id="your_key" \
80
- --from-literal=razorpay-key-secret="your_secret" \
81
- --from-literal=jwt-secret="your-jwt-secret"
87
+ ```env
88
+ PORT=4004
89
+ GEMINI_API_KEY=your_gemini_api_key
90
+ UPSTASH_VECTOR_REST_URL=https://your-index.upstash.io
91
+ UPSTASH_VECTOR_REST_TOKEN=your_token
92
+ JWT_SECRET="your-jwt-secret"
93
+ NODE_ENV=development
82
94
  ```
95
+ </details>
83
96
 
84
97
  ---
85
98
 
86
- ## ๐ŸŒŸ 2. How To Run Locally
99
+ ## ๐Ÿ–ฅ๏ธ 3. Running the Project
87
100
 
88
- We support two modes of development:
89
-
90
- ### 1. Native Mode (Recommended)
91
-
92
- This is the fastest loop. Run everything directly on your machine:
101
+ ### Option A: Native Mode (Recommended for Dev)
93
102
 
94
103
  ```bash
95
104
  npm run run-local
96
105
  ```
97
106
 
98
- This script handles:
99
-
100
- - Stopping K8s port conflicts
101
- - Starting local Docker DBs
102
- - Running all services via `npm run dev`
103
-
104
- ### 2. Kubernetes Mode (GitOps)
105
-
106
- Follow this if you want to test the full K8s stack:
107
-
108
- 1. **Build & Deploy**: `npm run run-k8s build`
109
- 2. **Access Dashboard**: `npm run argo`
110
- 3. **Connect Ports**: `npm run access`
111
-
112
- We utilize ArgoCD as the GitOps agent. It constantly monitors your main branch's `k8s/` folder and applies the configuration locally.
107
+ Handles everything: clears port conflicts, starts Docker DBs, launches all services.
113
108
 
114
- ### Step 1: Tell ArgoCD to watch your directory
109
+ ### Option B: Kubernetes Mode (Production)
115
110
 
116
- Apply the custom Application configuration directly:
111
+ ```mermaid
112
+ %%{init: {'theme':'dark','themeVariables':{'fontSize':'10px'}}}%%
113
+ flowchart LR
114
+ A[Build] --> B[Tag] --> C[ArgoCD] --> D[Deploy] --> E[Forward]
115
+ ```
117
116
 
118
117
  ```bash
118
+ # 1. Tell ArgoCD to watch your repo
119
119
  kubectl apply -f argocd/application.yaml
120
- ```
121
-
122
- ### Step 2: Build the Local Images (Automated)
123
120
 
124
- Your Kubernetes `Deployment` manifests are configured to pull from `ghcr.io/luff-org/...` with an `IfNotPresent` pull policy. To run the images locally exactly as they are configured in your manifests, **we have created an automation script**.
125
-
126
- This script pulls your `.env` Client ID, tags images according to your current commit SHA (what ArgoCD expects), and restarts the Kubernetes pods.
127
-
128
- ```bash
121
+ # 2. Build & deploy locally
129
122
  ./scripts/deploy-local.sh
130
- ```
131
-
132
- ### Step 3: Port Forwarding
133
123
 
134
- Because we are working locally, we must manually expose K8s services to `localhost`:
135
-
136
- ```bash
137
- # Terminal 1 - For the Frontend Application
124
+ # 3. Forward ports to localhost
138
125
  kubectl port-forward svc/frontend-service 3000:3000
139
-
140
- # Terminal 2 - For the API Gateway (Backend)
141
126
  kubectl port-forward svc/api-gateway 4000:4000
142
127
  ```
143
128
 
144
- Visit `http://localhost:3000` โ€” Your Google OAuth login will be functioning seamlessly.
145
-
146
- ---
129
+ ### Kubernetes Secrets
147
130
 
148
- ## ๐Ÿ”„ 3. What To Do Whenever You Run This Afterwards
149
-
150
- When returning to development on a new day, you **DO NOT** need to repeat the secret configuration or ArgoCD setup. You just have to build any new changes and run your port-forwards.
131
+ ```bash
132
+ # Auth secrets
133
+ kubectl create secret generic auth-secrets \
134
+ --from-literal=database-url="postgresql://postgres:postgres@auth-db-service:5432/auth_db" \
135
+ --from-literal=google-client-id="your_id" \
136
+ --from-literal=google-client-secret="your_secret" \
137
+ --from-literal=jwt-secret="your-jwt-secret"
151
138
 
152
- 1. **Commit your code to Git**: Or ArgoCD will desync!
153
- 2. **Run the Automation Script**: To push the newest changes directly to your local cluster:
154
- ```bash
155
- ./scripts/deploy-local.sh
156
- ```
157
- 3. **Start your tunnels**:
158
- ```bash
159
- kubectl port-forward svc/frontend-service 3000:3000
160
- kubectl port-forward svc/api-gateway 4000:4000
161
- ```
139
+ # Payment secrets
140
+ kubectl create secret generic payment-secrets \
141
+ --from-literal=database-url="postgresql://postgres:postgres@payment-db-service:5432/payment_db" \
142
+ --from-literal=razorpay-key-id="your_key" \
143
+ --from-literal=razorpay-key-secret="your_secret" \
144
+ --from-literal=jwt-secret="your-jwt-secret"
162
145
 
163
- _(Alternatively, if you only want to develop quickly on your host machine WITHOUT Kubernetes, you can bypass Docker altogether by running `npm run dev` in the root folder!)_
146
+ # AI secrets
147
+ kubectl create secret generic ai-secrets \
148
+ --from-literal=gemini-api-key="your_gemini_key" \
149
+ --from-literal=upstash-vector-rest-url="your_url" \
150
+ --from-literal=upstash-vector-rest-token="your_token" \
151
+ --from-literal=jwt-secret="your-jwt-secret"
152
+ ```
164
153
 
165
154
  ---
166
155
 
167
- ## ๐Ÿค– 4. Ensuring Automation Works (GitHub Actions CI/CD)
168
-
169
- Whenever you push to `main` on GitHub, our unified pipeline (`.github/workflows/pipeline.yml`) runs automatically.
170
-
171
- **To ensure this workflow succeeds on the cloud:**
172
- You MUST add your `GOOGLE_CLIENT_ID` to GitHub Secrets. Failure to do so means the Cloud-built Docker image will have an empty Google Client ID baked into its statically-generated frontend!
173
-
174
- **Go to GitHub**:
156
+ ## ๐Ÿ”„ 4. Daily Development Workflow
175
157
 
176
- 1. Open Repository > `Settings`
177
- 2. Navigate to `Secrets and variables` > `Actions`
178
- 3. Click `New repository secret`
179
- 4. **Name**: `GOOGLE_CLIENT_ID`
180
- 5. **Secret**: `your_client_id.apps.googleusercontent.com`
181
- 6. Click **Add secret**.
158
+ > After initial setup, you **don't** need to reconfigure secrets or ArgoCD.
182
159
 
183
- _(The frontend URL and other runtime variables are dynamically passed, but Next.js `NEXT_PUBLIC_` variables are physically built into the Docker image, so this is strictly required!)\_
160
+ | Mode | Daily Steps |
161
+ |:---|:---|
162
+ | **Native** | Just run `npm run run-local` |
163
+ | **K8s** | `./scripts/deploy-local.sh` โ†’ Port forward |
184
164
 
185
165
  ---
186
166
 
187
- ## ๐ŸŽจ 5. Personalization & Customization (For New Users)
167
+ ## ๐Ÿค– 5. CI/CD Pipeline
188
168
 
189
- If you are cloning this boilerplate to start your own project, you need to update a few hardcoded values to point to your own GitHub Organization and Repository.
190
-
191
- ### Step 1: Search and Replace
192
-
193
- Search the entire repository for `luff-org` and replace it with your own **GitHub Username** or **Organization Name** (in lowercase).
169
+ ```mermaid
170
+ %%{init: {'theme':'dark','themeVariables':{'fontSize':'10px'}}}%%
171
+ flowchart LR
172
+ Push --> CI[Actions] --> Lint --> Build --> Reg[GHCR] --> Argo[ArgoCD] --> K8s
173
+ ```
194
174
 
195
- - **Impacts**: K8s image paths, Docker tags, and CI/CD registry paths.
175
+ > **โš ๏ธ Important**: Add `GOOGLE_CLIENT_ID` to GitHub Repository Secrets. Next.js `NEXT_PUBLIC_` variables are baked into the Docker image at build time.
196
176
 
197
- ### Step 2: Update ArgoCD Repo URL
177
+ ### Adding the GitHub Secret
198
178
 
199
- Open `argocd/application.yaml` and update the `repoURL` to point to your new fork or repository:
179
+ 1. Repository โ†’ **Settings** โ†’ **Secrets and variables** โ†’ **Actions**
180
+ 2. Click **New repository secret**
181
+ 3. Name: `GOOGLE_CLIENT_ID` โ†’ Value: `your_client_id.apps.googleusercontent.com`
200
182
 
201
- ```yaml
202
- repoURL: https://github.com/YOUR_ORG/YOUR_REPO.git
203
- ```
183
+ ---
204
184
 
205
- ### Step 3: Update Production API URL
185
+ ## ๐ŸŽจ 6. Customization Guide
206
186
 
207
- Open `.github/workflows/pipeline.yml` and update the `NEXT_PUBLIC_API_URL` under the `Build & Push` job to your actual production domain:
187
+ When forking for your own project, search and replace these values:
208
188
 
209
- ```yaml
210
- build-args: |
211
- NEXT_PUBLIC_API_URL=https://api.your-actual-domain.com
212
- ```
189
+ | Find | Replace With | Affects |
190
+ |:---|:---|:---|
191
+ | `luff-org` | Your GitHub org (lowercase) | K8s images, Docker tags, CI/CD |
192
+ | `Luff-Org` | Your GitHub org | Git URLs, ArgoCD config |
193
+ | `Luff-Boilerplate` | Your repo name | Clone URLs, package names |
213
194
 
214
- ### Step 4: Database Names & Secrets
195
+ ### Key Files to Update
215
196
 
216
- If you change the service names or database names in the `k8s/` manifests, remember to update the corresponding `DATABASE_URL` strings in your **Kubernetes Secrets** (Step 1.3 above).
197
+ | File | What to Change |
198
+ |:---|:---|
199
+ | `argocd/application.yaml` | `repoURL` โ†’ your repository |
200
+ | `.github/workflows/pipeline.yml` | `NEXT_PUBLIC_API_URL` โ†’ your domain |
201
+ | `k8s/*.yaml` | Image paths โ†’ your registry |
202
+ | All `DATABASE_URL` strings | If you rename databases |
package/README.md CHANGED
@@ -1,191 +1,218 @@
1
- # ๐Ÿ’จ Luff Microservices Boilerplate
1
+ # ๐Ÿš€ create-luff-app
2
2
 
3
- [![NPM Version](https://img.shields.io/npm/v/create-luff-app?color=blue&style=flat-square)](https://www.npmjs.com/package/create-luff-app)
4
- [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg?style=flat-square)](https://opensource.org/licenses/MIT)
5
- [![TypeScript](https://img.shields.io/badge/TypeScript-5.4-blue?style=flat-square&logo=typescript)](https://www.typescriptlang.org/)
3
+ <p align="center">
4
+ <img src="https://img.shields.io/npm/v/create-luff-app?style=for-the-badge&color=6366f1&label=npm" alt="npm" />
5
+ <img src="https://img.shields.io/badge/Services-6-34d399?style=for-the-badge" />
6
+ <img src="https://img.shields.io/badge/AI_Powered-Gemini_2.5-8E75B2?style=for-the-badge" />
7
+ <img src="https://img.shields.io/badge/License-MIT-green?style=for-the-badge" />
8
+ </p>
6
9
 
7
- A **production-grade microservices monorepo** designed for speed, scalability, and developer experience. Built with Turborepo, Next.js, Express, Prisma, and PostgreSQL.
10
+ > **Scaffold the entire LUFF. microservices ecosystem in one command.**
11
+ > Full-stack Next.js + Express + Prisma + Gemini AI + Razorpay โ€” ready to run.
8
12
 
9
13
  ---
10
14
 
11
- ## ๐Ÿš€ Quick Start with CLI
12
-
13
- The fastest way to scaffold a new project using this boilerplate is with our official CLI:
15
+ ## โšก Quick Start
14
16
 
15
17
  ```bash
16
- npx create-luff-app <your-app-name>
18
+ npx create-luff-app@latest my-app
17
19
  ```
18
20
 
19
- > [!TIP]
20
- > This command will clone the repository, install dependencies, and set up your project structure automatically.
21
+ That's it. The CLI will:
22
+ 1. Clone the boilerplate
23
+ 2. Ask if you want **AI features** (Gemini + RAG)
24
+ 3. Install all dependencies
25
+ 4. Initialize a fresh Git repo
21
26
 
22
- ---
27
+ ### After Scaffolding
23
28
 
24
- ## ๐Ÿ“ Operational Notes
29
+ ```bash
30
+ cd my-app
31
+ bash scripts/setup-envs.sh
32
+ docker compose -f docker/docker-compose.yml up auth-db posts-db payment-db -d
33
+ npm run run-local
34
+ ```
25
35
 
26
- For detailed troubleshooting on database connections, Kubernetes local setup, and Docker build fixes, see [NOTES.md](./NOTES.md).
36
+ > ๐Ÿง  **AI Users**: Add your `GEMINI_API_KEY` and Upstash Vector keys to `backend/ai-service/.env`
27
37
 
28
38
  ---
29
39
 
30
- ## ๐Ÿ—๏ธ Architecture
31
-
32
- ```text
33
- โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
34
- โ”‚ API Gatewayโ”‚ :4000
35
- โ”‚ (Express) โ”‚
36
- โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”˜
37
- โ”‚
38
- โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
39
- โ”‚ โ”‚ โ”‚
40
- โ”Œโ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”
41
- โ”‚ Auth โ”‚ โ”‚ Posts โ”‚ โ”‚ Payment โ”‚
42
- โ”‚ Service โ”‚:4001โ”‚ Service โ”‚:4002โ”‚ Service โ”‚:4003
43
- โ”‚ (Express) โ”‚ โ”‚ (Express) โ”‚ โ”‚ (Express) โ”‚
44
- โ””โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”˜
45
- โ”‚ โ”‚ โ”‚
46
- โ”Œโ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”
47
- โ”‚ Auth DB โ”‚ โ”‚ Posts DB โ”‚ โ”‚Payment DB โ”‚
48
- โ”‚ (Postgres)โ”‚ โ”‚ (Postgres)โ”‚ โ”‚(Postgres) โ”‚
49
- โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
50
-
51
- โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
52
- โ”‚ Frontend App โ”‚
53
- โ”‚ (Next.js) โ”‚
54
- โ”‚ :3000 โ”‚
55
- โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
40
+ ## ๐Ÿ—๏ธ What Gets Scaffolded
41
+
42
+ ```
43
+ my-app/
44
+ โ”œโ”€โ”€ frontend/ โ†’ Next.js 14 (App Router + Tailwind)
45
+ โ”œโ”€โ”€ backend/
46
+ โ”‚ โ”œโ”€โ”€ api-gateway/ โ†’ Reverse Proxy & Rate Limiting (:4000)
47
+ โ”‚ โ”œโ”€โ”€ auth/ โ†’ Google OAuth + JWT (:4001)
48
+ โ”‚ โ”œโ”€โ”€ posts/ โ†’ Community CRUD (:4002)
49
+ โ”‚ โ”œโ”€โ”€ payment/ โ†’ Razorpay Payments (:4003)
50
+ โ”‚ โ””โ”€โ”€ ai-service/ โ†’ Gemini 2.5 AI + RAG (:4004)
51
+ โ”œโ”€โ”€ shared/ โ†’ Shared types, config, logger
52
+ โ”œโ”€โ”€ docker/ โ†’ Docker Compose (3 PostgreSQL DBs)
53
+ โ”œโ”€โ”€ k8s/ โ†’ Kubernetes manifests (ArgoCD-ready)
54
+ โ”œโ”€โ”€ scripts/ โ†’ Setup & deployment automation
55
+ โ””โ”€โ”€ .github/workflows/ โ†’ CI/CD pipeline
56
56
  ```
57
57
 
58
58
  ---
59
59
 
60
- ## ๐Ÿ› ๏ธ Tech Stack
60
+ ## ๐Ÿ“ก Service Directory
61
61
 
62
- | Layer | Technology |
63
- | :----------- | :------------------------------------------------ |
64
- | **Frontend** | Next.js 14 (App Router), TailwindCSS, React Query |
65
- | **Backend** | Node.js, Express, TypeScript |
66
- | **Database** | PostgreSQL, Prisma ORM |
67
- | **Payment** | Integrated Stripe/Internal Payment Logic |
68
- | **Auth** | Google OAuth (PostMessage flow), JWT |
69
- | **Monorepo** | Turborepo, npm workspaces |
70
- | **Infra** | Docker, Kubernetes (ArgoCD ready) |
71
- | **Quality** | ESLint, Prettier, Husky, Commitlint |
72
- | **Toast** | Sonner (Premium Notifications) |
62
+ | | Service | Port | Tech | What It Does |
63
+ |:---:|:---|:---:|:---|:---|
64
+ | ๐Ÿง  | **AI Service** | `4004` | Gemini 2.5 Flash, Upstash Vector | PDF intelligence, contextual chat, RAG |
65
+ | ๐Ÿ” | **Auth** | `4001` | Google OAuth, JWT, Prisma | Stateless authentication |
66
+ | ๐Ÿ“ | **Posts** | `4002` | Express, Prisma | Community posts with owner enforcement |
67
+ | ๐Ÿ’ณ | **Payment** | `4003` | Razorpay SDK, Prisma | Orders, verification, transaction ledger |
68
+ | ๐Ÿ›ก๏ธ | **Gateway** | `4000` | Express, http-proxy-middleware | CORS, rate-limiting, routing |
69
+ | ๐Ÿ–ฅ๏ธ | **Frontend** | `3000` | Next.js 14, Tailwind, React Query | Premium UI with dark/light mode |
73
70
 
74
71
  ---
75
72
 
76
- ## โšก Local Development Setup
77
-
78
- Follow these steps to get your environment running from scratch.
79
-
80
- ### 1. Prerequisites
81
-
82
- Ensure you have the following installed:
73
+ ## ๐Ÿง  AI Feature (Opt-In)
83
74
 
84
- - **Node.js**: `v20.x` or higher
85
- - **Docker**: For running databases locally
75
+ During scaffolding, the CLI asks:
86
76
 
87
- ### 2. Installation
88
-
89
- If you didn't use the CLI, clone and install manually:
90
-
91
- ```bash
92
- git clone https://github.com/Luff-Org/Luff-Boilerplate.git
93
- cd Luff-Boilerplate
94
- npm install
95
77
  ```
96
-
97
- ### 3. Environment & Databases
98
-
99
- We provide a setup script to automate `.env` creation:
100
-
101
- ```bash
102
- # Automatically creates .env files from .env.example
103
- npm run setup
104
-
105
- # Spin up PostgreSQL instances via Docker
106
- docker compose -f docker/docker-compose.yml up auth-db posts-db -d
78
+ โœจ Would you like to enable the AI Chatbot feature (RAG + Gemini)? (y/n)
107
79
  ```
108
80
 
109
- ### 4. Database Initialization
110
-
111
- Generate Prisma clients and push schemas to your local databases:
112
-
113
- ```bash
114
- # Auth service
115
- cd backend/auth && npm run db:push && npm run db:generate && cd ../..
116
-
117
- # Posts service
118
- cd backend/posts && npm run db:push && npm run db:generate && cd ../..
81
+ | Choice | What Happens |
82
+ |:---:|:---|
83
+ | **Yes** | Full AI service included โ€” chat, PDF upload, RAG pipeline |
84
+ | **No** | AI service is removed, gateway routes cleaned up, chat page deleted |
85
+
86
+ ### AI Architecture
87
+
88
+ ```mermaid
89
+ %%{init: {'theme':'dark','themeVariables':{'fontSize':'10px'}}}%%
90
+ flowchart LR
91
+ A[Upload] --> B[Parse]
92
+ B --> C[Embed]
93
+ C --> D[Store]
94
+ E[Query] --> F[Search]
95
+ D -.-> F
96
+ F --> G[Gemini]
97
+ G --> H[Answer]
119
98
  ```
120
99
 
121
- ### 5. Start Developing
122
-
123
- ```bash
124
- npm run dev
100
+ ## ๐Ÿงฌ Architecture at a Glance
101
+
102
+ ```mermaid
103
+ %%{init: {'theme':'dark','themeVariables':{'fontSize':'19px'}}}%%
104
+ graph LR
105
+ FE[FE] --> GW[API GW]
106
+ GW --> A[Auth]
107
+ GW --> P[Posts]
108
+ GW --> Pay[Pay]
109
+ GW --> AI[AI]
110
+ A --> AD[(AuthDB)]
111
+ P --> PD[(PostsDB)]
112
+ Pay --> PaD[(PayDB)]
113
+ AI --> V[(Vector)]
114
+ AI --> G[Gemini]
125
115
  ```
126
116
 
127
- Your services will be available at:
128
-
129
- - **Web Interface**: [http://localhost:3000](http://localhost:3000)
130
- - **API Gateway**: [http://localhost:4000](http://localhost:4000)
131
- - **Auth Service**: [http://localhost:4001](http://localhost:4001)
132
- - **Posts Service**: [http://localhost:4002](http://localhost:4002)
133
-
134
117
  ---
135
118
 
136
- ## ๐Ÿ“‚ Project Structure
137
-
138
- ```text
139
- โ”œโ”€โ”€ frontend/ # Unified Next.js application
140
- โ”œโ”€โ”€ backend/
141
- โ”‚ โ”œโ”€โ”€ auth/ # Auth microservice (Google OAuth + JWT)
142
- โ”‚ โ”œโ”€โ”€ posts/ # Posts microservice (CRUD)
143
- โ”‚ โ””โ”€โ”€ api-gateway/ # Express Proxy & Rate Limiting
144
- โ”œโ”€โ”€ shared/ # Shared internal packages (Types, Logger, Config)
145
- โ”œโ”€โ”€ docker/ # Docker Compose configurations
146
- โ”œโ”€โ”€ k8s/ # Kubernetes manifests
147
- โ””โ”€โ”€ scripts/ # Automation & Setup scripts
119
+ ## ๐Ÿ’ณ Payment Service โ€” Transaction Infrastructure
120
+
121
+ <summary><b>๐Ÿ” Click to expand Payment Architecture</b></summary>
122
+
123
+ ```mermaid
124
+ %%{init: {'theme':'dark','themeVariables':{'fontSize':'10px'}}}%%
125
+ sequenceDiagram
126
+ participant U as User
127
+ participant F as Frontend
128
+ participant G as Gateway
129
+ participant P as Payment
130
+ participant R as Razorpay
131
+ participant DB as PayDB
132
+
133
+ U->>F: Buy
134
+ F->>G: POST /create-order
135
+ G->>P: Forward
136
+ P->>R: Create Order
137
+ R-->>P: order_id
138
+ P-->>F: order_id
139
+ F->>R: Checkout
140
+ R-->>F: Callback
141
+ F->>G: POST /verify
142
+ G->>P: Forward
143
+ P->>P: HMAC Check
144
+ P->>DB: Save
145
+ P-->>F: Verified
148
146
  ```
149
147
 
148
+ | Route | Method | Auth | Description |
149
+ |:---|:---:|:---:|:---|
150
+ | `/payments/create-order` | POST | โœ… | Creates a Razorpay order with amount & currency |
151
+ | `/payments/verify` | POST | โœ… | Verifies payment signature (HMAC-SHA256) |
152
+ | `/payments/my-purchases` | GET | โœ… | Returns user's transaction history |
153
+
150
154
  ---
151
155
 
152
- ## ๐Ÿ” Google OAuth Configuration
156
+ ## ๐Ÿ” Auth Service โ€” Stateless Security
157
+
158
+ <summary><b>๐Ÿ” Click to expand Authentication Flow</b></summary>
159
+
160
+ ```mermaid
161
+ %%{init: {'theme':'dark','themeVariables':{'fontSize':'10px'}}}%%
162
+ sequenceDiagram
163
+ participant U as User
164
+ participant F as Frontend
165
+ participant G as Google
166
+ participant A as Auth
167
+ participant DB as AuthDB
168
+
169
+ U->>F: Login
170
+ F->>G: OAuth Popup
171
+ G-->>F: Token
172
+ F->>A: POST /auth/google
173
+ A->>G: Verify
174
+ G-->>A: Profile
175
+ A->>DB: Upsert
176
+ A->>A: Sign JWT
177
+ A-->>F: JWT + User
178
+ F->>F: Store JWT
179
+ ```
153
180
 
154
- To enable authentication:
181
+ ## ๐Ÿ”‘ Credentials Setup
155
182
 
156
- 1. Create OAuth credentials in [Google Cloud Console](https://console.cloud.google.com/apis/credentials).
157
- 2. Set authorized origin to `http://localhost:3000`.
158
- 3. Update `GOOGLE_CLIENT_ID` in `backend/auth/.env` and `NEXT_PUBLIC_GOOGLE_CLIENT_ID` in `frontend/.env`.
183
+ <details>
184
+ <summary><b>๐Ÿง  AI โ€” Gemini + Upstash</b></summary>
159
185
 
160
- ---
186
+ | Get From | What | Put In |
187
+ |:---|:---|:---|
188
+ | [AI Studio](https://aistudio.google.com/app/apikey) | `GEMINI_API_KEY` | `backend/ai-service/.env` |
189
+ | [Upstash](https://console.upstash.com/vector) | `REST_URL` + `TOKEN` | `backend/ai-service/.env` |
161
190
 
162
- ## ๐Ÿณ Deployment
191
+ Create a Vector Index with **768 dimensions**.
192
+ </details>
163
193
 
164
- ### Docker Compose
194
+ <details>
195
+ <summary><b>๐Ÿ” Auth โ€” Google OAuth</b></summary>
165
196
 
166
- ```bash
167
- docker compose -f docker/docker-compose.yml up --build
168
- ```
197
+ | Get From | What | Put In |
198
+ |:---|:---|:---|
199
+ | [Cloud Console](https://console.cloud.google.com/apis/credentials) | `CLIENT_ID`, `CLIENT_SECRET` | `backend/auth/.env` + `frontend/.env` |
169
200
 
170
- ### Kubernetes
201
+ Redirect URI: `http://localhost:4000/auth/callback/google`
202
+ </details>
171
203
 
172
- ```bash
173
- kubectl apply -f k8s/
174
- ```
175
-
176
- ---
204
+ <details>
205
+ <summary><b>๐Ÿ’ณ Payments โ€” Razorpay</b></summary>
177
206
 
178
- ## ๐Ÿ“œ Scripts
207
+ | Get From | What | Put In |
208
+ |:---|:---|:---|
209
+ | [Razorpay](https://dashboard.razorpay.com/) | `KEY_ID`, `KEY_SECRET` | `backend/payment/.env` + `frontend/.env` |
179
210
 
180
- | Command | Description |
181
- | :-------------- | :-------------------------------------- |
182
- | `npm run dev` | Starts all services in development mode |
183
- | `npm run build` | Builds all apps and packages |
184
- | `npm run setup` | Initializes environment files |
185
- | `npm run lint` | Runs linting across the monorepo |
211
+ Enable **Test Mode** first.
212
+ </details>
186
213
 
187
214
  ---
188
215
 
189
216
  ## ๐Ÿ“„ License
190
217
 
191
- This project is licensed under the [MIT License](LICENSE).
218
+ [MIT](LICENSE)
package/bin/cli.js CHANGED
@@ -5,6 +5,14 @@ const degit = require("degit");
5
5
  const fs = require("fs");
6
6
  const path = require("path");
7
7
  const { execSync } = require("child_process");
8
+ const readline = require("readline");
9
+
10
+ const rl = readline.createInterface({
11
+ input: process.stdin,
12
+ output: process.stdout,
13
+ });
14
+
15
+ const question = (query) => new Promise((resolve) => rl.question(query, resolve));
8
16
 
9
17
  const projectName = process.argv[2];
10
18
 
@@ -33,13 +41,36 @@ async function main() {
33
41
  const emitter = degit("Luff-Org/Luff-Boilerplate", {
34
42
  cache: false,
35
43
  force: true,
36
- verbose: true
44
+ verbose: true,
37
45
  });
38
46
 
39
47
  await emitter.clone(projectPath);
40
48
 
41
49
  process.chdir(projectPath);
42
50
 
51
+ // Ask about AI Feature
52
+ const enableAI = await question("\x1b[33mโœจ Would you like to enable the AI Chatbot feature (RAG + GPT-4o)? (y/n): \x1b[0m");
53
+ rl.close();
54
+
55
+ if (enableAI.toLowerCase() !== "y") {
56
+ console.log("\x1b[36m%s\x1b[0m", "๐Ÿงน Removing AI module...");
57
+ try {
58
+ fs.rmSync(path.join(projectPath, "backend/ai-service"), { recursive: true, force: true });
59
+ fs.rmSync(path.join(projectPath, "frontend/src/app/chat"), { recursive: true, force: true });
60
+
61
+ // Clean up Gateway index.ts
62
+ const gatewayIndexPath = path.join(projectPath, "backend/api-gateway/src/index.ts");
63
+ if (fs.existsSync(gatewayIndexPath)) {
64
+ let content = fs.readFileSync(gatewayIndexPath, "utf8");
65
+ content = content.replace(/import { authProxy, postsProxy, paymentProxy, aiProxy } from '.\/routes\/proxy';/, "import { authProxy, postsProxy, paymentProxy } from './routes/proxy';");
66
+ content = content.replace(/\/\/ Proxy \/ai\/\* โ†’ ai service\napp\.use\('\/ai', aiProxy\);\n/, "");
67
+ fs.writeFileSync(gatewayIndexPath, content);
68
+ }
69
+ } catch (e) {
70
+ console.log(" Notice: Could not fully remove AI files, skipping.");
71
+ }
72
+ }
73
+
43
74
  console.log("\x1b[36m%s\x1b[0m", "๐Ÿงน Cleaning up repository history...");
44
75
 
45
76
  try {
@@ -87,6 +118,9 @@ async function main() {
87
118
  console.log(
88
119
  " set up .env files from .env.example files, can also use script > npm run setup"
89
120
  );
121
+ if (enableAI.toLowerCase() === 'y') {
122
+ console.log("\x1b[35m%s\x1b[0m", " ๐Ÿ’ก Don't forget to add OPENAI_API_KEY and UPSTASH_VECTOR keys to backend/ai-service/.env!");
123
+ }
90
124
  console.log(" npm run dev");
91
125
  console.log("");
92
126
  } catch (error) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-luff-app",
3
- "version": "1.0.7",
3
+ "version": "2.0.1",
4
4
  "description": "CLI to scaffold the Luff Microservices Boilerplate",
5
5
  "bin": {
6
6
  "create-luff-app": "bin/cli.js"