PRD text → production FastAPI app → ZIP bytes. One Python file, zero dependencies.
Inspired by Andrej Karpathy's micrograd — this is the core Archiet algorithm in its simplest form.
python microcodegen.py your-prd.md --out ./myapp
cd myapp && pip install -r requirements.txt
alembic upgrade head
uvicorn main:app --reload→ A working, bootable FastAPI app at http://localhost:8000/docs.
Given a plain-English Product Requirements Document, microcodegen.py outputs a complete FastAPI application:
- FastAPI with
/docsinteractive OpenAPI explorer — free, auto-generated by FastAPI - SQLAlchemy 2.0 models — one per entity extracted from your PRD (
DeclarativeBase) - Pydantic v2 schemas —
Base/Create/Update/Responseclasses per entity - JWT auth —
/api/auth/register,/api/auth/login,/api/auth/mewith httpOnly cookies; never localStorage - Full CRUD APIRouters — list, create, get, update, delete per entity; all
Depends(get_current_user) - Per-tenant data isolation — every row has a
user_idFK; every query filters by it; no cross-user leaks - Alembic migrations —
alembic.ini+alembic/env.pypre-configured; runalembic upgrade head - pytest test suite —
TestClientwithdependency_overrides, auto-skips if Postgres unreachable - docker-compose.yml — Postgres 16 with healthcheck-gated app startup
- ARCHITECTURE.md — ArchiMate 3.2 element map typed from the genome IR
- openapi.yaml — machine-readable API contract; import into Postman or Swagger UI
Zero LLM calls. Zero API keys. Pure Python stdlib.
# Python 3.10+
git clone https://github.com/Anioko/microcodegen
cd microcodegen
# Generate from an example PRD
python microcodegen.py examples/task_manager.md --out ./my-task-app
cd my-task-app
pip install -r requirements.txt
alembic upgrade head
uvicorn main:app --reload
# → http://localhost:8000/docsOr pipe the ZIP:
python microcodegen.py examples/task_manager.md > app.zipOr install from PyPI:
pip install archiet-microcodegen
archiet-microcodegen examples/task_manager.md --out ./my-task-app# Project Tracker
## Entities
- Project: name (string, required), description (text), status (string)
- Task: title (string, required), completed (boolean), due_date (datetime)
- Comment: body (text, required)
## User Stories
- As a developer, I want to manage projects so that I can track my work.
- As a developer, I want to add tasks to projects so that I can break work into steps.Save as prd.md, run:
python microcodegen.py prd.md --out ./my-appPRD text (your requirements document)
│
▼ Stage 1: parse_prd(text) → manifest
│ Pure regex extraction — entities, fields, user stories, integrations.
│ No LLM. Misses subtle PRDs; that's acceptable for a spec reference.
│
▼ Stage 2: manifest_to_genome(manifest) → genome
│ Converts the manifest into a stack-neutral architectural genome dict.
│ Adds ArchiMate 3.2 element typing (ApplicationComponent, DataObject,
│ BusinessProcess, ApplicationService) for each extracted element.
│
▼ Stage 3: render_genome(genome) → {path: content}
│ string.Template substitution over embedded FastAPI templates.
│ Outputs SQLAlchemy 2.0 models, Pydantic v2 schemas, APIRouters,
│ Alembic env, pytest suite, ARCHITECTURE.md, openapi.yaml.
│
▼ Stage 4: pack(files) → ZIP bytes
stdlib zipfile.ZipFile. Download it, push it to GitHub, deploy it.
The same philosophy as micrograd and minGPT:
If you can't express the core algorithm in a single file, you're hiding behind layers.
microcodegen.py serves three purposes:
- Onboarding — a new engineer understands what Archiet is in 10 minutes
- Regression check — a bug that doesn't repro here is in the efficiency layers, not the algorithm
- Spec — any algorithmic change (new genome key, new manifest field) updates this file first
This is the minimum viable PRD→code pipeline. Production use cases need more:
| Feature | Where it lives |
|---|---|
| LLM-powered PRD extraction (handles natural language) | archiet.com |
| 9 backend stacks: NestJS, Django, Flask, Go (chi), Java Spring Boot, .NET, Laravel, Rails | archiet.com |
| React/Next.js frontend (shadcn/ui, auth pages, onboarding) | archiet.com |
| Expo mobile app (iOS + Android, push notifications) | archiet.com |
| Compliance artifact packs — SOC 2, HIPAA, GDPR, PCI-DSS control matrices | archiet.com |
| 13-gate shippability audit (security scan, import coherence, boot test) | archiet.com |
| GitHub push + drift detection + architecture scoring | archiet.com |
| Quality score ≥ 80 gate (delivery blocked on broken output) | archiet.com |
Free plan at archiet.com — 1 full app per month, no credit card.
Pure regex extraction across four pattern classes:
_ENTITY_PATTERN— finds entity section headers (## Entities,## Data Models)_ENTITY_NAME_PATTERN— finds entity names as list items or sub-headers_FIELD_PATTERN— finds- fieldname: type (modifiers)declarations_USER_STORY_PATTERN— findsAs a X, I want Y so that Z.sentences
The full Archiet pipeline replaces this with a chunked LLM extractor (overlap + dedup merge) that handles PRDs that don't follow a rigid format. The algorithm shape is identical — only the extraction quality changes.
Converts the manifest into a formal architectural genome — the stack-neutral intermediate representation that drives all downstream rendering.
The genome encodes:
language—fastapi(this file's scope; the full system supports 12+ stacks)modules[]— one module per entity, with entities, user_stories, acceptance_criteriaarchimate_elements[]— every extracted element typed to ArchiMate 3.2 (ApplicationComponent for the app itself, DataObject per entity, BusinessProcess for workflow user stories, ApplicationService per integration)integrations[]— inferred from vendor mentions (Stripe, Auth0, SendGrid, etc.)
string.Template substitution across templates embedded directly in the file. Each template is a complete source file with $variable placeholders.
Templates emitted for every generated app:
main.py— FastAPI entry point withinclude_routerwiring (nocreate_all— Alembic owns the schema)app/database.py— SQLAlchemy 2.0DeclarativeBase+get_dbdependencyapp/auth.py— JWT via PyJWT + passlib/bcrypt, httpOnly cookie,get_current_userdependencyapp/models/user.py— User modelalembic.ini+alembic/env.py— migration environment with model auto-discoveryARCHITECTURE.md— ArchiMate 3.2 element tableopenapi.yaml— full OpenAPI 3.1 spec
Per entity:
app/models/<entity>.py— SQLAlchemy 2.0 model withuser_idFKapp/schemas/<entity>.py— Pydantic v2Base/Create/Update/Responseapp/routers/<entity>.py— FastAPIAPIRouterwith full CRUD
zipfile.ZipFile(DEFLATED). Maps {path: content} → ZIP bytes. The customer downloads this ZIP and runs it.
See examples/ for sample PRDs:
task_manager.md— project/task management SaaSsaas_billing.md— subscription billing with Stripeecommerce.md— product catalog + orders
The algorithm is intentionally simple. Before adding features, ask:
"Is this part of how a PRD becomes shippable code? Or is it tuning, fallback, or quality?"
If the former, open a PR. If the latter, it belongs in the full Archiet pipeline.
MIT. Use it, fork it, learn from it.
The production platform (12+ stacks, compliance packs, quality gates, GitHub push) is commercial: archiet.com