-
Notifications
You must be signed in to change notification settings - Fork 1
Modules
A module is the fundamental building block of Foundation CLI. Every technology option — Next.js, PostgreSQL, JWT auth, Docker — is implemented as a module.
A module is a self-contained unit that declares everything needed to add a technology to a project:
interface ModuleManifest {
id: string; // kebab-case, unique — e.g. "auth-jwt"
name: string; // display name — e.g. "JWT"
version: string; // semver
category: PluginCategory; // see categories below
description: string;
dependencies: PackageDependency[]; // npm / pip packages to install
files: FileEntry[]; // files to write (EJS templates)
configPatches: ConfigPatch[]; // merges into package.json, tsconfig, .env, etc.
compatibility: {
conflicts: string[]; // module IDs that cannot coexist
};
}
Modules may also export lifecycle hooks — functions that run at specific stages of the pipeline. See Architecture for details.
Generates the client-side application scaffold, build configuration, and entry point files.
| Module | ID | Key files generated |
|---|---|---|
| Next.js | frontend-nextjs | App Router layout, page, globals.css, next.config.mjs |
| React + Vite | frontend-react-vite | index.html, main.tsx, App.tsx, vite.config.ts |
| Vue 3 | frontend-vue | App.vue, main.ts, vite.config.ts |
| Svelte | frontend-svelte | App.svelte, main.ts, svelte.config.js, vite.config.ts |
If you are contributing to Foundation CLI, follow these steps to add a new module:
- Create
packages/modules/src/<category>/<name>.ts— use an existing module as a template - Export a
PluginDefinitionwith a uniqueid,category, and all required manifest fields - Add the export to
packages/modules/src/index.ts - Add the import and entry to
BUILTIN_MODULESinpackages/modules/src/registry-loader.ts - Add the selection → module ID mapping to
SELECTION_TO_MODULE_ID - Add a prompt choice to the appropriate array in
packages/cli/src/prompt/graph-definition.ts
A module is the fundamental building block of Foundation CLI. Every technology option — Next.js, PostgreSQL, JWT auth, Docker — is implemented as a module.
A module is a self-contained unit that declares everything needed to add a technology to a project:
interface ModuleManifest {
id: string; // kebab-case, unique — e.g. "auth-jwt"
name: string; // display name — e.g. "JWT"
version: string; // semver
category: PluginCategory; // see categories below
description: string;
dependencies: PackageDependency[]; // npm / pip packages to install
files: FileEntry[]; // files to write (EJS templates)
configPatches: ConfigPatch[]; // merges into package.json, tsconfig, .env, etc.
compatibility: {
conflicts: string[]; // module IDs that cannot coexist
};
}Modules may also export lifecycle hooks — functions that run at specific stages of the pipeline. See [Architecture](Architecture) for details.
Generates the client-side application scaffold, build configuration, and entry point files.
| Module | ID | Key files generated |
|---|---|---|
| Next.js | frontend-nextjs |
App Router layout, page, globals.css, next.config.mjs
|
| React + Vite | frontend-react-vite |
index.html, main.tsx, App.tsx, vite.config.ts
|
| Vue 3 | frontend-vue |
App.vue, main.ts, vite.config.ts
|
| Svelte | frontend-svelte |
App.svelte, main.ts, svelte.config.js, vite.config.ts
|
Generates the server application, routing, middleware, and health endpoint.
| Module | ID | Key files generated |
|---|---|---|
| Express | backend-express |
server.ts with CORS, Helmet, health endpoint |
| NestJS | backend-nestjs |
AppModule, AppController, AppService, main.ts
|
| FastAPI | backend-fastapi |
app/main.py, requirements.txt, CORS middleware |
| Django | backend-django |
settings.py, urls.py, DRF views, requirements.txt
|
Generates the database client, connection pooling, and initial migration.
| Module | ID | Key files generated |
|---|---|---|
| PostgreSQL | database-postgresql |
src/db/client.ts (node-postgres pool), 001_init.sql
|
| MySQL | database-mysql |
src/db/client.ts (mysql2 pool), 001_init.sql
|
| MongoDB | database-mongodb |
src/db/client.ts (native driver), 001_init.js
|
| SQLite | database-sqlite |
src/db/client.ts (better-sqlite3, WAL mode), 001_init.sql
|
| Supabase | database-supabase |
src/db/client.ts (anon + admin clients), init migration |
Generates authentication middleware, route handlers, and token/session management.
| Module | ID | Key files generated |
|---|---|---|
| JWT | auth-jwt |
auth.service.ts, auth.middleware.ts, auth.router.ts
|
| OAuth (Google + GitHub) | auth-oauth |
oauth.config.ts, oauth.router.ts (Passport.js) |
| Session-based | auth-session |
session.config.ts, session.middleware.ts, session.router.ts
|
| Clerk | auth-clerk |
clerk.middleware.ts, clerk.router.ts, AuthProvider.tsx
|
| Auth0 | auth-auth0 |
auth0.config.ts, auth0.middleware.ts, AuthProvider.tsx
|
Generates the CSS/component framework configuration and provider wrappers.
| Module | ID | Key files generated |
|---|---|---|
| Tailwind CSS | ui-tailwind |
tailwind.config.js, postcss.config.js, globals.css
|
| ShadCN/UI | ui-shadcn |
tailwind.config.ts with CSS variables, components.json, utils.ts
|
| Material UI | ui-mui |
theme.ts, MuiProvider.tsx with AppRouterCacheProvider
|
| Chakra UI | ui-chakra |
ChakraProvider.tsx with extended theme |
| Bootstrap | ui-bootstrap |
layout.tsx with Bootstrap import, custom.scss
|
Generates the client-side state store, provider wrapper, and usage examples.
| Module | ID | Key files generated |
|---|---|---|
| Zustand | state-zustand |
src/store/index.ts with devtools + persistence |
| Redux Toolkit | state-redux |
store/index.ts, counterSlice.ts, ReduxProvider.tsx
|
| TanStack Query | state-tanstack-query |
query-client.ts, QueryProvider.tsx, example hooks |
Generates infrastructure configuration files for the target platform. See Deployment for details.
| Module | ID | Key files generated |
|---|---|---|
| Docker | deployment-docker |
Multi-stage Dockerfile, docker-compose.yml with Postgres |
| Vercel | deployment-vercel |
vercel.json with CORS headers, .vercelignore
|
| Render | deployment-render |
render.yaml Blueprint with managed PostgreSQL |
| AWS | deployment-aws |
ECS task definition, GitHub Actions CI/CD workflow |
When you select multiple modules, the engine builds a dependency graph. Each module declares which other modules it conflicts with. The resolver checks every pair and aborts with a structured error if an unresolvable conflict is found (for example, selecting two auth modules simultaneously).
Many modules need to patch shared files — package.json, tsconfig.json, .env.example, docker-compose.yml. Rather than overwriting these files, Foundation CLI merges patches using type-aware strategies:
| File | Merge strategy |
|---|---|
package.json |
Deep merge — scripts, dependencies, devDependencies are merged key-by-key |
tsconfig.json |
Deep merge — compilerOptions and paths are merged |
.env.example |
Key deduplication — existing keys are preserved, new keys are appended |
docker-compose.yml |
Service-level merge — each service block is merged independently |
requirements.txt |
Package deduplication with semver intersection for version constraints |
Modules are written in topological dependency order. If module B depends on module A (for example, an auth module that requires a database module), module A is rendered and staged first.
Modules carry a status field that the CLI enforces:
| Status | Behavior |
|---|---|
stable |
Default. No restrictions. |
experimental |
Warning printed. Blocked in CI unless --allow-experimental is passed. |
deprecated |
Warning printed with successor information. Still usable. |
removed |
Hard error. Migration guide URL is printed. |
If you are contributing to Foundation CLI, follow these steps to add a new module:
- Create
packages/modules/src/<category>/<name>.ts— use an existing module as a template - Export a
PluginDefinitionwith a uniqueid,category, and all required manifest fields - Add the export to
packages/modules/src/index.ts - Add the import and entry to
BUILTIN_MODULESinpackages/modules/src/registry-loader.ts - Add the selection → module ID mapping to
SELECTION_TO_MODULE_ID - Add a prompt choice to the appropriate array in
packages/cli/src/prompt/graph-definition.ts