PRD text to production Flask app in one Python file. The Archiet core algorithm, standalone.
Project description
microcodegen.py
PRD text → production Flask 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 > app.zip
unzip app.zip -d myapp && cd myapp && pip install -r requirements.txt && flask run
→ A working, bootable Flask app at http://localhost:5000.
What it generates from your PRD
Given a plain-English Product Requirements Document, microcodegen.py outputs a complete Flask application:
- SQLAlchemy models — one per entity extracted from your PRD
- JWT auth —
/auth/register,/auth/login,/auth/mewith httpOnly cookies - CRUD API routes — full REST for every entity
- Per-tenant data isolation — every query scoped to the authenticated user
- Alembic migrations —
flask db upgradeand you're running - pytest test suite — auth + entity CRUD tests, all passing
- docker-compose.yml — Postgres + app, one command local dev
Zero LLM calls. Zero API keys. Pure Python stdlib.
Run it
# 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
flask db upgrade
flask run
# → http://localhost:5000/auth/register
Or pipe the ZIP:
python microcodegen.py examples/task_manager.md > app.zip
Write your own PRD
# 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-app
The four stages
PRD 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.
│ Key decisions: Flask, PostgreSQL, JWT, per-user isolation.
│
▼ Stage 3: render_genome(genome) → {path: content}
│ string.Template substitution over embedded Flask templates.
│ Outputs SQLAlchemy models, Blueprints, Alembic env, pytest suite.
│
▼ Stage 4: pack(files) → ZIP bytes
stdlib zipfile.ZipFile. Download it, push it to GitHub, deploy it.
Why one file?
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
What this file does NOT include
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, FastAPI, Go (chi), Java Spring Boot, .NET, Laravel, Rails | archiet.com |
| React/Next.js frontend (shadcn/ui) | archiet.com |
| Expo mobile app (iOS + Android) | 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.
Architecture deep dive
Stage 1 — parse_prd(text) → manifest
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.
Stage 2 — manifest_to_genome(manifest) → genome
Converts the manifest into a formal architectural genome — the stack-neutral intermediate representation that drives all downstream rendering.
The genome encodes:
language—flask-nextjs(this file's scope; the full system supports 9 stacks)modules[]— one module per entity, with entities, user_stories, acceptance_criteriacapabilities[]— inferred from the PRD (auth, payments if Stripe mentioned, etc.)delivery_archetype— product class, tenant model, auth model
This is the IR that makes multi-stack generation possible. The same genome dict drives Flask, NestJS, Django, FastAPI, Go, Java, .NET, Laravel, and Rails renderers — the stacks are just different render_genome() implementations.
Stage 3 — render_genome(genome) → {path: content}
string.Template substitution across templates embedded directly in the file. Each template is a complete source file with $variable placeholders.
Templates emitted:
config.py— Flask app factory, SQLAlchemy, JWT, migrations configmodels/user.py— User model with password hashmodels/<entity>.py— SQLAlchemy model per entityblueprints/auth_bp.py— JWT register/login/logout/meblueprints/<entity>_bp.py— CRUD Blueprint per entityalembic/env.py— migration environmenttests/test_api.py— pytest suite with auth fixturesdocker-compose.yml— Postgres + app servicerequirements.txt
The full Archiet renderer uses Jinja2 with a 1,200+ template library. The string.Template approach here is deliberately simple to keep the algorithm readable.
Stage 4 — pack(files) → bytes
zipfile.ZipFile(DEFLATED). Maps {path: content} → ZIP bytes. The customer downloads this ZIP and runs it.
Examples
See examples/ for sample PRDs:
task_manager.md— project/task management SaaSsaas_billing.md— subscription billing with Stripeecommerce.md— product catalog + orders
Contributing
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.
License
MIT. Use it, fork it, learn from it.
The production platform (9 stacks, compliance packs, quality gates, GitHub push) is commercial: archiet.com
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file microcodegen-0.1.0.tar.gz.
File metadata
- Download URL: microcodegen-0.1.0.tar.gz
- Upload date:
- Size: 18.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
00219ca7bb959d86c36b3629dc249b2058b648e93d2290c619f0c1bb57a167e2
|
|
| MD5 |
d5dd18a44a953237bc1baa76a960a42f
|
|
| BLAKE2b-256 |
61716799d70f310510b5fb5da4da1a7355cca216b581c44d61491b79e874c9cc
|
File details
Details for the file microcodegen-0.1.0-py3-none-any.whl.
File metadata
- Download URL: microcodegen-0.1.0-py3-none-any.whl
- Upload date:
- Size: 26.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0380943ace94afe4126b934895c18e86e9a05dde870093440c3c740f3d62067a
|
|
| MD5 |
a91853dc4914be494a39764de7f10da9
|
|
| BLAKE2b-256 |
ef38e5ea83ed830a2953ee7d453a78bb24e2127cc0979401978dc3043f505d50
|