Skip to main content

PyArch

PyPI Python FastAPI Typer Jinja2 License: MIT Status

PyArch is a CLI for creating and extending Layered FastAPI projects. It sets up the application structure, database, tests and Alembic, then lets you add CRUD modules and integrations without wiring every file by hand.

Unlike a one-time project template, PyArch keeps a small manifest in the generated project. Later commands use it to understand the project and update the right files.

PyArch CLI demo

Why PyArch?

PyArch removes repetitive setup while keeping the generated code readable and ready to change.

  • Layered FastAPI project structure
  • PostgreSQL and SQLite support
  • Complete CRUD modules with models, schemas, repositories, services and routes
  • Automatic model and router registration
  • JWT auth integration with generated RSA keys
  • Protected CRUD routes
  • Alembic setup for relational databases
  • Tests and dependency setup through uv
  • Project-aware generation through pyarch.toml

Quick Start

PyArch requires Python 3.13 or newer and uv.

Install the latest release from PyPI:

pip install pyarch-cli

Create a project and move into it:

pyarch init my_project --database postgres
cd my_project

Copy .env.example to .env and set the database connection values. For PostgreSQL or SQLite, create the first migration:

uv run alembic revision --autogenerate -m "initial"
uv run alembic upgrade head

Run the API:

uv run uvicorn app.main:app --reload

Open http://127.0.0.1:8000/docs to use the generated Swagger UI.

You can now extend the project:

pyarch generate module users
pyarch add integration auth
pyarch generate module tasks --protected
pyarch info

What Gets Generated

A new project includes the application layers, database configuration, test setup and the files needed to run FastAPI:

my_project/
├── app/
│   ├── api/v1/
│   ├── core/
│   ├── db/
│   ├── dependencies/
│   ├── models/
│   ├── repositories/
│   ├── schemas/
│   ├── services/
│   └── main.py
├── tests/
├── alembic/          # PostgreSQL and SQLite only
├── .env.example
├── pyarch.toml
└── pyproject.toml

Each generated CRUD module adds:

  • a database model;
  • create, update and response schemas;
  • repository and service classes;
  • list, get, create, update and delete routes;
  • CRUD tests;
  • model and router registration in the existing application.

Commands

Command Description
pyarch init <name> Create a Layered FastAPI project
pyarch init <name> --database <engine> Select PostgreSQL or SQLite
pyarch generate module <name> Add a CRUD module to the current project
pyarch add integration auth Add JWT authentication and user management
pyarch generate module <name> --protected Generate CRUD routes that require authentication
pyarch info Show the current project configuration
pyarch --help Show CLI help

Generation commands must be run inside a project created by PyArch.

Databases and Current Limitations

Database CRUD modules Alembic Auth integration Protected modules
PostgreSQL Yes Yes Yes Yes
SQLite Yes Yes Yes Yes

Current limitations:

  • only Layered Architecture is supported;
  • generated applications use synchronous database access;
  • generated projects are starter scaffolds and still require application-specific configuration and code;
  • the manifest format may change before a stable release.

Project Manifest

Every generated project contains pyarch.toml. It records the selected architecture and database, generated modules, enabled integrations and known project paths.

Commands such as generate module, add integration and info read this file instead of trying to infer project state from the directory structure. PyArch updates the manifest after a successful generation step.

Development

Clone the repository and install the development environment:

git clone https://github.com/Allcode-1/PyArch.git
cd PyArch
uv sync

Run the CLI from the checkout:

uv run pyarch --help

Or install the current checkout as an editable CLI tool:

uv tool install --editable .

Architecture and Design

How PyArch is structured
Typer CLI
    ↓
Application services
    ↓
Generators
    ↓
Jinja2 templates
    ↓
Generated FastAPI project
    ↑
pyarch.toml

The CLI handles user input and delegates work to application services. Generators render Jinja2 templates and update files at explicit registration markers. The manifest provides the project context needed by later commands.

Why use a manifest?

Scanning the filesystem shows which files exist, but not which project choices produced them. The manifest stores those choices directly, so later commands do not have to guess the architecture, database or enabled features.

Why marker-based registration?

PyArch modifies files it generated itself. Explicit markers provide stable and readable insertion points for model and router imports without requiring a full AST rewriting pipeline.

Why Jinja2?

Templates stay close to the Python code users receive and can edit. Jinja2 is used with StrictUndefined, so missing template context fails during generation instead of producing incomplete files.

Roadmap

v0.2

  • safer generation and validation;
  • rollback on failed generation;
  • Redis integration foundation.

v0.3

  • Redis integration;
  • scheduler integration;
  • dry-run mode.

Later

  • more architectures;
  • plugin system;
  • asynchronous database access.

Status

PyArch is in early development. The main workflow is usable, but commands, templates, generated code and the manifest may still change before a stable release.

Metadata

Release files for PyArch-CLI 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for PyArch-CLI 0.1.1
File Size Uploaded
pyarch_cli-0.1.1.tar.gz 217.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for PyArch-CLI 0.1.1
File Interpreter ABI Platform
pyarch_cli-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 259.6 kB

Release files / pyarch_cli-0.1.1.tar.gz

Download URL pyarch_cli-0.1.1.tar.gz
Size 217.6 kB
Tags Source
SHA-256 checksum
How to use checksums
f5695f328dc28af1155158df686ac62dfcf235c6ae0b321ad6855569e9b8f9c5
BLAKE2b-256 checksum
How to use checksums
b4eb7cf4d88512265ff13cbaf158caba3ed013fdd86ac17d2e4270936ee6a0af
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.12

Release files / pyarch_cli-0.1.1-py3-none-any.whl

Download URL pyarch_cli-0.1.1-py3-none-any.whl
Size 42.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9a79916f58a9f59e4f93e763c00dd36f2b7b513000b128442fa461331cdaac41
BLAKE2b-256 checksum
How to use checksums
5a6743985c4d1b550721a7706332bd9acd77c228b79ce219d8d8360392ead9e6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.12

Release history Release notifications | RSS feed

0.2.1

2 release files

0.2.0

2 release files

0.1.2

2 release files

This release

0.1.1 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page