Speks
Interactive Functional Analysis Generator — turn pseudo-code and Markdown specifications into a live, testable documentation website.
Why Speks?
Business rules live in code, but stakeholders read documentation. Speks bridges the gap:
- Write business rules as Python pseudo-code with built-in mocking for external services
- Document them in Markdown with special tags that embed live code, contracts, and diagrams
- Generate an interactive website where anyone can read, understand, and test every rule
No more stale specs. No more "the doc says X but the code does Y". Your documentation is the executable specification.
Quick Start
pip install pyspeks
speks init my-project
cd my-project
speks serve
Open http://localhost:8000 to see your interactive documentation.
What You Get
Write business rules as Python pseudo-code:
from speks import service, stub
@service
class CoreBanking:
"""Core Banking API (blackbox)."""
@stub(mock=1500.0)
def check_balance(self, client_id: str) -> float:
... # real HTTP/SQL implementation here
def evaluate_credit(client_id: str, amount: float) -> bool:
balance = CoreBanking().check_balance(client_id)
return balance > amount
Then document them in Markdown with special tags:
## Credit Evaluation
@[contract](src/rules.py:evaluate_credit)
@[code](src/rules.py:evaluate_credit)
@[playground](src/rules.py:evaluate_credit)
@[sequence](src/rules.py:evaluate_credit)
@[dependencies](src/)
@[mermaid](diagrams/flow.mmd)
@[plantuml](diagrams/sequence.puml)
Speks generates a live website where stakeholders can read, understand, and test every business rule — with auto-generated dependency graphs and sequence diagrams.
Features
- Interactive Playground — Each documented function gets an auto-generated form to test it live in the browser
- Mocking Engine — External services are auto-mocked; users can override mock values and simulate errors
- Custom Markdown Tags —
@[code],@[playground],@[contract],@[dependencies],@[sequence],@[mermaid],@[plantuml] - Auto-generated Diagrams — Dependency graphs and sequence diagrams derived from your code via static analysis
- Test Case Management — Save, replay, and validate test scenarios directly from the documentation
- Standalone Binaries — Distribute as a single executable (Windows, macOS, Linux) — no Python required
Markdown Tags Reference
| Tag | Description |
|---|---|
@[code](src/file.py:func) |
Embed function source code with syntax highlighting |
@[playground](src/file.py:func) |
Interactive form to test the function live |
@[contract](src/file.py:func) |
Function signature as a readable table |
@[dependencies](src/) |
Auto-generated dependency graph (Mermaid) |
@[sequence](src/file.py:func) |
Auto-generated sequence diagram |
@[mermaid](diagrams/flow.mmd) |
Embed a Mermaid diagram from file |
@[plantuml](diagrams/file.puml) |
Embed a PlantUML diagram |
Project Layout
speks/ # The generator library & CLI
core/ # Markdown parser, code extractor, dependency & sequence analysis
engine/ # Mocking system (@service / @stub decorators, error overrides)
web/ # Site builder, dev server (FastAPI)
mkdocs_plugins/ # MkDocs plugins for each tag type
i18n/ # Internationalization (en, fr)
cli.py # CLI entry point (init, serve)
User Workspace
After speks init, a workspace is created:
my-project/
src/ # Python pseudo-code (business rules)
docs/ # Markdown documentation
diagrams/ # PlantUML diagrams
testcases/ # Saved test scenarios (JSON)
speks.toml # Project configuration
mkdocs.yml # MkDocs configuration
Examples
See the examples/ directory for complete projects across different industries:
| Example | Domain | Demonstrates |
|---|---|---|
| Credit Evaluation | Banking | Core features, mocking, error handling, sequence diagrams |
| Order Processing | E-commerce | Multi-step workflows, pricing rules, inventory checks |
| Patient Eligibility | Healthcare | Compliance rules, multi-service orchestration |
| Shipping Calculator | Logistics | Decision trees, zone-based calculations |
Contributing
See CONTRIBUTING.md for development setup and guidelines.
License
Apache License 2.0 — see LICENSE for details.
Release files for pyspeks 0.1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pyspeks-0.1.3.tar.gz | 128.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pyspeks-0.1.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 242.5 kB
Release files / pyspeks-0.1.3.tar.gz
| Download URL | pyspeks-0.1.3.tar.gz |
|---|---|
| Size | 128.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ec773673cb15989092f7d6add2158f420f5a063053b7aecead3b9416b11ca0dd
|
|
BLAKE2b-256 checksum How to use checksums |
d7466e5f20149252ebf7f92a8320451a142e4c2ebc0cc6a6e2f69b648cf3f3c4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.3
|
Release files / pyspeks-0.1.3-py3-none-any.whl
| Download URL | pyspeks-0.1.3-py3-none-any.whl |
|---|---|
| Size | 114.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8e89d6b5dcefb9414612f736c26550060483584098ec4b8baaeb18872c87a39f
|
|
BLAKE2b-256 checksum How to use checksums |
506d0b40653d1ff14403fa1e26ad24b76fe81b83b71cb0ec5a5f4b07f93a8528
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.3
|