Implementation status note (2026-04-12): The current V1 stack is live and production-facing. The codebase includes in-process generation orchestration (template render → LLM → reconstruction → compile retry), multi-ecosystem support (DotNet-NextJs + Python-React via
IBuildStrategy), personalization, Stripe Checkout + webhook payment gate, Supabase SSR auth with user-linked generations, Cloudflare R2 upload, real-time build log streaming, and security hardening (rate limiting, CORS, service key auth, prompt sanitization, token accounting, schema size limits, mobile navigation, metadata, sitemap, robots, and route error boundaries). Tier 3 IaC templates remain pending.
1. System Architecture
- Frontend and API Gateway: Next.js application (App Router) handling user intake and checkout.
- State and Identity: Supabase PostgreSQL for relational data and Auth. Row Level Security restricts generation history access.
- Generation Engine: Anthropic Claude 3.5 Sonnet API in production, with a mock fallback when no Anthropic key is configured.
- Storage Layer: Cloudflare R2 provides zero egress temporary storage for compiled archives.
2. DevOps & Environment Strategy The platform utilizes a Single Project + Branching model in Supabase, synchronized with GitHub Actions Environments (Test and Prod).
- Development (
.env.development): Local development using the Supabase CLI (supabase start). - Test (
.env.test): Scoped to the "Test" environment in GitHub. Connects to the Supabasedevelopbranch. - Prod (
.env.production): Scoped to the "Prod" environment in GitHub. Connects to the Supabasemainproject.
3. Containerization Strategy
StackAlchemist uses a multi-stage, multi-target Docker architecture. This allows a single Dockerfile to serve all environments by targeting specific build stages (web, engine, worker).
4. Optimal CI/CD Flow
- Stage 1: Continuous Integration (CI)
- Trigger: Pull Requests.
- Actions: Run tests and verify Supabase migrations using
supabase db test.
- Stage 2: Staging Deployment (Test)
- Trigger: Push to
developbranch. - Actions: Build and replace the
sa-webcontainer on the test host for the public test site.
- Trigger: Push to
- Stage 3: Production Deployment (Prod)
- Trigger: Merge to
mainbranch. - Automation:
- git-cliff: Automatically update
CHANGELOG.mdand create a GitHub Release for every push tomain. - AWS Deploy: Deploy verified images to the production environment (EC2) automatically.
- git-cliff: Automatically update
- Health Checks: Components utilize
wgetfor health probes (e.g.,sa-webandsa-enginefinal stages includewgetto support Docker Compose health checks).
- Trigger: Merge to
5. Core Workflows and Technical Pipelines
A. Dual Mode Intake Pipeline
- Simple Mode: User submits text prompt. Next.js server action calls LLM to generate a structured JSON schema. The frontend renders this JSON into an editable node based UI.
- Advanced Mode: User interacts directly with the node based UI to define entities, choose a target platform, and configure endpoints. The final validated schema plus
project_typeselection are serialized into the generation payload. - Compile Orchestration:
CompileServicenow dispatches to per-platform build strategies so.NET/Next.jsandFastAPI/Reactprojects can share the same retry/state machine pipeline while keeping ecosystem-specific validation commands and error parsing.
B. The "Swiss Cheese" Generation Method The system maintains a library of master templates (starting with the V1 .NET/Next.js stack).
- Template Retrieval: The planned generation engine retrieves the static boilerplate and Handlebars templates.
- Deterministic Injection: Handlebars injects project names and standard configurations.
- LLM Generation: The LLM receives the database schema and generates only the dynamic files (Dapper queries, C# controllers, Next.js pages).
- Reconstruction: The LLM generated files are injected into the specific placeholders within the master template directory.
C. The Compile Guarantee CI/CD
- The in-process compile worker runs
dotnet buildin the temporary reconstruction directory. - If exit code
0is returned, the process proceeds to compression. - If exit code
1is returned, the standard error output is captured and sent back to the LLM with the context of the broken file for an automated fix. Maximum retry limit is set to 3.
D. Tier 3 IaC Export Pipeline For Tier 3 transactions, the system utilizes Handlebars to inject the user's specific environment variables and project naming conventions into pre written AWS CDK scripts, Terraform providers, and Helm Charts. A markdown runbook is generated and included in the final root directory of the zip archive.
6. Supabase Data Schema
- Three tables implemented with checked-in Supabase migrations:
profiles,transactions,generations— matching the ERD. - Six migrations in
supabase/migrations/: create_profiles, create_transactions, create_generations, add_project_type, add_personalization, add_token_usage_and_atomic_build_log. - RLS enforced: users read/update own profiles; read own transactions; anyone inserts generations (free tier); service role manages updates. Realtime publication enabled on
generations. generationstable includes:schema_json,personalization_json,build_log,preview_files_json,project_type,download_url,status,retry_count,input_tokens,output_tokens,model_used,user_id.