create-luff-app 1.0.6 โ 2.0.0
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.
- package/NOTES.md +116 -124
- package/README.md +92 -143
- package/bin/cli.js +37 -2
- package/package.json +1 -1
package/NOTES.md
CHANGED
|
@@ -1,44 +1,50 @@
|
|
|
1
|
-
#
|
|
1
|
+
# ๐ LUFF. Operational Manual
|
|
2
2
|
|
|
3
|
-
|
|
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
|
|
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
|
|
13
|
+
## ๐ 1. Initial Setup
|
|
10
14
|
|
|
11
|
-
|
|
15
|
+
### Prerequisites
|
|
12
16
|
|
|
13
|
-
|
|
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
|
-
-
|
|
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
|
-
|
|
30
|
+
---
|
|
29
31
|
|
|
30
|
-
|
|
32
|
+
## โ๏ธ 2. Environment Variables
|
|
31
33
|
|
|
32
|
-
You
|
|
34
|
+
You **must** configure these `.env` files before the app will fully function:
|
|
33
35
|
|
|
34
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
71
|
+
<details>
|
|
72
|
+
<summary><b>backend/payment/.env</b></summary>
|
|
61
73
|
|
|
62
74
|
```env
|
|
63
75
|
PORT=4003
|
|
@@ -67,150 +79,130 @@ 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
|
-
|
|
84
|
+
<details>
|
|
85
|
+
<summary><b>backend/ai-service/.env</b></summary>
|
|
72
86
|
|
|
73
|
-
```
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
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
|
-
##
|
|
99
|
+
## ๐ฅ๏ธ 3. Running the Project
|
|
87
100
|
|
|
88
|
-
|
|
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
|
-
|
|
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
|
-
###
|
|
109
|
+
### Option B: Kubernetes Mode (Production)
|
|
115
110
|
|
|
116
|
-
|
|
111
|
+
```mermaid
|
|
112
|
+
flowchart LR
|
|
113
|
+
A[Build] --> B[Tag]
|
|
114
|
+
B --> C[ArgoCD]
|
|
115
|
+
C --> D[Deploy]
|
|
116
|
+
D --> E[Forward]
|
|
117
|
+
```
|
|
117
118
|
|
|
118
119
|
```bash
|
|
120
|
+
# 1. Tell ArgoCD to watch your repo
|
|
119
121
|
kubectl apply -f argocd/application.yaml
|
|
120
|
-
```
|
|
121
|
-
|
|
122
|
-
### Step 2: Build the Local Images (Automated)
|
|
123
122
|
|
|
124
|
-
|
|
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
|
|
123
|
+
# 2. Build & deploy locally
|
|
129
124
|
./scripts/deploy-local.sh
|
|
130
|
-
```
|
|
131
|
-
|
|
132
|
-
### Step 3: Port Forwarding
|
|
133
125
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
```bash
|
|
137
|
-
# Terminal 1 - For the Frontend Application
|
|
126
|
+
# 3. Forward ports to localhost
|
|
138
127
|
kubectl port-forward svc/frontend-service 3000:3000
|
|
139
|
-
|
|
140
|
-
# Terminal 2 - For the API Gateway (Backend)
|
|
141
128
|
kubectl port-forward svc/api-gateway 4000:4000
|
|
142
129
|
```
|
|
143
130
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
---
|
|
131
|
+
### Kubernetes Secrets
|
|
147
132
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
133
|
+
```bash
|
|
134
|
+
# Auth secrets
|
|
135
|
+
kubectl create secret generic auth-secrets \
|
|
136
|
+
--from-literal=database-url="postgresql://postgres:postgres@auth-db-service:5432/auth_db" \
|
|
137
|
+
--from-literal=google-client-id="your_id" \
|
|
138
|
+
--from-literal=google-client-secret="your_secret" \
|
|
139
|
+
--from-literal=jwt-secret="your-jwt-secret"
|
|
151
140
|
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
```bash
|
|
159
|
-
kubectl port-forward svc/frontend-service 3000:3000
|
|
160
|
-
kubectl port-forward svc/api-gateway 4000:4000
|
|
161
|
-
```
|
|
141
|
+
# Payment secrets
|
|
142
|
+
kubectl create secret generic payment-secrets \
|
|
143
|
+
--from-literal=database-url="postgresql://postgres:postgres@payment-db-service:5432/payment_db" \
|
|
144
|
+
--from-literal=razorpay-key-id="your_key" \
|
|
145
|
+
--from-literal=razorpay-key-secret="your_secret" \
|
|
146
|
+
--from-literal=jwt-secret="your-jwt-secret"
|
|
162
147
|
|
|
163
|
-
|
|
148
|
+
# AI secrets
|
|
149
|
+
kubectl create secret generic ai-secrets \
|
|
150
|
+
--from-literal=gemini-api-key="your_gemini_key" \
|
|
151
|
+
--from-literal=upstash-vector-rest-url="your_url" \
|
|
152
|
+
--from-literal=upstash-vector-rest-token="your_token" \
|
|
153
|
+
--from-literal=jwt-secret="your-jwt-secret"
|
|
154
|
+
```
|
|
164
155
|
|
|
165
156
|
---
|
|
166
157
|
|
|
167
|
-
##
|
|
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**:
|
|
158
|
+
## ๐ 4. Daily Development Workflow
|
|
175
159
|
|
|
176
|
-
|
|
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**.
|
|
160
|
+
> After initial setup, you **don't** need to reconfigure secrets or ArgoCD.
|
|
182
161
|
|
|
183
|
-
|
|
162
|
+
| Mode | Daily Steps |
|
|
163
|
+
|:---|:---|
|
|
164
|
+
| **Native** | Just run `npm run run-local` |
|
|
165
|
+
| **K8s** | `./scripts/deploy-local.sh` โ Port forward |
|
|
184
166
|
|
|
185
167
|
---
|
|
186
168
|
|
|
187
|
-
##
|
|
169
|
+
## ๐ค 5. CI/CD Pipeline
|
|
188
170
|
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
171
|
+
```mermaid
|
|
172
|
+
flowchart LR
|
|
173
|
+
Push --> CI[Actions]
|
|
174
|
+
CI --> Lint
|
|
175
|
+
Lint --> Build
|
|
176
|
+
Build --> GHCR
|
|
177
|
+
GHCR --> Argo[ArgoCD]
|
|
178
|
+
Argo --> K8s
|
|
179
|
+
```
|
|
194
180
|
|
|
195
|
-
|
|
181
|
+
> **โ ๏ธ Important**: Add `GOOGLE_CLIENT_ID` to GitHub Repository Secrets. Next.js `NEXT_PUBLIC_` variables are baked into the Docker image at build time.
|
|
196
182
|
|
|
197
|
-
###
|
|
183
|
+
### Adding the GitHub Secret
|
|
198
184
|
|
|
199
|
-
|
|
185
|
+
1. Repository โ **Settings** โ **Secrets and variables** โ **Actions**
|
|
186
|
+
2. Click **New repository secret**
|
|
187
|
+
3. Name: `GOOGLE_CLIENT_ID` โ Value: `your_client_id.apps.googleusercontent.com`
|
|
200
188
|
|
|
201
|
-
|
|
202
|
-
repoURL: https://github.com/YOUR_ORG/YOUR_REPO.git
|
|
203
|
-
```
|
|
189
|
+
---
|
|
204
190
|
|
|
205
|
-
|
|
191
|
+
## ๐จ 6. Customization Guide
|
|
206
192
|
|
|
207
|
-
|
|
193
|
+
When forking for your own project, search and replace these values:
|
|
208
194
|
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
195
|
+
| Find | Replace With | Affects |
|
|
196
|
+
|:---|:---|:---|
|
|
197
|
+
| `luff-org` | Your GitHub org (lowercase) | K8s images, Docker tags, CI/CD |
|
|
198
|
+
| `Luff-Org` | Your GitHub org | Git URLs, ArgoCD config |
|
|
199
|
+
| `Luff-Boilerplate` | Your repo name | Clone URLs, package names |
|
|
213
200
|
|
|
214
|
-
###
|
|
201
|
+
### Key Files to Update
|
|
215
202
|
|
|
216
|
-
|
|
203
|
+
| File | What to Change |
|
|
204
|
+
|:---|:---|
|
|
205
|
+
| `argocd/application.yaml` | `repoURL` โ your repository |
|
|
206
|
+
| `.github/workflows/pipeline.yml` | `NEXT_PUBLIC_API_URL` โ your domain |
|
|
207
|
+
| `k8s/*.yaml` | Image paths โ your registry |
|
|
208
|
+
| All `DATABASE_URL` strings | If you rename databases |
|
package/README.md
CHANGED
|
@@ -1,189 +1,138 @@
|
|
|
1
|
-
#
|
|
1
|
+
# ๐ create-luff-app
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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
|
-
|
|
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
|
-
##
|
|
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
|
|
18
|
+
npx create-luff-app@latest my-app
|
|
17
19
|
```
|
|
18
20
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
## ๐ Operational Notes
|
|
25
|
-
|
|
26
|
-
For detailed troubleshooting on database connections, Kubernetes local setup, and Docker build fixes, see [NOTES.md](./NOTES.md).
|
|
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
|
|
27
26
|
|
|
28
|
-
|
|
27
|
+
### After Scaffolding
|
|
29
28
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
โ (Express) โ
|
|
36
|
-
โโโโโโโโฌโโโโโโโ
|
|
37
|
-
โ
|
|
38
|
-
โโโโโโโโโโโโโโผโโโโโโโโโโโโโ
|
|
39
|
-
โ โ
|
|
40
|
-
โโโโโโโดโโโโโโ โโโโโโโโดโโโโโโ
|
|
41
|
-
โ Auth โ โ Posts โ
|
|
42
|
-
โ Service โ :4001 โ Service โ :4002
|
|
43
|
-
โ (Express) โ โ (Express) โ
|
|
44
|
-
โโโโโโโฌโโโโโโ โโโโโโโโฌโโโโโโ
|
|
45
|
-
โ โ
|
|
46
|
-
โโโโโโโดโโโโโโ โโโโโโโโดโโโโโโ
|
|
47
|
-
โ Auth DB โ โ Posts DB โ
|
|
48
|
-
โ (Postgres)โ โ (Postgres) โ
|
|
49
|
-
โโโโโโโโโโโโโ โโโโโโโโโโโโโโ
|
|
50
|
-
|
|
51
|
-
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
52
|
-
โ Frontend App โ
|
|
53
|
-
โ (Next.js) โ
|
|
54
|
-
โ :3000 โ
|
|
55
|
-
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
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
|
|
56
34
|
```
|
|
57
35
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
## ๐ ๏ธ Tech Stack
|
|
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
|
-
| **Auth** | Google OAuth (PostMessage flow), JWT |
|
|
68
|
-
| **Monorepo** | Turborepo, npm workspaces |
|
|
69
|
-
| **Infra** | Docker, Kubernetes (ArgoCD ready) |
|
|
70
|
-
| **Quality** | ESLint, Prettier, Husky, Commitlint |
|
|
36
|
+
> ๐ง **AI Users**: Add your `GEMINI_API_KEY` and Upstash Vector keys to `backend/ai-service/.env`
|
|
71
37
|
|
|
72
38
|
---
|
|
73
39
|
|
|
74
|
-
##
|
|
75
|
-
|
|
76
|
-
Follow these steps to get your environment running from scratch.
|
|
40
|
+
## ๐๏ธ What Gets Scaffolded
|
|
77
41
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
npm install
|
|
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
|
|
93
56
|
```
|
|
94
57
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
We provide a setup script to automate `.env` creation:
|
|
58
|
+
---
|
|
98
59
|
|
|
99
|
-
|
|
100
|
-
# Automatically creates .env files from .env.example
|
|
101
|
-
npm run setup
|
|
60
|
+
## ๐ก Service Directory
|
|
102
61
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
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 |
|
|
106
70
|
|
|
107
|
-
|
|
71
|
+
---
|
|
108
72
|
|
|
109
|
-
|
|
73
|
+
## ๐ง AI Feature (Opt-In)
|
|
110
74
|
|
|
111
|
-
|
|
112
|
-
# Auth service
|
|
113
|
-
cd backend/auth && npm run db:push && npm run db:generate && cd ../..
|
|
75
|
+
During scaffolding, the CLI asks:
|
|
114
76
|
|
|
115
|
-
# Posts service
|
|
116
|
-
cd backend/posts && npm run db:push && npm run db:generate && cd ../..
|
|
117
77
|
```
|
|
118
|
-
|
|
119
|
-
### 5. Start Developing
|
|
120
|
-
|
|
121
|
-
```bash
|
|
122
|
-
npm run dev
|
|
78
|
+
โจ Would you like to enable the AI Chatbot feature (RAG + Gemini)? (y/n)
|
|
123
79
|
```
|
|
124
80
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
โ โโโ api-gateway/ # Express Proxy & Rate Limiting
|
|
142
|
-
โโโ shared/ # Shared internal packages (Types, Logger, Config)
|
|
143
|
-
โโโ docker/ # Docker Compose configurations
|
|
144
|
-
โโโ k8s/ # Kubernetes manifests
|
|
145
|
-
โโโ scripts/ # Automation & Setup scripts
|
|
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
|
+
flowchart LR
|
|
90
|
+
A[Upload] --> B[Parse]
|
|
91
|
+
B --> C[Embed]
|
|
92
|
+
C --> D[Store]
|
|
93
|
+
E[Query] --> F[Search]
|
|
94
|
+
D -.-> F
|
|
95
|
+
F --> G[Gemini]
|
|
96
|
+
G --> H[Answer]
|
|
146
97
|
```
|
|
147
98
|
|
|
148
99
|
---
|
|
149
100
|
|
|
150
|
-
##
|
|
151
|
-
|
|
152
|
-
To enable authentication:
|
|
101
|
+
## ๐ Credentials Setup
|
|
153
102
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
3. Update `GOOGLE_CLIENT_ID` in `backend/auth/.env` and `NEXT_PUBLIC_GOOGLE_CLIENT_ID` in `frontend/.env`.
|
|
157
|
-
|
|
158
|
-
---
|
|
103
|
+
<details>
|
|
104
|
+
<summary><b>๐ง AI โ Gemini + Upstash</b></summary>
|
|
159
105
|
|
|
160
|
-
|
|
106
|
+
| Get From | What | Put In |
|
|
107
|
+
|:---|:---|:---|
|
|
108
|
+
| [AI Studio](https://aistudio.google.com/app/apikey) | `GEMINI_API_KEY` | `backend/ai-service/.env` |
|
|
109
|
+
| [Upstash](https://console.upstash.com/vector) | `REST_URL` + `TOKEN` | `backend/ai-service/.env` |
|
|
161
110
|
|
|
162
|
-
|
|
111
|
+
Create a Vector Index with **768 dimensions**.
|
|
112
|
+
</details>
|
|
163
113
|
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
```
|
|
114
|
+
<details>
|
|
115
|
+
<summary><b>๐ Auth โ Google OAuth</b></summary>
|
|
167
116
|
|
|
168
|
-
|
|
117
|
+
| Get From | What | Put In |
|
|
118
|
+
|:---|:---|:---|
|
|
119
|
+
| [Cloud Console](https://console.cloud.google.com/apis/credentials) | `CLIENT_ID`, `CLIENT_SECRET` | `backend/auth/.env` + `frontend/.env` |
|
|
169
120
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
```
|
|
121
|
+
Redirect URI: `http://localhost:4000/auth/callback/google`
|
|
122
|
+
</details>
|
|
173
123
|
|
|
174
|
-
|
|
124
|
+
<details>
|
|
125
|
+
<summary><b>๐ณ Payments โ Razorpay</b></summary>
|
|
175
126
|
|
|
176
|
-
|
|
127
|
+
| Get From | What | Put In |
|
|
128
|
+
|:---|:---|:---|
|
|
129
|
+
| [Razorpay](https://dashboard.razorpay.com/) | `KEY_ID`, `KEY_SECRET` | `backend/payment/.env` + `frontend/.env` |
|
|
177
130
|
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
| `npm run dev` | Starts all services in development mode |
|
|
181
|
-
| `npm run build` | Builds all apps and packages |
|
|
182
|
-
| `npm run setup` | Initializes environment files |
|
|
183
|
-
| `npm run lint` | Runs linting across the monorepo |
|
|
131
|
+
Enable **Test Mode** first.
|
|
132
|
+
</details>
|
|
184
133
|
|
|
185
134
|
---
|
|
186
135
|
|
|
187
136
|
## ๐ License
|
|
188
137
|
|
|
189
|
-
|
|
138
|
+
[MIT](LICENSE)
|
package/bin/cli.js
CHANGED
|
@@ -1,9 +1,18 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
/* eslint-env node */
|
|
2
3
|
|
|
3
4
|
const degit = require("degit");
|
|
4
5
|
const fs = require("fs");
|
|
5
6
|
const path = require("path");
|
|
6
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));
|
|
7
16
|
|
|
8
17
|
const projectName = process.argv[2];
|
|
9
18
|
|
|
@@ -32,13 +41,36 @@ async function main() {
|
|
|
32
41
|
const emitter = degit("Luff-Org/Luff-Boilerplate", {
|
|
33
42
|
cache: false,
|
|
34
43
|
force: true,
|
|
35
|
-
verbose: true
|
|
44
|
+
verbose: true,
|
|
36
45
|
});
|
|
37
46
|
|
|
38
47
|
await emitter.clone(projectPath);
|
|
39
48
|
|
|
40
49
|
process.chdir(projectPath);
|
|
41
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
|
+
|
|
42
74
|
console.log("\x1b[36m%s\x1b[0m", "๐งน Cleaning up repository history...");
|
|
43
75
|
|
|
44
76
|
try {
|
|
@@ -81,11 +113,14 @@ async function main() {
|
|
|
81
113
|
console.log("Next steps:");
|
|
82
114
|
console.log(` cd ${projectName}`);
|
|
83
115
|
console.log(
|
|
84
|
-
" docker compose -f docker/docker-compose.yml up auth-db posts-db -d"
|
|
116
|
+
" docker compose -f docker/docker-compose.yml up auth-db posts-db payment-db -d"
|
|
85
117
|
);
|
|
86
118
|
console.log(
|
|
87
119
|
" set up .env files from .env.example files, can also use script > npm run setup"
|
|
88
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
|
+
}
|
|
89
124
|
console.log(" npm run dev");
|
|
90
125
|
console.log("");
|
|
91
126
|
} catch (error) {
|