How jatingarg619/saas-builder works
Project Type and Purpose
• This is an open-source, Python-based CLI tool (saas-builder) whose sole purpose is to scaffold production-ready full-stack Next.js/Supabase SaaS apps automatically using AI models.
• Key capabilities: interactive CLI commands, AI-powered code generation, template management, build orchestration, and external API integration (OpenAI, Anthropic, Gemini, Supabase).
File Structure
• Top-level:
• .env.sample, .gitignore, LICENSE, README.md
• pyproject.toml, requirements.txt
• The gocodeo_cli/ package contains:
– cli.py (entry point)
– commands/ (Command pattern modules: init, build)
– agents/ (orchestrators: base.py, build_agent.py)
– services/ (abstractions over LLM, project state)
– tools/ (shell wrappers: npm, SQL migrations, env management, build tools)
– templates/ (prompt templates & ZIP’ed app-template stacks)
– utils/config.py (configuration loader)
Extract Additional Insights from README
• The architecture is pipeline-driven:
CLI → select template & tech stack → configure Supabase → call AI model → scaffold code → run build steps (npm install, db migrations) → start dev server.
• Dependencies: Next.js, Supabase, TypeScript, real-time features.
Main Components & Interactions
a. Components
1. CLI Entry Point (saas-builder, cli.py)
2. Command Modules (commands/init.py, commands/build.py)
3. Agents (agents/base.py, agents/build_agent.py)
4. Services
– LLMService (services/llm_service.py): wraps OpenAI/Anthropic/Gemini calls
– ProjectState (services/project_state.py): tracks user inputs, template choices, generated files
5. Tools
– EnvTools (load/write .env)
– NpmTools (npm install, npm run dev)
– SqlTools (run migrations via Supabase CLI or psql)
– BuildTools (file scaffolding, zip extraction)
6. Templates (templates/prompts/*.txt, templates/stacks/*.zip)
7. External Services
– AI Providers (OpenAI, Anthropic, Google)
– Supabase (Auth, PostgreSQL, real-time)
8. File System (writes the generated Next.js project)
b. Relationships / Data Flows
• User invokes saas-builder init → CLI loads configuration → Command module delegates to BuildAgent
• BuildAgent sequences: prompt user → fetch/generate code via LLMService → write code using BuildTools → install deps via NpmTools → configure database via SqlTools → spin up dev server
• ProjectState maintains context and intermediate results passed between modules
• EnvTools reads/writes API keys for Supabase & AI models
• Templates feed static files & prompt blueprints into agents
Architectural Patterns & Design Principles
• Command Pattern: Each CLI command is a pluggable module under commands/.
• Orchestrator/Agent: Business logic centralized in build_agent.py, decoupled from CLI wiring.
• Service Abstraction: External API calls (LLM, Supabase) behind service interfaces.
• Tool Wrappers: Shell commands abstracted in tools/ to allow mocking, testing.
• Template-Driven Generation: Prompts and project starters in templates/.
Essential Details to Capture
• The entry flow (cli.py → command → agent)
• The AI invocation path (through llm_service.py to external LLMs)
• The Scaffolding & Build path (templates → build_tools → npm_tools → proj filesystem)
• The Database Setup path (sql_tools → Supabase)
• Config management (utils/config.py, .env handling)