|
| 1 | +<div align="center"> |
| 2 | + |
1 | 3 | # create-polyglot |
2 | 4 |
|
3 | | -CLI to scaffold a polyglot microservice monorepo (Node.js, Python/FastAPI, Go, Java Spring Boot, Next.js frontend) with optional Turborepo or Nx presets, Docker assets, shared packages, an interactive wizard, post-init service/plugin additions, and a persisted `polyglot.json` config. |
| 5 | +[](https://github.com/kaifcoder/create-polyglot/actions) |
| 6 | +[](https://github.com/kaifcoder/create-polyglot/blob/main/LICENSE) |
| 7 | +[](https://github.com/kaifcoder/create-polyglot/releases) |
| 8 | +[](https://github.com/kaifcoder/create-polyglot/issues) |
| 9 | +[](https://github.com/kaifcoder/create-polyglot/pulls) |
| 10 | +[](https://github.com/kaifcoder/create-polyglot) |
| 11 | +[](https://codecov.io/gh/kaifcoder/create-polyglot) |
| 12 | +[](https://github.com/kaifcoder/create-polyglot/graphs/contributors) |
| 13 | +[](https://www.npmjs.com/package/create-polyglot) |
| 14 | +[](https://www.npmjs.com/package/create-polyglot) |
| 15 | + |
| 16 | +<strong>Scaffold a modern polyglot microservices monorepo in seconds.</strong><br/> |
| 17 | +Generate Node.js, Python (FastAPI), Go, Java (Spring Boot), and Next.js frontend services with optional Turborepo or Nx presets, Docker Compose, shared packages, plugin hooks, and a persisted configuration file. |
| 18 | + |
| 19 | +</div> |
| 20 | + |
| 21 | +--- |
| 22 | + |
| 23 | +## Table of Contents |
| 24 | +1. [Why create-polyglot?](#why-create-polyglot) |
| 25 | +2. [Features](#features) |
| 26 | +3. [Quick Start](#quick-start) |
| 27 | +4. [Installation](#installation) |
| 28 | +5. [Usage Examples](#usage-examples) |
| 29 | +6. [Commands](#commands) |
| 30 | +7. [Init Flags / Options](#init-options) |
| 31 | +8. [Generated Project Structure](#generated-structure) |
| 32 | +9. [Presets](#presets) |
| 33 | +10. [Development Workflow](#development-workflow) |
| 34 | +11. [Docker & Compose Support](#docker--compose) |
| 35 | +12. [polyglot.json Configuration](#polyglotjson) |
| 36 | +13. [Plugins](#plugins) |
| 37 | +14. [Basic Dev Runner](#basic-dev-runner) |
| 38 | +15. [Roadmap](#roadmap--ideas) |
| 39 | +16. [Contributing](#contributing) |
| 40 | +17. [License](#license) |
| 41 | + |
| 42 | +--- |
| 43 | + |
| 44 | +## Why create-polyglot? |
| 45 | +Building a production-style polyglot microservice environment normally requires repetitive boilerplate across languages, Docker files, presets, and configs. `create-polyglot` automates: |
| 46 | +- Consistent folder layout & service naming |
| 47 | +- Language starter templates (Node, FastAPI, Go, Spring Boot, Next.js) |
| 48 | +- Optional monorepo orchestration (Turborepo or Nx) OR a zero-frills basic runner |
| 49 | +- Dockerfile + `compose.yaml` generation with correct port mappings |
| 50 | +- Extensible plugin scaffolding for future lifecycle hooks |
| 51 | +- A centralized manifest (`polyglot.json`) driving subsequent commands (e.g. `add service`) |
| 52 | + |
| 53 | +Use it to prototype architectures, onboard teams faster, or spin up reproducible demos / PoCs. |
| 54 | + |
| 55 | +## Features |
| 56 | +- 🚀 Rapid polyglot monorepo scaffolding (Node.js, Python/FastAPI, Go, Java Spring Boot, Next.js) |
| 57 | +- 🧩 Optional presets: Turborepo, Nx, or Basic runner |
| 58 | +- 🐳 Automatic Dockerfile + Docker Compose generation |
| 59 | +- 🛠 Interactive wizard (or fully non-interactive via flags) |
| 60 | +- 🔁 Post-init extensibility: add services & plugins anytime |
| 61 | +- 📦 Shared package (`packages/shared`) for cross-service JS utilities |
| 62 | +- 🧪 Vitest test setup for the CLI itself |
| 63 | +- 🌈 Colorized dev logs & health probing for Node/frontend services |
| 64 | +- 🔌 Plugin skeleton generation (`create-polyglot add plugin <name>`) |
| 65 | +- 📄 Single source of truth: `polyglot.json` |
| 66 | +- ✅ Safe guards: port collision checks, reserved name checks, graceful fallbacks |
| 67 | +- 📝 Friendly chalk-based CLI output with clear status symbols |
| 68 | + |
| 69 | +## Quick Start |
| 70 | +Scaffold a workspace named `my-org` with multiple services: |
| 71 | + |
| 72 | +```bash |
| 73 | +npx create-polyglot init my-org -s node,python,go,java,frontend --git --yes |
| 74 | +``` |
| 75 | + |
| 76 | +Then run everything (Node + frontend locally): |
| 77 | +```bash |
| 78 | +create-polyglot dev |
| 79 | +``` |
| 80 | + |
| 81 | +Or via Docker Compose: |
| 82 | +```bash |
| 83 | +create-polyglot dev --docker |
| 84 | +``` |
| 85 | + |
| 86 | +Add a new service later: |
| 87 | +```bash |
| 88 | +create-polyglot add service payments --type node --port 4100 |
| 89 | +``` |
| 90 | + |
| 91 | +## Installation |
| 92 | +Global (recommended for repeated use): |
| 93 | +```bash |
| 94 | +npm install -g create-polyglot |
| 95 | +``` |
| 96 | + |
| 97 | +Local dev / contributing: |
| 98 | +```bash |
| 99 | +npm install |
| 100 | +npm link # or: pnpm link --global / yarn link / bun link |
| 101 | +``` |
| 102 | + |
| 103 | +## Usage Examples |
| 104 | +Interactive wizard (prompts for missing info): |
| 105 | +```bash |
| 106 | +create-polyglot init my-org |
| 107 | +``` |
| 108 | + |
| 109 | +Non-interactive with explicit services & git init: |
| 110 | +```bash |
| 111 | +create-polyglot init my-org -s node,python,go --git --yes |
| 112 | +``` |
| 113 | + |
| 114 | +Add plugin skeleton: |
| 115 | +```bash |
| 116 | +create-polyglot add plugin postgres |
| 117 | +``` |
| 118 | + |
| 119 | +Start dev with Docker: |
| 120 | +```bash |
| 121 | +create-polyglot dev --docker |
| 122 | +``` |
| 123 | + |
| 124 | +## Commands |
| 125 | +| Command | Description | |
| 126 | +|---------|-------------| |
| 127 | +| `create-polyglot init <name>` | Scaffold a new workspace (root invocation without `init` is deprecated). | |
| 128 | +| `create-polyglot add service <name>` | Add a service after init (`--type`, `--port`, `--yes`). | |
| 129 | +| `create-polyglot add plugin <name>` | Create plugin skeleton under `plugins/<name>`. | |
| 130 | +| `create-polyglot dev [--docker]` | Run Node & frontend services locally or all via compose. | |
| 131 | + |
| 132 | +## Init Options |
| 133 | +| Flag | Description | |
| 134 | +|------|-------------| |
| 135 | +| `-s, --services <list>` | Comma separated services: `node,python,go,java,frontend` | |
| 136 | +| `--preset <name>` | `turborepo`, `nx`, or `basic` (default auto -> asks) | |
| 137 | +| `--git` | Initialize git repo & initial commit | |
| 138 | +| `--no-install` | Skip dependency installation step | |
| 139 | +| `--package-manager <pm>` | One of `npm|pnpm|yarn|bun` (default: detect or npm) | |
| 140 | +| `--frontend-generator` | Use `create-next-app` (falls back to template on failure) | |
| 141 | +| `--force` | Overwrite existing target directory if it exists | |
| 142 | +| `--yes` | Accept defaults & suppress interactive prompts | |
| 143 | + |
| 144 | +If you omit flags, the wizard will prompt interactively (similar to `create-next-app`). |
| 145 | + |
| 146 | +## Generated Structure |
| 147 | +``` |
| 148 | +my-org/ |
| 149 | + services/ |
| 150 | + node/ # Express + dev script |
| 151 | + python/ # FastAPI + uvicorn |
| 152 | + go/ # Go net/http service |
| 153 | + java/ # Spring Boot (Maven) |
| 154 | + frontend/ # Next.js (template or create-next-app output) |
| 155 | + gateway/ |
| 156 | + infra/ |
| 157 | + packages/ |
| 158 | + shared/ |
| 159 | + plugins/ # created when adding plugins |
| 160 | + compose.yaml |
| 161 | + polyglot.json # persisted configuration |
| 162 | + package.json |
| 163 | + turbo.json / nx.json (if preset chosen) |
| 164 | + scripts/ |
| 165 | + dev-basic.cjs |
| 166 | +``` |
| 167 | + |
| 168 | +### Presets |
| 169 | +- **Turborepo**: Generates `turbo.json`, sets root `dev` & `build` scripts for pipeline caching. |
| 170 | +- **Nx**: Generates `nx.json` and adjusts scripts accordingly. |
| 171 | +- **Basic**: Minimal setup + `scripts/dev-basic.cjs` for simple concurrency. |
| 172 | + |
| 173 | +## Development Workflow |
| 174 | +1. Scaffold with `init`. |
| 175 | +2. (Optional) Add more services or plugins. |
| 176 | +3. Run `create-polyglot dev` (local) or `create-polyglot dev --docker`. |
| 177 | +4. Edit services under `services/<name>`. |
| 178 | +5. Extend infra / databases inside `compose.yaml`. |
| 179 | + |
| 180 | +### Basic Dev Runner |
| 181 | +When no preset is chosen, `npm run dev` uses `scripts/dev-basic.cjs`: |
| 182 | +1. Detects package manager (pnpm > yarn > bun > npm fallback) |
| 183 | +2. Scans `services/` for Node services |
| 184 | +3. Runs those with a `dev` script |
| 185 | +4. Prefixes log lines with service name |
| 186 | + |
| 187 | +Non-Node services start manually or via compose: |
| 188 | +```bash |
| 189 | +cd services/python && uvicorn app.main:app --reload |
| 190 | +``` |
| 191 | + |
| 192 | +## polyglot dev Command |
| 193 | +`create-polyglot dev` reads `polyglot.json`, launches Node & frontend services that expose a `dev` script, assigns each a colorized log prefix, and probes `http://localhost:<port>/health` until ready (15s timeout). Pass `--docker` to instead delegate to `docker compose up --build` for all services. |
| 194 | + |
| 195 | +If a service lacks a `dev` script it is skipped with no error. Non-Node services (python/go/java) are not auto-started yet unless you choose `--docker`. |
| 196 | + |
| 197 | +## Docker & Compose |
| 198 | +For each selected service a Dockerfile is generated. A `compose.yaml` includes: |
| 199 | +- Service definitions with build contexts |
| 200 | +- Port mappings (adjust manually if conflicts) |
| 201 | +- Shared network `app-net` |
| 202 | + |
| 203 | +You can extend compose with volumes, env vars, or database services after generation. |
| 204 | + |
| 205 | +## Frontend Generation |
| 206 | +If `--frontend-generator create-next-app` is supplied, the tool shells out to `npx create-next-app` (respecting the chosen package manager for installs). If it fails, a fallback static template is used. |
| 207 | + |
| 208 | +## polyglot.json |
| 209 | +Example: |
| 210 | +```jsonc |
| 211 | +{ |
| 212 | + "name": "my-org", |
| 213 | + "preset": "none", |
| 214 | + "packageManager": "npm", |
| 215 | + "services": [ |
| 216 | + { "name": "node", "type": "node", "port": 3001, "path": "services/node" } |
| 217 | + ] |
| 218 | +} |
| 219 | +``` |
| 220 | +Used by `add service` to assert uniqueness and regenerate `compose.yaml`. |
| 221 | + |
| 222 | +## Plugins |
| 223 | +`create-polyglot add plugin <name>` scaffolds `plugins/<name>/index.js` with a hook skeleton (`afterInit`). Future releases will execute hooks automatically during lifecycle events. |
| 224 | + |
| 225 | +## Shared Package |
| 226 | +`packages/shared` shows cross-service Node utilities. Extend or add per-language shared modules. |
| 227 | + |
| 228 | +## Force Overwrite |
| 229 | +If the target directory already exists, the CLI aborts unless `--force` is passed. Use with caution. |
| 230 | + |
| 231 | +## Git Initialization |
| 232 | +Pass `--git` to automatically run `git init`, create an initial commit, and (if desired) you can add remotes afterwards. |
| 233 | + |
| 234 | +## Lint & Format |
| 235 | +Generates ESLint + Prettier base configs at the root. Extend rules per service if needed. |
| 236 | + |
| 237 | +## Roadmap / Ideas |
| 238 | +- Plugin hook execution pipeline |
| 239 | +- Healthchecks and depends_on in `compose.yaml` |
| 240 | +- Additional generators (Remix, Astro, SvelteKit) |
| 241 | +- Automatic test harness & CI workflow template |
| 242 | +- Language-specific shared libs (Python package, Go module) |
| 243 | +- Hot reload integration aggregator |
| 244 | +- Remove service / remove plugin commands |
| 245 | + |
| 246 | +## Contributing |
| 247 | +Contributions welcome! See `CONTRIBUTING.md` for guidelines. Please run tests before submitting a PR: |
| 248 | +```bash |
| 249 | +npm test |
| 250 | +``` |
| 251 | + |
| 252 | +## License |
| 253 | +MIT |
| 254 | + |
| 255 | +## Documentation Site (VitePress) |
| 256 | + |
| 257 | +Local docs development: |
| 258 | +```bash |
| 259 | +npm run docs:dev |
| 260 | +``` |
| 261 | +Build static site: |
| 262 | +```bash |
| 263 | +npm run docs:build |
| 264 | +``` |
| 265 | +Preview production build: |
| 266 | +```bash |
| 267 | +npm run docs:preview |
| 268 | +``` |
| 269 | +Docs source lives in `docs/` with sidebar-driven structure defined in `docs/.vitepress/config.mjs`. |
| 270 | + |
| 271 | +### Deployment |
| 272 | +Docs are auto-deployed to GitHub Pages on pushes to `main` that touch `docs/` via `.github/workflows/docs.yml`. The base path is set using `VITEPRESS_BASE=/create-polyglot/`. |
4 | 273 |
|
5 | 274 | ## Installation (local dev) |
6 | 275 |
|
|
0 commit comments