rjoydip/pytent

A monorepo project template with UV package manager

โ˜… 0Forks 0PythonGitHub โ†—Compare

README

Pytent

ci uv pre-commit conventional commits pyright ruff

A project template with UV package manager and CI integration.

๐Ÿš€ Features

  • UV - An extremely fast Python package and project manager, written in Rust.
  • Ruff - An extremely fast Python linter and code formatter, written in Rust.
  • Pytest - The pytest framework makes it easy to write small tests, yet scales to support complex functional testing
  • Pyright - Static Type Checker for Python
  • uv-secure - Scan your uv.lock file for dependencies with known vulnerabilities
  • pre-commit - A framework for managing and maintaining multi-language pre-commit hooks
  • commitizen - Create committing rules for projects ๐Ÿš€ auto bump versions โฌ†๏ธ and auto changelog generation ๐Ÿ“‚

๐Ÿ“‹ Prerequisites

  • Python >=3.12+ - Download the latest version
  • Docker Desktop - Docker Desktop is a one-click-install or Podman - The best free & open source container tools
  • UV - An extremely fast Python package and project manager, written in Rust.

๐Ÿ›  Installation

  • Clone the repository:

Install project dependencies:

uv sync --all-packages
  • Ruff
uv tool install ruff
  • Pyright
uv tool install pyright
  • Pip Audit
uv tool install uv-secure
  • Pre-commit
uv tool install pre-commit

uvx pre-commit install
  • Commitizen
uv tool install commitizen

Upgrade Tools

uv tool upgrade [...TOOL_NAMES]

Development

Local Development

  • Audit package vulnerability
uvx uv-secure .
  • Run Pre-commit against all the files
uvx pre-commit run --all-files
  • Run code formatting and linting:
# local
uvx ruff check . --fix
# ci
uvx ruff check --output-format=json . > artifacts/ruff-output.json
  • Run typechecking:
# local
uvx pyright .
# ci
uvx pyright . --outputjson > artifacts/pyright-output.json 2>&1
  • Run tests:
# local
uv run pytest
# ci
uv run pytest --cov=packages --cov-report=json:artifacts/coverage.json
  • Complexity Analysis
# local
uvx xenon .
# or
uvx xenon . --paths-in-front > artifacts/complexity-report.json

Local application development

# Development
uv run fastapi dev services/app --port 8000 --host 127.0.0.1
# Production
uv run fastapi run services/app/main.py --port 8000 --host 127.0.0.1

Docker/Podman Development

Build and run the api in Docker/Podman:

docker build -t app .
docker run <IMAGE_NAME>

# Or
podman build -t app .
podman run <IMAGE_NAME>

Docker/Podman compose

Build and run the api in Docker/Podman compose:

docker compose up --build

# Or
podman compose up --build

Commitizen Commands

Command Description Alias
cz commit Create a new commit cz c
cz bump Bump version and update changelog -
cz changelog Generate changelog cz ch
cz check Validate commit messages -
cz version Show version information -

๐ŸŒ API Endpoints

  • GET /: Returns a "API is working" message
  • GET /healthcheck: Returns a system check message

๐Ÿงช Testing

Tests are located in the tests/ directory. Run the test suite using:

uv run pytest

๐Ÿ” Project Structure

pytent/
โ”œโ”€ .devcontainer/
โ”‚  โ””โ”€ devcontainer.json
โ”œโ”€ .github/
โ”‚  โ”œโ”€ actions/
โ”‚  โ”‚  โ””โ”€ setup/
โ”‚  โ”‚     โ””โ”€ action.yml
โ”‚  โ”œโ”€ workflows/
โ”‚  โ”‚  โ”œโ”€ ci.yml
โ”‚  โ”‚  โ””โ”€ release.yml
โ”‚  โ””โ”€ dependabot.yml
โ”œโ”€ artifacts/
โ”‚  โ””โ”€ .gitkeep
โ”œโ”€ docs/
โ”‚  โ””โ”€ .gitkeep
โ”œโ”€ packages/
โ”‚  โ”œโ”€ error/
โ”‚  โ”‚  โ”œโ”€ __init__.py
โ”‚  โ”‚  โ”œโ”€ exceptions.py
โ”‚  โ”‚  โ””โ”€ handler.py
โ”‚  โ””โ”€ log/
โ”‚     โ”œโ”€ __init__.py
โ”‚     โ””โ”€ logger.py
โ”œโ”€ scripts/
โ”‚  โ””โ”€ .gitkeep
โ”œโ”€ services/
โ”‚  โ”œโ”€ api/
โ”‚  โ”‚  โ”œโ”€ __init__.py
โ”‚  โ”‚  โ”œโ”€ main.py
โ”‚  โ””โ”€ functions/
โ”‚     โ”œโ”€ src/
โ”‚     โ”‚  โ””โ”€ main.py
โ”‚     โ””โ”€ requirements.txt
โ”œโ”€ tests/
โ”‚  โ”œโ”€ e2e/
โ”‚  โ”‚  โ””โ”€ .gitkeep
โ”‚  โ”œโ”€ fixtures/
โ”‚  โ”‚  โ””โ”€ .gitkeep
โ”‚  โ””โ”€ integration/
โ”‚  โ”‚  โ””โ”€ .gitkeep
โ”‚  โ””โ”€ unit/
โ”‚     โ””โ”€ .test_hello.py
โ”œโ”€ tools/
โ”‚  โ””โ”€ .gitkeep
โ”œโ”€ .gitattributes
โ”œโ”€ .gitignore
โ”œโ”€ .pre-commit-config.yaml
โ”œโ”€ .python-version
โ”œโ”€ .tool-versions
โ”œโ”€ CHANGELOG.md
โ”œโ”€ docker-compose.yml
โ”œโ”€ Dockerfile
โ”œโ”€ LICENSE
โ”œโ”€ pyproject.toml
โ”œโ”€ README.md
โ””โ”€ uv.lock

๐Ÿ‘ฅ Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License

Released under MIT by @rjoydip.

Contributors

rjoydip

Issues