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.
- package/NOTES.md +110 -124
- package/README.md +165 -138
- package/bin/cli.js +35 -1
- 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,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
|
-
|
|
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
|
+
%%{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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
145
|
-
|
|
146
|
-
---
|
|
129
|
+
### Kubernetes Secrets
|
|
147
130
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
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
|
-
|
|
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
|
-
```
|
|
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
|
-
|
|
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
|
-
##
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
##
|
|
167
|
+
## ๐ค 5. CI/CD Pipeline
|
|
188
168
|
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
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
|
-
|
|
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
|
-
###
|
|
177
|
+
### Adding the GitHub Secret
|
|
198
178
|
|
|
199
|
-
|
|
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
|
-
|
|
202
|
-
repoURL: https://github.com/YOUR_ORG/YOUR_REPO.git
|
|
203
|
-
```
|
|
183
|
+
---
|
|
204
184
|
|
|
205
|
-
|
|
185
|
+
## ๐จ 6. Customization Guide
|
|
206
186
|
|
|
207
|
-
|
|
187
|
+
When forking for your own project, search and replace these values:
|
|
208
188
|
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
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
|
-
###
|
|
195
|
+
### Key Files to Update
|
|
215
196
|
|
|
216
|
-
|
|
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
|
-
#
|
|
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
|
+
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
|
-
|
|
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
|
-
|
|
36
|
+
> ๐ง **AI Users**: Add your `GEMINI_API_KEY` and Upstash Vector keys to `backend/ai-service/.env`
|
|
27
37
|
|
|
28
38
|
---
|
|
29
39
|
|
|
30
|
-
## ๐๏ธ
|
|
31
|
-
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
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
|
-
##
|
|
60
|
+
## ๐ก Service Directory
|
|
61
61
|
|
|
62
|
-
|
|
|
63
|
-
|
|
64
|
-
| **
|
|
65
|
-
| **
|
|
66
|
-
| **
|
|
67
|
-
| **Payment**
|
|
68
|
-
| **
|
|
69
|
-
| **
|
|
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
|
-
##
|
|
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
|
-
|
|
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
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
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
|
-
|
|
122
|
-
|
|
123
|
-
```
|
|
124
|
-
|
|
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
|
-
##
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
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
|
-
## ๐
|
|
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
|
-
|
|
181
|
+
## ๐ Credentials Setup
|
|
155
182
|
|
|
156
|
-
|
|
157
|
-
|
|
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
|
-
|
|
191
|
+
Create a Vector Index with **768 dimensions**.
|
|
192
|
+
</details>
|
|
163
193
|
|
|
164
|
-
|
|
194
|
+
<details>
|
|
195
|
+
<summary><b>๐ Auth โ Google OAuth</b></summary>
|
|
165
196
|
|
|
166
|
-
|
|
167
|
-
|
|
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
|
-
|
|
201
|
+
Redirect URI: `http://localhost:4000/auth/callback/google`
|
|
202
|
+
</details>
|
|
171
203
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
```
|
|
175
|
-
|
|
176
|
-
---
|
|
204
|
+
<details>
|
|
205
|
+
<summary><b>๐ณ Payments โ Razorpay</b></summary>
|
|
177
206
|
|
|
178
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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) {
|