fastapi-spawn 0.1.0__tar.gz → 0.2.0__tar.gz

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 (63) hide show
  1. {fastapi_spawn-0.1.0 → fastapi_spawn-0.2.0}/PKG-INFO +154 -94
  2. fastapi_spawn-0.2.0/README.md +281 -0
  3. {fastapi_spawn-0.1.0 → fastapi_spawn-0.2.0}/fastapi_spawn/__init__.py +2 -1
  4. {fastapi_spawn-0.1.0 → fastapi_spawn-0.2.0}/fastapi_spawn/config.py +94 -47
  5. fastapi_spawn-0.2.0/fastapi_spawn/constants.py +223 -0
  6. {fastapi_spawn-0.1.0 → fastapi_spawn-0.2.0}/fastapi_spawn/generator.py +22 -1
  7. fastapi_spawn-0.2.0/fastapi_spawn/templates/app/core/ai.py.j2 +140 -0
  8. {fastapi_spawn-0.1.0 → fastapi_spawn-0.2.0}/fastapi_spawn/templates/app/core/config.py.j2 +100 -19
  9. fastapi_spawn-0.2.0/fastapi_spawn/templates/app/core/email.py.j2 +87 -0
  10. fastapi_spawn-0.2.0/fastapi_spawn/templates/app/core/logger.py.j2 +117 -0
  11. fastapi_spawn-0.2.0/fastapi_spawn/templates/app/core/monitoring.py.j2 +46 -0
  12. fastapi_spawn-0.2.0/fastapi_spawn/templates/app/core/notifications.py.j2 +70 -0
  13. fastapi_spawn-0.2.0/fastapi_spawn/templates/app/core/vector_db.py.j2 +92 -0
  14. fastapi_spawn-0.2.0/fastapi_spawn/templates/app/middleware/__init__.py.j2 +1 -0
  15. fastapi_spawn-0.2.0/fastapi_spawn/templates/app/middleware/rate_limit.py.j2 +24 -0
  16. fastapi_spawn-0.2.0/fastapi_spawn/templates/app/middleware/request_logger.py.j2 +100 -0
  17. fastapi_spawn-0.2.0/fastapi_spawn/templates/base/env_example.j2 +243 -0
  18. {fastapi_spawn-0.1.0 → fastapi_spawn-0.2.0}/fastapi_spawn/templates/base/pyproject.toml.j2 +68 -21
  19. {fastapi_spawn-0.1.0 → fastapi_spawn-0.2.0}/pyproject.toml +1 -1
  20. fastapi_spawn-0.1.0/README.md +0 -221
  21. fastapi_spawn-0.1.0/fastapi_spawn/constants.py +0 -133
  22. fastapi_spawn-0.1.0/fastapi_spawn/templates/app/core/ai.py.j2 +0 -76
  23. fastapi_spawn-0.1.0/fastapi_spawn/templates/base/env_example.j2 +0 -85
  24. {fastapi_spawn-0.1.0 → fastapi_spawn-0.2.0}/.gitignore +0 -0
  25. {fastapi_spawn-0.1.0 → fastapi_spawn-0.2.0}/CHANGELOG.md +0 -0
  26. {fastapi_spawn-0.1.0 → fastapi_spawn-0.2.0}/LICENSE +0 -0
  27. {fastapi_spawn-0.1.0 → fastapi_spawn-0.2.0}/fastapi_spawn/cli.py +0 -0
  28. {fastapi_spawn-0.1.0 → fastapi_spawn-0.2.0}/fastapi_spawn/interactive.py +0 -0
  29. {fastapi_spawn-0.1.0 → fastapi_spawn-0.2.0}/fastapi_spawn/templates/alembic/alembic.ini.j2 +0 -0
  30. {fastapi_spawn-0.1.0 → fastapi_spawn-0.2.0}/fastapi_spawn/templates/alembic/env.py.j2 +0 -0
  31. {fastapi_spawn-0.1.0 → fastapi_spawn-0.2.0}/fastapi_spawn/templates/app/__init__.py.j2 +0 -0
  32. {fastapi_spawn-0.1.0 → fastapi_spawn-0.2.0}/fastapi_spawn/templates/app/api/deps.py.j2 +0 -0
  33. {fastapi_spawn-0.1.0 → fastapi_spawn-0.2.0}/fastapi_spawn/templates/app/api/v1/auth.py.j2 +0 -0
  34. {fastapi_spawn-0.1.0 → fastapi_spawn-0.2.0}/fastapi_spawn/templates/app/api/v1/health.py.j2 +0 -0
  35. {fastapi_spawn-0.1.0 → fastapi_spawn-0.2.0}/fastapi_spawn/templates/app/core/exceptions.py.j2 +0 -0
  36. {fastapi_spawn-0.1.0 → fastapi_spawn-0.2.0}/fastapi_spawn/templates/app/core/logging.py.j2 +0 -0
  37. {fastapi_spawn-0.1.0 → fastapi_spawn-0.2.0}/fastapi_spawn/templates/app/core/security.py.j2 +0 -0
  38. {fastapi_spawn-0.1.0 → fastapi_spawn-0.2.0}/fastapi_spawn/templates/app/core/storage.py.j2 +0 -0
  39. {fastapi_spawn-0.1.0 → fastapi_spawn-0.2.0}/fastapi_spawn/templates/app/db/session.py.j2 +0 -0
  40. {fastapi_spawn-0.1.0 → fastapi_spawn-0.2.0}/fastapi_spawn/templates/app/main.py.j2 +0 -0
  41. {fastapi_spawn-0.1.0 → fastapi_spawn-0.2.0}/fastapi_spawn/templates/base/Makefile.j2 +0 -0
  42. {fastapi_spawn-0.1.0 → fastapi_spawn-0.2.0}/fastapi_spawn/templates/base/README.md.j2 +0 -0
  43. {fastapi_spawn-0.1.0 → fastapi_spawn-0.2.0}/fastapi_spawn/templates/base/env.j2 +0 -0
  44. {fastapi_spawn-0.1.0 → fastapi_spawn-0.2.0}/fastapi_spawn/templates/base/gitignore.j2 +0 -0
  45. {fastapi_spawn-0.1.0 → fastapi_spawn-0.2.0}/fastapi_spawn/templates/base/pre_commit.j2 +0 -0
  46. {fastapi_spawn-0.1.0 → fastapi_spawn-0.2.0}/fastapi_spawn/templates/ci/github/publish.yml.j2 +0 -0
  47. {fastapi_spawn-0.1.0 → fastapi_spawn-0.2.0}/fastapi_spawn/templates/ci/github/tests.yml.j2 +0 -0
  48. {fastapi_spawn-0.1.0 → fastapi_spawn-0.2.0}/fastapi_spawn/templates/ci/gitlab/gitlab-ci.yml.j2 +0 -0
  49. {fastapi_spawn-0.1.0 → fastapi_spawn-0.2.0}/fastapi_spawn/templates/docker/Dockerfile.j2 +0 -0
  50. {fastapi_spawn-0.1.0 → fastapi_spawn-0.2.0}/fastapi_spawn/templates/docker/docker-compose.yml.j2 +0 -0
  51. {fastapi_spawn-0.1.0 → fastapi_spawn-0.2.0}/fastapi_spawn/templates/docker/dockerignore.j2 +0 -0
  52. {fastapi_spawn-0.1.0 → fastapi_spawn-0.2.0}/fastapi_spawn/templates/infra/docker/docker-compose.prod.yml.j2 +0 -0
  53. {fastapi_spawn-0.1.0 → fastapi_spawn-0.2.0}/fastapi_spawn/templates/infra/helm/Chart.yaml.j2 +0 -0
  54. {fastapi_spawn-0.1.0 → fastapi_spawn-0.2.0}/fastapi_spawn/templates/infra/helm/values.yaml.j2 +0 -0
  55. {fastapi_spawn-0.1.0 → fastapi_spawn-0.2.0}/fastapi_spawn/templates/infra/terraform/main.tf.j2 +0 -0
  56. {fastapi_spawn-0.1.0 → fastapi_spawn-0.2.0}/fastapi_spawn/templates/infra/terraform/variables.tf.j2 +0 -0
  57. {fastapi_spawn-0.1.0 → fastapi_spawn-0.2.0}/fastapi_spawn/templates/root/main.py.j2 +0 -0
  58. {fastapi_spawn-0.1.0 → fastapi_spawn-0.2.0}/fastapi_spawn/templates/tasks/celery_app.py.j2 +0 -0
  59. {fastapi_spawn-0.1.0 → fastapi_spawn-0.2.0}/fastapi_spawn/templates/tasks/sample_tasks.py.j2 +0 -0
  60. {fastapi_spawn-0.1.0 → fastapi_spawn-0.2.0}/fastapi_spawn/templates/tests/conftest.py.j2 +0 -0
  61. {fastapi_spawn-0.1.0 → fastapi_spawn-0.2.0}/fastapi_spawn/templates/tests/test_health.py.j2 +0 -0
  62. {fastapi_spawn-0.1.0 → fastapi_spawn-0.2.0}/fastapi_spawn/utils.py +0 -0
  63. {fastapi_spawn-0.1.0 → fastapi_spawn-0.2.0}/fastapi_spawn/validators.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fastapi-spawn
