CLI Init Flow
CLI Init Deep Dive
Section titled “CLI Init Deep Dive”This guide explains exactly what happens when you run:
npx seamless-cli my-appThat project-name shorthand runs the same init path as npx seamless-cli init my-app. Running the
CLI with no command prints help.
This guide focuses on local project generation, auth wiring, Docker setup, and admin dashboard inclusion.
Mental Model
Section titled “Mental Model”init → prompts → generators → config → ready-to-run appStep 0: Directory Setup
Section titled “Step 0: Directory Setup”If you pass a project name:
npx seamless-cli my-appThe CLI will:
- Create a new folder
- Ensure it does not already exist
- Use it as the project root
If you run npx seamless-cli init with no project name, it uses the current directory. If that
directory is not empty, the current CLI prints that an existing project was detected and exits; the
existing-project integration flow is still future work.
Step 1: Interactive Prompts
Section titled “Step 1: Interactive Prompts”The CLI asks a series of questions to shape your stack.
Web Framework
Section titled “Web Framework”- React (Vite)
- Next.js is listed as coming soon, not currently generated
This determines your frontend scaffold.
Backend Framework
Section titled “Backend Framework”- Express
- Fastify, FastAPI, and Axum are listed as coming soon, not currently generated
This determines your API server.
Auth Mode
Section titled “Auth Mode”- Docker (recommended)
- Local dev server (advanced)
Docker mode:
- Runs full auth stack in containers
- Closest to production
Local mode:
- Generates the auth server source into
./auth - Still relies on Docker for the full local stack
- Prompts about Docker, but the current source enables Docker either way because it is required for the full generated stack
Admin Dashboard
Section titled “Admin Dashboard”You choose whether to include the Admin UI.
If enabled:
Admin Source
Section titled “Admin Source”- Docker image (recommended)
- Source (for customization)
Step 2: Generators Run
Section titled “Step 2: Generators Run”Based on your answers, the CLI executes generators.
Frontend
Section titled “Frontend”await generateReactStarter({ root })Creates:
- React app (Vite)
- Auth-aware starter frontend
Backend
Section titled “Backend”await generateExpressStarter({ root })Creates:
- Express API
- Auth-ready endpoints
Auth Server
Section titled “Auth Server”If using local mode:
await generateAuthServer({ root }, 'local')This generates the Seamless Auth server locally.
Docker Setup
Section titled “Docker Setup”await generateDockerCompose(root, { authMode, adminMode, includeAdmin,})Creates:
- Postgres container
- Auth server container
- Admin UI container (optional)
Step 3: Environment Configuration
Section titled “Step 3: Environment Configuration”The CLI wires environment variables automatically.
configureApiEnv(root, sharedConfig)configureWebEnv(root)configureAuthLocalEnv(root)This ensures:
- Services can communicate
- URLs and ports are aligned
Step 4: Project Config File
Section titled “Step 4: Project Config File”generateSeamlessConfig(root, { ... })Creates:
seamless.config.jsonThis file stores:
- Framework choices
- Auth mode
- Admin configuration
Step 5: Final Output
Section titled “Step 5: Final Output”The CLI prints next steps. In the Docker-backed path, those are:
docker compose upseamless bootstrap-admin- complete registration in the browser
It also prints the expected local service URLs for auth, API, web, and admin.
Generated Project Structure
Section titled “Generated Project Structure”my-app/ web/ api/ auth/ # local auth mode only admin/ # admin source mode only docker-compose.yml seamless.config.json README.mdWhat Gets Wired Automatically
Section titled “What Gets Wired Automatically”- Auth endpoints
- Session handling
- Secure cookies
- Frontend SDK integration
- Backend auth validation
Key Design Decisions
Section titled “Key Design Decisions”Opinionated Defaults
Section titled “Opinionated Defaults”The CLI chooses:
- Secure session handling
- Passwordless flows
- Best-practice structure
Full-Stack by Default
Section titled “Full-Stack by Default”You always get:
web/frontend starterapi/backend starter- local Docker Compose wiring
seamless.config.json- auth server runtime wiring
You may also get:
auth/source when local auth mode is selectedadmin/source when admin source mode is selected
Docker-First
Section titled “Docker-First”Even in local mode, Docker is used to ensure consistency.
Common Pitfalls
Section titled “Common Pitfalls”- Running in a non-empty directory
- Skipping Docker setup
- Misunderstanding auth mode differences
Prompt for AI Help
Section titled “Prompt for AI Help”Copy this into ChatGPT:
“Explain what happens internally when I run seamless-cli init and how the project is generated.”
Next Step
Section titled “Next Step”→ Learn how Docker and local services work together