create-luff-app 1.0.2 → 1.0.4
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/README.md +156 -0
- package/bin/cli.js +3 -0
- package/package.json +2 -2
package/README.md
ADDED
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
# Microservices Boilerplate
|
|
2
|
+
|
|
3
|
+
A **production-grade microservices monorepo** built with Turborepo, TypeScript, Next.js, Express, Prisma, and PostgreSQL.
|
|
4
|
+
|
|
5
|
+
## Architecture
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
┌─────────────┐
|
|
9
|
+
│ API Gateway│ :4000
|
|
10
|
+
│ (Express) │
|
|
11
|
+
└──────┬──────┘
|
|
12
|
+
│
|
|
13
|
+
┌────────────┼────────────┐
|
|
14
|
+
│ │
|
|
15
|
+
┌─────┴─────┐ ┌──────┴─────┐
|
|
16
|
+
│ Auth │ │ Posts │
|
|
17
|
+
│ Service │ :4001 │ Service │ :4002
|
|
18
|
+
│ (Express) │ │ (Express) │
|
|
19
|
+
└─────┬─────┘ └──────┬─────┘
|
|
20
|
+
│ │
|
|
21
|
+
┌─────┴─────┐ ┌──────┴─────┐
|
|
22
|
+
│ Auth DB │ │ Posts DB │
|
|
23
|
+
│ (Postgres)│ │ (Postgres) │
|
|
24
|
+
└───────────┘ └────────────┘
|
|
25
|
+
|
|
26
|
+
┌─────────────────────────────┐
|
|
27
|
+
│ Frontend App │
|
|
28
|
+
│ (Next.js) │
|
|
29
|
+
│ :3000 │
|
|
30
|
+
└─────────────────────────────┘
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Tech Stack
|
|
34
|
+
|
|
35
|
+
| Layer | Technology |
|
|
36
|
+
| ------------ | -------------------------------------------- |
|
|
37
|
+
| Frontend | Next.js 14, React, TailwindCSS, React Query |
|
|
38
|
+
| API Client | Axios |
|
|
39
|
+
| Backend | Node.js, Express, TypeScript |
|
|
40
|
+
| Database | PostgreSQL, Prisma ORM |
|
|
41
|
+
| Auth | Google OAuth (PostMessage flow), JWT |
|
|
42
|
+
| Gateway | http-proxy-middleware, rate-limit |
|
|
43
|
+
| Monorepo | Turborepo, npm workspaces |
|
|
44
|
+
| Logging | Pino |
|
|
45
|
+
| Config | Zod validation, dotenv |
|
|
46
|
+
| Docker | Multi-stage builds |
|
|
47
|
+
| Orchestrator | Kubernetes |
|
|
48
|
+
| Code Quality | ESLint, Prettier, Husky, Commitlint |
|
|
49
|
+
|
|
50
|
+
## Quick Start
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
# 1. Clone and install
|
|
54
|
+
git clone <repo-url>
|
|
55
|
+
cd Luff-Boilerplate
|
|
56
|
+
npm install
|
|
57
|
+
|
|
58
|
+
# 2. Copy environment files
|
|
59
|
+
bash scripts/setup.sh
|
|
60
|
+
|
|
61
|
+
# 3. Start databases (requires Docker)
|
|
62
|
+
docker compose -f docker/docker-compose.yml up auth-db posts-db -d
|
|
63
|
+
|
|
64
|
+
# 4. Generate Prisma clients and push schemas
|
|
65
|
+
cd backend/auth && npm run db:push && npm run db:generate && cd ../..
|
|
66
|
+
cd backend/posts && npm run db:push && npm run db:generate && cd ../..
|
|
67
|
+
|
|
68
|
+
# 5. Start all services
|
|
69
|
+
npm run dev
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
This starts:
|
|
73
|
+
|
|
74
|
+
| Service | URL |
|
|
75
|
+
| -------------- | ---------------------- |
|
|
76
|
+
| API Gateway | http://localhost:4000 |
|
|
77
|
+
| Auth Service | http://localhost:4001 |
|
|
78
|
+
| Posts Service | http://localhost:4002 |
|
|
79
|
+
| Web Frontend | http://localhost:3000 |
|
|
80
|
+
|
|
81
|
+
## Project Structure
|
|
82
|
+
|
|
83
|
+
```text
|
|
84
|
+
├── frontend/ # Unified Next.js application (Auth + Posts)
|
|
85
|
+
├── backend/
|
|
86
|
+
│ ├── auth/ # Auth microservice (Google OAuth postmessage, JWT)
|
|
87
|
+
│ ├── posts/ # Posts microservice (CRUD)
|
|
88
|
+
│ └── api-gateway/ # API Gateway (Express proxy, rate-limit)
|
|
89
|
+
├── shared/
|
|
90
|
+
│ ├── types/ # Shared TypeScript types
|
|
91
|
+
│ ├── logger/ # Shared Pino logger setup
|
|
92
|
+
│ ├── config/ # Zod env validation schema
|
|
93
|
+
│ └── eslint-config/ # Default ESLint rules
|
|
94
|
+
├── docker/ # Docker Compose Definitions
|
|
95
|
+
├── k8s/ # Kubernetes Manifests
|
|
96
|
+
└── scripts/ # CI/CD and Local Setup Scripts
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
## API Endpoints
|
|
100
|
+
|
|
101
|
+
### Auth Service (Proxied via Gateway `:4000`)
|
|
102
|
+
|
|
103
|
+
| Method | Endpoint | Auth | Description |
|
|
104
|
+
| ------ | -------------- | ---- | ----------------------------- |
|
|
105
|
+
| POST | /auth/login | No | Google OAuth postmessage login|
|
|
106
|
+
| GET | /auth/me | Yes | Get current user profile |
|
|
107
|
+
| POST | /auth/logout | Yes | Logout (clear session) |
|
|
108
|
+
|
|
109
|
+
### Posts Service (Proxied via Gateway `:4000`)
|
|
110
|
+
|
|
111
|
+
| Method | Endpoint | Auth | Description |
|
|
112
|
+
| ------ | -------------- | ---- | -------------------- |
|
|
113
|
+
| GET | /posts | No | List all posts |
|
|
114
|
+
| GET | /posts/:id | No | Get post by ID |
|
|
115
|
+
| POST | /posts | Yes | Create a post |
|
|
116
|
+
| DELETE | /posts/:id | Yes | Delete a post |
|
|
117
|
+
|
|
118
|
+
## Docker
|
|
119
|
+
|
|
120
|
+
### Run with Docker Compose
|
|
121
|
+
|
|
122
|
+
```bash
|
|
123
|
+
docker compose -f docker/docker-compose.yml up --build
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
### Build individual images
|
|
127
|
+
|
|
128
|
+
```bash
|
|
129
|
+
docker build -f backend/auth/Dockerfile -t auth-service .
|
|
130
|
+
docker build -f backend/posts/Dockerfile -t posts-service .
|
|
131
|
+
docker build -f backend/api-gateway/Dockerfile -t api-gateway .
|
|
132
|
+
docker build -f frontend/Dockerfile -t frontend-app .
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
## Kubernetes
|
|
136
|
+
|
|
137
|
+
```bash
|
|
138
|
+
# Apply all manifests
|
|
139
|
+
kubectl apply -f k8s/
|
|
140
|
+
|
|
141
|
+
# Note: You must manually deploy secrets in your cluster:
|
|
142
|
+
# - auth-secrets (database-url, jwt-secret, google auth credentials)
|
|
143
|
+
# - posts-secrets (database-url, jwt-secret)
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
## Scripts
|
|
147
|
+
|
|
148
|
+
```bash
|
|
149
|
+
npm run dev # Start all services (Turborepo)
|
|
150
|
+
npm run build # Build all TypeScript packages & apps
|
|
151
|
+
npm run lint # Lint across the monorepo
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
## License
|
|
155
|
+
|
|
156
|
+
MIT
|
package/bin/cli.js
CHANGED
|
@@ -83,6 +83,9 @@ async function main() {
|
|
|
83
83
|
console.log(
|
|
84
84
|
" docker compose -f docker/docker-compose.yml up auth-db posts-db -d"
|
|
85
85
|
);
|
|
86
|
+
console.log(
|
|
87
|
+
" set up .env files from .env.example files, can also use script > npm run setup"
|
|
88
|
+
);
|
|
86
89
|
console.log(" npm run dev");
|
|
87
90
|
console.log("");
|
|
88
91
|
} catch (error) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-luff-app",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"description": "CLI to scaffold the Luff Microservices Boilerplate",
|
|
5
5
|
"bin": {
|
|
6
6
|
"create-luff-app": "bin/cli.js"
|
|
@@ -16,4 +16,4 @@
|
|
|
16
16
|
"url": "https://github.com/Luff-Org/Luff-Boilerplate"
|
|
17
17
|
},
|
|
18
18
|
"license": "MIT"
|
|
19
|
-
}
|
|
19
|
+
}
|