3
- Version: 0.1.0
3
+ Version: 0.2.0
4
4
  Summary: A powerful CLI tool to scaffold production-ready FastAPI projects with flexible database, auth, broker, and deployment options.
5
5
  Project-URL: Homepage, https://github.com/Bishwajitgarai/fastapi-spawn
6
6
  Project-URL: Documentation, https://github.com/Bishwajitgarai/fastapi-spawn#readme
@@ -50,31 +50,9 @@ Description-Content-Type: text/markdown
50
50
  [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg?style=flat-square)](LICENSE)
51
51
  [![CI](https://img.shields.io/github/actions/workflow/status/Bishwajitgarai/fastapi-spawn/tests.yml?label=tests&style=flat-square)](https://github.com/Bishwajitgarai/fastapi-spawn/actions)
52
52
 
53
- </div>
54
-
55
- ---
53
+ Generate production-ready FastAPI projects in seconds — with exactly the stack you need.
56
54
 
57
- ## Why fastapi-spawn?
58
-
59
- `fastapi-spawn` generates **production-ready** FastAPI projects in seconds. No boilerplate, no guesswork — just run one command and get a fully structured, configured project with the exact stack you need.
60
-
61
- | Feature | scaffold-fastapi | **fastapi-spawn** |
62
- |---|---|---|
63
- | Interactive TUI | Basic prompts | ✅ Rich questionary TUI |
64
- | Databases | PostgreSQL, MongoDB, SQLite | ✅ + MySQL |
65
- | ORM | None | ✅ SQLAlchemy 2.x, Tortoise, Beanie |
66
- | Migrations | ❌ | ✅ Alembic (async), Aerich |
67
- | Auth | ❌ | ✅ JWT, OAuth2, API Key |
68
- | Message brokers | Redis, RabbitMQ | ✅ + Kafka |
69
- | File storage | ❌ | ✅ AWS S3 (boto3) |
70
- | AI integration | ❌ | ✅ OpenAI, Anthropic |
71
- | Config style | Single URL | ✅ Individual fields + `@property` URL |
72
- | Entry point | app/main.py | ✅ Root `main.py` (`uv run main.py`) |
73
- | CI/CD | GitHub Actions | ✅ GitHub Actions + GitLab CI |
74
- | Observability | ❌ | ✅ /health /readiness /liveness |
75
- | Logging | None | ✅ loguru / structlog / standard |
76
- | Package manager | uv | ✅ uv (with `[tool.uv]` config) |
77
- | Dry-run mode | ❌ | ✅ Preview tree before generating |
55
+ </div>
78
56
 
79
57
  ---
80
58
 
@@ -91,10 +69,10 @@ uv pip install fastapi-spawn
91
69
  ## Quick Start
92
70
 
93
71
  ```bash
94
- # Fully interactive — guided TUI
72
+ # Interactive TUI — guided step-by-step
95
73
  fastapi-spawn new my-api
96
74
 
97
- # One-liner (all flags)
75
+ # One-liner with all flags
98
76
  fastapi-spawn new my-api \
99
77
  --db postgresql \
100
78
  --orm sqlalchemy \
@@ -103,87 +81,73 @@ fastapi-spawn new my-api \
103
81
  --broker redis \
104
82
  --storage s3 \
105
83
  --ai openai \
84
+ --monitoring sentry \
85
+ --email sendgrid \
86
+ --log-dest cloudwatch \
87
+ --vector-db qdrant \
106
88
  --stack full \
107
- --ci github \
108
- --log-lib loguru
89
+ --ci github
109
90
 
110
- # Preview without writing files
91
+ # Preview file tree without writing
111
92
  fastapi-spawn new my-api --dry-run
93
+
94
+ # Add a feature to an existing project
95
+ fastapi-spawn add openai
96
+ fastapi-spawn add alembic
97
+ fastapi-spawn add sentry
112
98
  ```
113
99
 
114
100
  ---
115
101
 
116
- ## Generated Project Structure
102
+ ## What Gets Generated
117
103
 
118
104
  ```
119
105
  my-api/
120
106
  ├── app/
121
107
  │ ├── api/
122
108
  │ │ └── v1/
123
- │ │ ├── health.py # /health /readiness /liveness
124
- │ │ └── auth.py # JWT login + refresh
109
+ │ │ ├── health.py # GET /health /readiness /liveness
110
+ │ │ └── auth.py # POST /auth/login /auth/refresh
125
111
  │ ├── core/
126
- │ │ ├── config.py # Pydantic Settings v2 (individual env fields)
127
- │ │ ├── logging.py # loguru / structlog / standard
128
- │ │ ├── exceptions.py # Custom exception hierarchy
129
- │ │ ├── security.py # JWT + bcrypt (when auth enabled)
130
- │ │ ├── storage.py # AWS S3 utils (when s3 chosen)
131
- │ │ └── ai.py # OpenAI / Anthropic client (when AI chosen)
112
+ │ │ ├── config.py # Pydantic Settings v2 individual env fields + @property URLs
113
+ │ │ ├── logger.py # Context-var logger request ID, client IP, dual-timezone
114
+ │ │ ├── exceptions.py # Custom exception hierarchy + handlers
115
+ │ │ ├── security.py # JWT / bcrypt
116
+ │ │ ├── storage.py # AWS S3 / MinIO helpers
117
+ │ │ ├── ai.py # OpenAI / Anthropic / Gemini / Ollama async client
118
+ │ │ ├── email.py # SendGrid / SMTP / SES
119
+ │ │ └── monitoring.py # Sentry init / Prometheus metrics
120
+ │ ├── middleware/
121
+ │ │ ├── request_logger.py # X-Request-ID, response time, structured logs
122
+ │ │ └── rate_limit.py # slowapi — 429 with Retry-After
132
123
  │ ├── db/
133
124
  │ │ └── session.py # Async SQLAlchemy / Tortoise / Beanie
134
- │ ├── models/ # ORM models
135
- │ ├── schemas/ # Pydantic schemas
136
- │ ├── services/ # Business logic layer
137
- │ └── repositories/ # Data access layer
125
+ │ ├── models/
126
+ │ ├── schemas/
127
+ │ ├── services/
128
+ │ └── repositories/
138
129
  ├── tasks/ # Celery workers (root-level)
139
130
  │ ├── celery_app.py
140
131
  │ └── sample_tasks.py
141
- ├── migrations/ # Alembic migrations
142
- │ ├── env.py # Async-compatible env
132
+ ├── migrations/ # Alembic (async-compatible)
133
+ │ ├── env.py
143
134
  │ └── versions/
144
135
  ├── infra/
145
136
  │ ├── docker/
146
137
  │ ├── helm/
147
138
  │ └── terraform/
148
139
  ├── tests/
149
- ├── conftest.py
150
- │ └── test_health.py
151
- ├── main.py # uv run main.py entry point
140
+ ├── logs/ # Local log rotation directory
141
+ ├── main.py # uv run main.py
152
142
  ├── alembic.ini
153
- ├── Dockerfile # Uses uv for fast builds
154
- ├── docker-compose.yml # All services pre-configured
143
+ ├── Dockerfile # Uses uv for fast layer-cached builds
144
+ ├── docker-compose.yml # All selected services pre-configured
155
145
  ├── .env # gitignored
156
146
  ├── .env.example
157
147
  ├── .gitignore
158
148
  ├── .pre-commit-config.yaml
159
149
  ├── Makefile
160
- └── pyproject.toml # uv-compatible
161
- ```
162
-
163
- ---
164
-
165
- ## Environment Variables
166
-
167
- `fastapi-spawn` generates **individual env fields** (not URL strings) for every service, assembled into URLs via `@property`:
168
-
169
- ```env
170
- # PostgreSQL — assembled into DATABASE_URL by settings
171
- POSTGRES_USER=postgres
172
- POSTGRES_PASSWORD=postgres
173
- POSTGRES_HOST=localhost
174
- POSTGRES_PORT=5432
175
- POSTGRES_DB=my_api_db
176
-
177
- # OpenAI — supports custom base URL for Azure / LM Studio
178
- OPENAI_API_KEY=sk-placeholder
179
- OPENAI_MODEL=gpt-4o
180
- OPENAI_BASE_URL= # blank = api.openai.com
181
-
182
- # Redis
183
- REDIS_HOST=localhost
184
- REDIS_PORT=6379
185
- REDIS_PASSWORD=
186
- REDIS_DB=0
150
+ └── pyproject.toml # uv-compatible with [tool.uv.scripts]
187
151
  ```
188
152
 
189
153
  ---
@@ -193,42 +157,128 @@ REDIS_DB=0
193
157
  ```
194
158
  fastapi-spawn new [OPTIONS] PROJECT_NAME
195
159
 
160
+ Database & ORM
196
161
  --db postgresql | mysql | mongodb | sqlite | none
197
162
  --orm sqlalchemy | tortoise | beanie | none
198
163
  --migration alembic | aerich | none
164
+
165
+ Auth & Security
199
166
  --auth jwt | oauth2 | api-key | none
167
+
168
+ Messaging & Cache
200
169
  --broker redis | rabbitmq | kafka | none
201
170
  --cache redis | memcached | none
202
- --storage s3 | local | none
203
- --ai openai | anthropic | none
171
+
172
+ Storage
173
+ --storage s3 | local | none (s3 = AWS S3 or MinIO)
174
+
175
+ AI / LLM
176
+ --ai openai | anthropic | gemini | ollama | none
177
+
178
+ Monitoring
179
+ --monitoring sentry | prometheus | both | none
180
+
181
+ Email
182
+ --email sendgrid | smtp | ses | none
183
+
184
+ Notifications
185
+ --notify slack | discord | none
186
+
187
+ Logging
188
+ --log-lib loguru | structlog | standard
189
+ --log-dest local | cloudwatch | datadog | none
190
+
191
+ Vector Database
192
+ --vector-db qdrant | pinecone | elasticsearch | none
193
+
194
+ Deployment
204
195
  --stack minimal | standard | full
205
196
  --ci github | gitlab | both | none
206
- --log-lib loguru | structlog | standard
197
+
198
+ Flags
207
199
  --no-docker Skip Docker files
208
200
  --no-tests Skip test suite
209
- --dry-run Preview file tree only
201
+ --dry-run Preview file tree without writing
210
202
  --force / -f Overwrite existing directory
211
- --output / -o Output directory (default: .)
203
+ --output / -o Output directory
212
204
  ```
213
205
 
214
- ### Subcommands
206
+ ---
207
+
208
+ ## uv run Scripts
209
+
210
+ Every generated project has `[tool.uv.scripts]` pre-wired:
215
211
 
216
212
  ```bash
217
- fastapi-spawn list-templates # Show all options + ORM/DB compatibility
218
- fastapi-spawn validate FILE # Validate a .fastapi-spawn.toml
213
+ uv run dev # uvicorn --reload
214
+ uv run start # python main.py
215
+ uv run test # pytest --cov
216
+ uv run lint # ruff check
217
+ uv run format # ruff format
218
+ uv run typecheck # mypy
219
+ uv run migrate # alembic upgrade head (if alembic)
220
+ uv run rollback # alembic downgrade -1 (if alembic)
221
+ uv run makemig # alembic revision --autogenerate (if alembic)
222
+ uv run worker # celery worker (if broker)
223
+ uv run beat # celery beat (if broker)
224
+ ```
225
+
226
+ ---
227
+
228
+ ## Environment Variables
229
+
230
+ Individual fields per service — **no URL strings**. URLs are assembled via `@property`:
231
+
232
+ ```env
233
+ ENVIRONMENT=dev
234
+ SECRET_KEY=super-secret-change-in-production
235
+
236
+ # PostgreSQL
237
+ POSTGRES_USER=postgres
238
+ POSTGRES_PASSWORD=postgres
239
+ POSTGRES_HOST=localhost
240
+ POSTGRES_PORT=5432
241
+ POSTGRES_DB=my_api_db
242
+
243
+ # Redis
244
+ REDIS_HOST=localhost
245
+ REDIS_PORT=6379
246
+ REDIS_PASSWORD=
247
+ REDIS_DB=0
248
+
249
+ # AWS S3 (or MinIO — set ENDPOINT_URL for local)
250
+ AWS_ACCESS_KEY_ID=AKIAIOSFODNN7EXAMPLE
251
+ AWS_SECRET_ACCESS_KEY=wJalrXUtnFEMI/K7MDENG
252
+ AWS_REGION=us-east-1
253
+ AWS_S3_BUCKET=my-api-bucket
254
+ AWS_S3_ENDPOINT_URL=http://localhost:9000 # MinIO local
255
+
256
+ # OpenAI (supports custom base URL for Azure / LM Studio)
257
+ OPENAI_API_KEY=sk-placeholder
258
+ OPENAI_MODEL=gpt-4o
259
+ OPENAI_BASE_URL=
260
+
261
+ # Sentry
262
+ SENTRY_DSN=https://xxx@sentry.io/yyy
263
+
264
+ # Logging
265
+ LOG_LEVEL=INFO
266
+ LOG_DIR=logs
267
+ LOG_BACKUP_DAYS=30
219
268
  ```
220
269
 
221
270
  ---
222
271
 
223
- ## After Scaffolding
272
+ ## Add Features to Existing Projects
224
273
 
225
274
  ```bash
226
- cd my-api
227
- uv sync # Install all dependencies
228
- uv run alembic upgrade head # Run DB migrations (if alembic)
229
- docker compose up --build # Start all services
230
- # or
231
- uv run main.py # Run locally
275
+ fastapi-spawn add sentry # Sentry error tracking setup
276
+ fastapi-spawn add openai # OpenAI async client + env vars
277
+ fastapi-spawn add alembic # Alembic async migrations
278
+ fastapi-spawn add s3 # AWS S3 / MinIO storage utils
279
+ fastapi-spawn add celery # Celery worker + tasks/
280
+ fastapi-spawn add helm # Helm chart in infra/helm/
281
+ fastapi-spawn add terraform # Terraform scaffold in infra/terraform/
232
282
  ```
233
283
 
234
284
  ---
@@ -244,6 +294,18 @@ uv run main.py # Run locally
244
294
 
245
295
  ---
246
296
 
297
+ ## Middleware Stack (always included)
298
+
299
+ | Middleware | What it does |
300
+ |---|---|
301
+ | `RequestLoggingMiddleware` | Logs `→ METHOD /path` + `✓ status duration` with request ID |
302
+ | `RateLimitMiddleware` | 200 req/min default via slowapi, returns 429 + `Retry-After` |
303
+ | `CORSMiddleware` | Configurable via `CORS_ORIGINS` env var |
304
+
305
+ Every response includes `X-Request-ID` and `X-Response-Time` headers.
306
+
307
+ ---
308
+
247
309
  ## Contributing
248
310
 
249
311
  ```bash
@@ -253,8 +315,6 @@ uv sync --all-extras
253
315
  uv run pytest
254
316
  ```
255
317
 
256
- PRs are welcome! See [CONTRIBUTING.md](CONTRIBUTING.md).
257
-
258
318
  ---
259
319
 
260
320
  ## License
@@ -0,0 +1,281 @@
1
+ <div align="center">
2
+
3
+ # ⚡ fastapi-spawn
4
+
5
+ **The most complete FastAPI project scaffolding CLI — built for modern Python development.**
6
+
7
+ [![PyPI version](https://img.shields.io/pypi/v/fastapi-spawn.svg?color=cyan&style=flat-square)](https://pypi.org/project/fastapi-spawn/)
8
+ [![Python](https://img.shields.io/pypi/pyversions/fastapi-spawn.svg?style=flat-square)](https://pypi.org/project/fastapi-spawn/)
9
+ [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg?style=flat-square)](LICENSE)
10
+ [![CI](https://img.shields.io/github/actions/workflow/status/Bishwajitgarai/fastapi-spawn/tests.yml?label=tests&style=flat-square)](https://github.com/Bishwajitgarai/fastapi-spawn/actions)
11
+
12
+ Generate production-ready FastAPI projects in seconds — with exactly the stack you need.
13
+
14
+ </div>
15
+
16
+ ---
17
+
18
+ ## Installation
19
+
20
+ ```bash
21
+ pip install fastapi-spawn
22
+ # or
23
+ uv pip install fastapi-spawn
24
+ ```
25
+
26
+ ---
27
+
28
+ ## Quick Start
29
+
30
+ ```bash
31
+ # Interactive TUI — guided step-by-step
32
+ fastapi-spawn new my-api
33
+
34
+ # One-liner with all flags
35
+ fastapi-spawn new my-api \
36
+ --db postgresql \
37
+ --orm sqlalchemy \
38
+ --migration alembic \
39
+ --auth jwt \
40
+ --broker redis \
41
+ --storage s3 \
42
+ --ai openai \
43
+ --monitoring sentry \
44
+ --email sendgrid \
45
+ --log-dest cloudwatch \
46
+ --vector-db qdrant \
47
+ --stack full \
48
+ --ci github
49
+
50
+ # Preview file tree without writing
51
+ fastapi-spawn new my-api --dry-run
52
+
53
+ # Add a feature to an existing project
54
+ fastapi-spawn add openai
55
+ fastapi-spawn add alembic
56
+ fastapi-spawn add sentry
57
+ ```
58
+
59
+ ---
60
+
61
+ ## What Gets Generated
62
+
63
+ ```
64
+ my-api/
65
+ ├── app/
66
+ │ ├── api/
67
+ │ │ └── v1/
68
+ │ │ ├── health.py # GET /health /readiness /liveness
69
+ │ │ └── auth.py # POST /auth/login /auth/refresh
70
+ │ ├── core/
71
+ │ │ ├── config.py # Pydantic Settings v2 — individual env fields + @property URLs
72
+ │ │ ├── logger.py # Context-var logger — request ID, client IP, dual-timezone
73
+ │ │ ├── exceptions.py # Custom exception hierarchy + handlers
74
+ │ │ ├── security.py # JWT / bcrypt
75
+ │ │ ├── storage.py # AWS S3 / MinIO helpers
76
+ │ │ ├── ai.py # OpenAI / Anthropic / Gemini / Ollama async client
77
+ │ │ ├── email.py # SendGrid / SMTP / SES
78
+ │ │ └── monitoring.py # Sentry init / Prometheus metrics
79
+ │ ├── middleware/
80
+ │ │ ├── request_logger.py # X-Request-ID, response time, structured logs
81
+ │ │ └── rate_limit.py # slowapi — 429 with Retry-After
82
+ │ ├── db/
83
+ │ │ └── session.py # Async SQLAlchemy / Tortoise / Beanie
84
+ │ ├── models/
85
+ │ ├── schemas/
86
+ │ ├── services/
87
+ │ └── repositories/
88
+ ├── tasks/ # Celery workers (root-level)
89
+ │ ├── celery_app.py
90
+ │ └── sample_tasks.py
91
+ ├── migrations/ # Alembic (async-compatible)
92
+ │ ├── env.py
93
+ │ └── versions/
94
+ ├── infra/
95
+ │ ├── docker/
96
+ │ ├── helm/
97
+ │ └── terraform/
98
+ ├── tests/
99
+ ├── logs/ # Local log rotation directory
100
+ ├── main.py # uv run main.py
101
+ ├── alembic.ini
102
+ ├── Dockerfile # Uses uv for fast layer-cached builds
103
+ ├── docker-compose.yml # All selected services pre-configured
104
+ ├── .env # gitignored
105
+ ├── .env.example
106
+ ├── .gitignore
107
+ ├── .pre-commit-config.yaml
108
+ ├── Makefile
109
+ └── pyproject.toml # uv-compatible with [tool.uv.scripts]
110
+ ```
111
+
112
+ ---
113
+
114
+ ## All Options
115
+
116
+ ```
117
+ fastapi-spawn new [OPTIONS] PROJECT_NAME
118
+
119
+ Database & ORM
120
+ --db postgresql | mysql | mongodb | sqlite | none
121
+ --orm sqlalchemy | tortoise | beanie | none
122
+ --migration alembic | aerich | none
123
+
124
+ Auth & Security
125
+ --auth jwt | oauth2 | api-key | none
126
+
127
+ Messaging & Cache
128
+ --broker redis | rabbitmq | kafka | none
129
+ --cache redis | memcached | none
130
+
131
+ Storage
132
+ --storage s3 | local | none (s3 = AWS S3 or MinIO)
133
+
134
+ AI / LLM
135
+ --ai openai | anthropic | gemini | ollama | none
136
+
137
+ Monitoring
138
+ --monitoring sentry | prometheus | both | none
139
+
140
+ Email
141
+ --email sendgrid | smtp | ses | none
142
+
143
+ Notifications
144
+ --notify slack | discord | none
145
+
146
+ Logging
147
+ --log-lib loguru | structlog | standard
148
+ --log-dest local | cloudwatch | datadog | none
149
+
150
+ Vector Database
151
+ --vector-db qdrant | pinecone | elasticsearch | none
152
+
153
+ Deployment
154
+ --stack minimal | standard | full
155
+ --ci github | gitlab | both | none
156
+
157
+ Flags
158
+ --no-docker Skip Docker files
159
+ --no-tests Skip test suite
160
+ --dry-run Preview file tree without writing
161
+ --force / -f Overwrite existing directory
162
+ --output / -o Output directory
163
+ ```
164
+
165
+ ---
166
+
167
+ ## uv run Scripts
168
+
169
+ Every generated project has `[tool.uv.scripts]` pre-wired:
170
+
171
+ ```bash
172
+ uv run dev # uvicorn --reload
173
+ uv run start # python main.py
174
+ uv run test # pytest --cov
175
+ uv run lint # ruff check
176
+ uv run format # ruff format
177
+ uv run typecheck # mypy
178
+ uv run migrate # alembic upgrade head (if alembic)
179
+ uv run rollback # alembic downgrade -1 (if alembic)
180
+ uv run makemig # alembic revision --autogenerate (if alembic)
181
+ uv run worker # celery worker (if broker)
182
+ uv run beat # celery beat (if broker)
183
+ ```
184
+
185
+ ---
186
+
187
+ ## Environment Variables
188
+
189
+ Individual fields per service — **no URL strings**. URLs are assembled via `@property`:
190
+
191
+ ```env
192
+ ENVIRONMENT=dev
193
+ SECRET_KEY=super-secret-change-in-production
194
+
195
+ # PostgreSQL
196
+ POSTGRES_USER=postgres
197
+ POSTGRES_PASSWORD=postgres
198
+ POSTGRES_HOST=localhost
199
+ POSTGRES_PORT=5432
200
+ POSTGRES_DB=my_api_db
201
+
202
+ # Redis
203
+ REDIS_HOST=localhost
204
+ REDIS_PORT=6379
205
+ REDIS_PASSWORD=
206
+ REDIS_DB=0
207
+
208
+ # AWS S3 (or MinIO — set ENDPOINT_URL for local)
209
+ AWS_ACCESS_KEY_ID=AKIAIOSFODNN7EXAMPLE
210
+ AWS_SECRET_ACCESS_KEY=wJalrXUtnFEMI/K7MDENG
211
+ AWS_REGION=us-east-1
212
+ AWS_S3_BUCKET=my-api-bucket
213
+ AWS_S3_ENDPOINT_URL=http://localhost:9000 # MinIO local
214
+
215
+ # OpenAI (supports custom base URL for Azure / LM Studio)
216
+ OPENAI_API_KEY=sk-placeholder
217
+ OPENAI_MODEL=gpt-4o
218
+ OPENAI_BASE_URL=
219
+
220
+ # Sentry
221
+ SENTRY_DSN=https://xxx@sentry.io/yyy
222
+
223
+ # Logging
224
+ LOG_LEVEL=INFO
225
+ LOG_DIR=logs
226
+ LOG_BACKUP_DAYS=30
227
+ ```
228
+
229
+ ---
230
+
231
+ ## Add Features to Existing Projects
232
+
233
+ ```bash
234
+ fastapi-spawn add sentry # Sentry error tracking setup
235
+ fastapi-spawn add openai # OpenAI async client + env vars
236
+ fastapi-spawn add alembic # Alembic async migrations
237
+ fastapi-spawn add s3 # AWS S3 / MinIO storage utils
238
+ fastapi-spawn add celery # Celery worker + tasks/
239
+ fastapi-spawn add helm # Helm chart in infra/helm/
240
+ fastapi-spawn add terraform # Terraform scaffold in infra/terraform/
241
+ ```
242
+
243
+ ---
244
+
245
+ ## ORM ↔ Database Compatibility
246
+
247
+ | ORM | Compatible Databases |
248
+ |---|---|
249
+ | `sqlalchemy` | postgresql, mysql, sqlite |
250
+ | `tortoise` | postgresql, mysql, sqlite |
251
+ | `beanie` | mongodb |
252
+ | `none` | any |
253
+
254
+ ---
255
+
256
+ ## Middleware Stack (always included)
257
+
258
+ | Middleware | What it does |
259
+ |---|---|
260
+ | `RequestLoggingMiddleware` | Logs `→ METHOD /path` + `✓ status duration` with request ID |
261
+ | `RateLimitMiddleware` | 200 req/min default via slowapi, returns 429 + `Retry-After` |
262
+ | `CORSMiddleware` | Configurable via `CORS_ORIGINS` env var |
263
+
264
+ Every response includes `X-Request-ID` and `X-Response-Time` headers.
265
+
266
+ ---
267
+
268
+ ## Contributing
269
+
270
+ ```bash
271
+ git clone https://github.com/Bishwajitgarai/fastapi-spawn
272
+ cd fastapi-spawn
273
+ uv sync --all-extras
274
+ uv run pytest
275
+ ```
276
+
277
+ ---
278
+
279
+ ## License
280
+
281
+ MIT © [Bishwajit Garai](https://github.com/Bishwajitgarai)
@@ -1,6 +1,7 @@
1
1
  """fastapi-spawn — Production-ready FastAPI project scaffolding CLI."""
2
2
 
3
- __version__ = "0.1.0"
3
+ __version__ = "0.2.0"
4
4
  __author__ = "Bishwajit Garai"
5
5
  __email__ = "bishwajitgarai@gmail.com"
6
6
  __license__ = "MIT"
7
+ __description__ = "Production-ready FastAPI project scaffolding — with every integration you need."