Metadata-Version: 2.4
Name: archiet-microcodegen
Version: 0.2.3
Summary: Archiet's core algorithm in one file: PRD text -> FastAPI app ZIP, pure stdlib, zero dependencies.
Project-URL: Homepage, https://archiet.com
Project-URL: Source, https://github.com/aniekanasuquookono-web/archiet
Project-URL: Issues, https://github.com/aniekanasuquookono-web/archiet/issues
Project-URL: Spec File, https://github.com/aniekanasuquookono-web/archiet/blob/main/scripts/microcodegen.py
Author-email: Aniekan Okono <founder@archiet.com>
License: MIT License
        
        Copyright (c) 2026 Archiet (Aniekan Okono)
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE
Keywords: api-generator,archiet,codegen,fastapi,microcodegen,prd,scaffolding
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Software Development :: Build Tools
Classifier: Topic :: Software Development :: Code Generators
Requires-Python: >=3.10
Description-Content-Type: text/markdown

# archiet-microcodegen

> **PRD text → working FastAPI + PostgreSQL app → ZIP. One command. No LLM. No API key. Pure Python stdlib. 1,377 lines you can read in 20 minutes.**

Inspired by Karpathy's `micrograd`: *this file is the complete algorithm. Everything else is just efficiency on top.*

```bash
pip install archiet-microcodegen
archiet-microcodegen prd.md --out ./myapp/
cd myapp && docker compose up
# → http://localhost:8000/docs
```

## What you get

Write a PRD describing your entities and user stories. Get back a bootable app:

| File | What it does |
|---|---|
| `main.py` | FastAPI app with `/docs` OpenAPI explorer |
| `models/*.py` | SQLAlchemy 2.0 models, one per entity |
| `schemas/*.py` | Pydantic v2 `Create` / `Update` / `Response` schemas |
| `routers/*.py` | Full CRUD — list, create, get, update, delete |
| `auth.py` | JWT via httpOnly cookies — register / login / logout / me |
| `alembic/` | Migrations pre-configured, run `alembic upgrade head` |
| `tests/test_*.py` | pytest suite with DB override, auto-skip if Postgres unreachable |
| `docker-compose.yml` | Postgres 16 with healthcheck-gated startup |
| **`ARCHITECTURE.md`** | **ArchiMate 3.2 element map** — ApplicationComponent, DataObject, ApplicationService, ApplicationInterface |
| `openapi.yaml` | Machine-readable API contract, importable into Postman |

**Every entity has per-tenant data isolation built in.** Every query filters by the authenticated user's ID. No data leaks between users.

Zero LLM calls. Zero API keys. Zero runtime dependencies. Pure Python stdlib.

## The four stages

```
PRD text
  │
  ▼ parse_prd()        — regex extraction: entities, fields, user stories, integrations
manifest dict
  │
  ▼ manifest_to_genome() — maps to canonical IR with ArchiMate 3.2 element typing
genome dict              (same schema as archiet.com's full platform)
  │
  ▼ render_genome()    — string.Template FastAPI rendering
{path: content}
  │
  ▼ pack()             — stdlib zipfile
ZIP bytes
```

The genome is the key: your PRD becomes an **ArchiMate 3.2 architecture document** before any code is generated. That's what makes the output traceable and maintainable — not just scaffolded.

## As a library

```python
from archiet_microcodegen import microcodegen, parse_prd, manifest_to_genome, render_genome

# Full pipeline
zip_bytes = microcodegen(open("prd.md").read())

# Or stage by stage
manifest = parse_prd(prd_text)
genome   = manifest_to_genome(manifest)
files    = render_genome(genome)   # dict[str, str]
# inspect files["ARCHITECTURE.md"] to see the ArchiMate element map
```

## Example PRD

```markdown
# Task Manager

## Entities
- Task: title (string, required), description (text), status (string), due_date (date)
- Project: name (string, required), description (text)

## User Stories
As a user, I want to create tasks so I can track my work.
As a user, I want to assign tasks to projects so I can organise them.

## Integrations
- Stripe for billing
```

Run it: `archiet-microcodegen prd.md --out ./taskapp/` — you'll get 23 files including a fully wired FastAPI app with Task and Project CRUD, auth, migrations, tests, and an `ARCHITECTURE.md` with ArchiMate 3.2 notation.

## Why no LLMs

LLMs are great at understanding messy PRDs. They're unnecessary for the generation step — once you have a clean manifest, code emission is deterministic. This file handles the deterministic half. The full platform at [archiet.com](https://archiet.com?utm_source=pypi&utm_medium=package&utm_campaign=microcodegen-fastapi) handles the LLM-powered extraction, 14 stacks, frontend, mobile, and delivery gates.

If a bug doesn't reproduce with `microcodegen`, it's in an efficiency layer, not the algorithm.

## What's NOT here

- No LLM extraction (full platform handles messy natural-language PRDs)
- No frontend, no mobile, no Stripe wiring, no rate limiting, no audit logging
- No multi-stack (FastAPI only here — for Flask, Django, NestJS, Go, Java see [archiet.com](https://archiet.com?utm_source=pypi&utm_medium=package&utm_campaign=microcodegen-fastapi))

## License

MIT. See [LICENSE](https://github.com/aniekanasuquookono-web/archiet/blob/main/LICENSE).

## Links

- **SDD guide:** [github.com/Anioko/spec-driven-development](https://github.com/Anioko/spec-driven-development) — maturity levels, Spec Kit comparison, `demo.sh`
- **Compliance guide:** [github.com/Anioko/compliance-from-architecture](https://github.com/Anioko/compliance-from-architecture) — three layers (Vanta/Drata vs codegen), EU AI Act Annex IV
- **EU AI Act (deadline Aug 2026):** [Free risk classifier](https://archiet.com/tools/eu-ai-act-risk-classifier) · [Annex IV use case](https://archiet.com/use-cases/eu-ai-act-high-risk-ai-compliance)
- Source: [github.com/aniekanasuquookono-web/archiet](https://github.com/aniekanasuquookono-web/archiet)
- Issues: [github.com/aniekanasuquookono-web/archiet/issues](https://github.com/aniekanasuquookono-web/archiet/issues)
- Full platform: [archiet.com](https://archiet.com?utm_source=pypi&utm_medium=package&utm_campaign=microcodegen-fastapi)
