A clean, modular Python application template using Clean Architecture (Onion Architecture), Streamlit UI, FastAPI REST API, Typer CLI, PostgreSQL / SQLModel, and Marimo Notebooks.
Ensure you have uv installed:
curl -LsSf https://astral.sh/uv/install.sh | sh
Create and activate the Python 3.12 virtual environment:
uv venv --python 3.12
source .venv/bin/activate
Install project dependencies:
uv sync
You can execute commands directly using the root executable ./run or python -m src.main:
# Display CLI help menu & options
./run
# (or python -m src.main)
# Launch Streamlit UI
./run ui
# Launch FastAPI REST API server (port 8001)
./run api
# Check environment & DB status
./run status
# Display project version
./run version
Exploratory notebooks are placed in the root notebooks/ directory to keep src/ clean:
# Edit interactive Marimo notebook in browser
marimo edit notebooks/explore_marimo.py
# Serve notebook as a standalone web app
marimo run notebooks/explore_marimo.py
Run static type checks and unit test suite:
# Run unit tests and Pyright type verification
pytest -m "not integration"
# Run full test suite including live service checks
pytest
Generate HTML documentation from docstrings using pdoc3:
pdoc3 --html -o data/_docs/ src --force
.
โโโ run # Root executable wrapper script for CLI commands
โโโ pyproject.toml # Project metadata & dependencies
โโโ README.md # Project instructions & overview
โโโ data/ # Application assets, configs, and sample inputs
โโโ notebooks/ # Root-level Marimo & Jupyter exploratory notebooks
โ โโโ README.md # Marimo usage guide
โ โโโ explore_marimo.py # Interactive Plotly analytics notebook
โ โโโ trial.ipynb # Jupyter notebook
โโโ src/ # Application source code (Clean Architecture)
โ โโโ main.py # Application CLI entrypoint
โ โโโ version.py # Application version string (__version__)
โ โโโ config.py # Configuration & pydantic-settings
โ โโโ application/ # Application use cases & helper utilities
โ โ โโโ utils.py # Helper utilities
โ โโโ domain/ # Core domain logic, models, & repository interfaces
โ โ โโโ models/ # SQLModel & data classes
โ โ โโโ schemas/ # Pydantic schemas (ResponseMessage, etc.)
โ โ โโโ repo_interfaces/ # Abstractions for persistence repositories
โ โโโ infra/ # Infrastructure & external adapters
โ โ โโโ logging.py # Loguru logging setup
โ โ โโโ postgres/ # Postgres DB operations & async/sync engines
โ โ โโโ persistence/ # Repository implementations (pgvector, qdrant)
โ โโโ presentation/ # Presentation layer (UI, REST API, CLI)
โ โโโ cli.py # Typer CLI application commands
โ โโโ bootstrap.py # Service dependency container
โ โโโ dependencies.py # FastAPI dependency checks & response examples
โ โโโ rest/ # FastAPI REST API routers & server runner
โ โโโ ui/ # Streamlit UI app, sidebar, and assets
โโโ tests/ # Pytest test suite & static type verification
โโโ conftest.py # Test fixtures
โโโ test_static.py # Pyright static type checker suite
โโโ test_ui.py # Streamlit UI helper tests
โโโ test_api.py # REST API test suite
โโโ test_db.py # Database integration tests