Skip to main content

Shared utilities, services, and RBAC system for TrackVault microservices

Project description

TrackVault Shared Library

Shared utilities and services for TrackVault microservices.

⚠️ IMPORTANT: Maintaining GitHub-PyPI Integrity

When adding new features, fixing bugs, or making any changes to the shared library, you MUST follow this workflow to keep GitHub and PyPI in sync:

Workflow for Changes:

  1. Make Your Changes

    • Edit code in the trackvault_shared/ directory
    • Update tests if needed
    • Test locally: pip install -e .
  2. Update Version in pyproject.toml

    • Increment version number following Semantic Versioning:
      • PATCH (1.5.01.5.1): Bug fixes, minor updates
      • MINOR (1.5.01.6.0): New features, backward compatible
      • MAJOR (1.5.02.0.0): Breaking changes
    [project]
    version = "1.5.1"  # Update this!
    
  3. Commit and Push to GitHub

    git add .
    git commit -m "Add new feature: [description]"
    git push origin main
    
  4. Create GitHub Release (Triggers PyPI Publish)

  5. GitHub Actions Automatically:

    • Builds the package from pyproject.toml
    • Publishes to PyPI with version from pyproject.toml
    • Creates a tagged release on GitHub
  6. Verify Publication

Critical Rules:

  • ALWAYS update pyproject.toml version before creating a release
  • Tag version MUST match pyproject.toml version (with v prefix)
  • Tag format: v1.5.1 (not 1.5.1 or v1.5.0 if version is 1.5.1)
  • Test locally first: pip install -e . in trackvault-shared-lib/
  • Don't publish without version bump (PyPI rejects duplicate versions)
  • Never push to PyPI manually (use GitHub Actions workflow only)
  • Never skip version bump (causes version conflicts)

After Publishing:

  • Update Microservices (if needed):
    • Update requirements.txt in microservices: trackvault-shared>=1.5.1
    • Or let them auto-update: trackvault-shared>=1.5.0 (will get 1.5.1)

Quick Checklist:

[ ] Made code changes
[ ] Updated version in pyproject.toml
[ ] Tested locally: pip install -e .
[ ] Committed and pushed to GitHub
[ ] Created GitHub release with matching tag (v1.x.x)
[ ] Verified GitHub Actions workflow succeeded
[ ] Verified package on PyPI
[ ] Updated microservices if needed

🚀 Quick Installation

Option 1: Install from PyPI (Recommended for Production)

# Install from PyPI
pip install trackvault-shared>=1.5.0

Benefits:

  • ✅ Standard Python package installation
  • ✅ Versioned releases
  • ✅ Works in any environment
  • ✅ CI/CD friendly
  • ✅ No authentication required (public package)

Option 2: Install Locally (Development Only)

For local development, install in editable mode:

# From backend/ directory
cd backend
pip install -e ../trackvault-shared-lib

Benefits:

  • ✅ Changes are immediately available (no reinstall needed)
  • ✅ Perfect for active development

Note: For production/CI/CD, use PyPI (Option 1).

Features

  • Event Bus: Redis Streams-based event publishing and subscription
  • Plans Registry: Multi-tenancy plan definitions and validation
  • Health Checks: Comprehensive health monitoring utilities
  • Circuit Breaker: Prevent cascade failures
  • Retry Pattern: Exponential backoff for resilient operations
  • Event Schemas: Standardized event types for microservice communication
  • Soft Delete: Soft delete mixins for Beanie models

Quick Start

from trackvault_shared import get_project_event_bus, PLANS

# Event Bus
bus = get_project_event_bus("redis://localhost:6379/0")
await bus.publish("project.created", {"project_id": "123"})

# Plans Registry
plan = get_plan_by_name("team")
print(plan["workspace_limits"])

📚 Publishing

To publish a new version:

  1. Update version in pyproject.toml
  2. Create a GitHub release (tag: v1.5.0)
  3. GitHub Actions automatically publishes to PyPI

PyPI API Token Setup:

  1. Go to https://pypi.org/manage/account/token/
  2. Create API token with "Upload packages" scope
  3. Add as secret PYPI_API_TOKEN in GitHub repository settings

License

MIT License - see LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

trackvault_shared-1.5.1.tar.gz (56.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

trackvault_shared-1.5.1-py3-none-any.whl (66.6 kB view details)

Uploaded Python 3

File details

Details for the file trackvault_shared-1.5.1.tar.gz.

File metadata

  • Download URL: trackvault_shared-1.5.1.tar.gz
  • Upload date:
  • Size: 56.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for trackvault_shared-1.5.1.tar.gz
Algorithm Hash digest
SHA256 6d85d3c1fab099c67ae1598214d1c6f7a24d77bacdc9a8722a34fbbc49f4c240
MD5 17b2d10b16e2d2ea658bdcb0bc0247f4
BLAKE2b-256 7bfbce79be4a65dcd24afe52812eba5aaf85d09ecc1c5e15fa609827c53ba26d

See more details on using hashes here.

File details

Details for the file trackvault_shared-1.5.1-py3-none-any.whl.

File metadata

File hashes

Hashes for trackvault_shared-1.5.1-py3-none-any.whl
Algorithm Hash digest
SHA256 fbb278cc0e93e2dbc58f499b381ec5f413d6af6583009f1c8fc8859b4bf1e952
MD5 798b76a5fd61865c1f450459b638da07
BLAKE2b-256 218f49a8419c7217e7165711d63ac9c1d1ac79ca0e3d6e99aa8a5fa44ac24619

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page