Skip to main content

Arclio-rules using fastmcp ๐Ÿš€

Project description

Arclio Rules ๐Ÿš€

Arclio Rules is a FastAPI-based service that implements rule processing using the FastMCP framework. It provides a robust and efficient system for managing and executing business rules in a microservices architecture.

Overview

Arclio Rules is built with Python 3.12+ and leverages modern async capabilities to provide high-performance rule processing. The service can be run either with session management or in a stateless mode using standard I/O.

Features

  • FastAPI-based REST API
  • Built on FastMCP framework for efficient rule processing
  • Elasticsearch integration for rule storage and querying
  • Git integration for version control of rules
  • Support for both session-based and stateless operation modes
  • Frontmatter parsing capabilities
  • Comprehensive logging with Loguru
  • UV package management for fast, reliable dependency handling
  • Make-based workflow automation

Prerequisites

  • Python 3.12.8 or higher
  • UV package manager
  • Docker (optional, for containerized deployment)
  • Age (for secrets management)

Installation

  1. Clone the repository:
git clone https://github.com/fisseha-estifanos/arclio-rules.git
cd arclio-rules
  1. Install dependencies using UV:
make install

This will:

  • Install project dependencies using UV
  • Set up the development environment
  • Sync all dependencies

Environment Setup

  1. Initialize SOPS for secret management:
make init-key
  1. Create your environment file:
# Copy the example environment file
cp .env.example .env

# Decrypt existing secrets (if you have access)
make decrypt

Required Environment Variables:

# GitHub API Configuration
GITHUB_TOKEN="add your GH PAT here"
GITHUB_ORG="add your GH Organization here"
REPO_NAME="add your repo that holds the rules here"

Default Environmental Variables (No need to modify):

Server Configuration

PORT=8000 # Application port HOST=0.0.0.0 # Host to bind to

Additional Settings

LOG_LEVEL=INFO # Logging level (DEBUG, INFO, WARNING, ERROR) ENVIRONMENT=development # Application environment


## Usage

The service can be run in two modes:


### Stateless Mode (using stdio)
```bash
source .env
arclio-rules

Development Mode

make run-dev

Development Commands

The project includes a comprehensive Makefile for common development tasks:

# Development
make run-dev         # Run development server
make install         # Install dependencies
make build           # Build the project
make publish         # Publish the project to pypi

# Code Quality
make lint            # Run Ruff linter
make type-check      # Run Pyright type checker
make format          # Format code with Ruff
make pre-commit      # Run all code quality checks

# Secrets Management
make init-key        # Generate new age key for SOPS
make encrypt         # Encrypt .env to .env.sops
make decrypt         # Decrypt .env.sops to .env
make add-recipient   # Add new public key (make add-recipient KEY=age1...)

Project Structure

arclio-rules/ โ”œโ”€โ”€ src/ โ”‚ โ””โ”€โ”€ arclio_rules/ โ”‚ โ”œโ”€โ”€ datamodels/ # Data models and schemas โ”‚ โ”œโ”€โ”€ inhouse_rules/ # Internal rule implementations โ”‚ โ”œโ”€โ”€ routes/ # API route handlers โ”‚ โ”œโ”€โ”€ services/ # Business logic services โ”‚ โ”œโ”€โ”€ main.py # Application entry point โ”‚ โ”œโ”€โ”€ server_with_session.py # Session-based server โ”‚ โ””โ”€โ”€ server_wo_session.py # Stateless server โ”œโ”€โ”€ dist/ # Distribution files โ”œโ”€โ”€ routes/ # API route definitions โ”œโ”€โ”€ Makefile # Development automation โ”œโ”€โ”€ pyproject.toml # Project configuration โ”œโ”€โ”€ .env.example # Example environment configuration โ””โ”€โ”€ docker-compose.yml # Docker composition file

Configuration

The project uses various configuration files:

  • pyproject.toml: Project metadata and dependencies
  • pyrightconfig.json: Python type checking configuration
  • .sops.yaml: Secrets management configuration
  • docker-compose.yml: Container orchestration settings
  • .env: Environment variables (created from .env.example)

Development

Package Management with UV

The project uses UV for dependency management, offering:

  • Faster package installation
  • Reliable dependency resolution
  • Consistent environments across development and production
  • Integration with virtual environments

Code Quality Tools

The project uses several tools to maintain code quality:

  • Ruff: For linting and formatting
    • Enforces PEP 8 style guide
    • Manages import sorting
    • Checks docstring formatting (Google style)
  • MyPy: For static type checking
  • Pytest: For testing (with async support)

Linting Rules

The project enforces specific linting rules through Ruff, including:

  • PEP 8 compliance (E)
  • PyFlakes checks (F)
  • Import sorting (I)
  • Docstring formatting (D)

Dependencies

Key dependencies include:

  • fastapi: Web framework
  • fastmcp: MCP framework integration
  • elasticsearch: Search and storage
  • aiohttp: Async HTTP client
  • pydantic: Data validation
  • uvicorn: ASGI server

License

[Add your license information here]

Contributing

[Add contribution guidelines here]

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

arclio_rules-0.4.2.tar.gz (62.5 kB view details)

Uploaded Source

Built Distribution

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

arclio_rules-0.4.2-py3-none-any.whl (14.7 kB view details)

Uploaded Python 3

File details

Details for the file arclio_rules-0.4.2.tar.gz.

File metadata

  • Download URL: arclio_rules-0.4.2.tar.gz
  • Upload date:
  • Size: 62.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for arclio_rules-0.4.2.tar.gz
Algorithm Hash digest
SHA256 032ed4d7ffa1921b3367e9aef61f2ca5b560bb0d7c04f3c58eafbdf345b7bda2
MD5 a8764f4ca97ea042fd46ba46b0b0ffc8
BLAKE2b-256 f358c82ff2f2e458e27c1524b83e40883ba4745431e4d6622445d9080db4073c

See more details on using hashes here.

File details

Details for the file arclio_rules-0.4.2-py3-none-any.whl.

File metadata

  • Download URL: arclio_rules-0.4.2-py3-none-any.whl
  • Upload date:
  • Size: 14.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for arclio_rules-0.4.2-py3-none-any.whl
Algorithm Hash digest
SHA256 2e48c56a9aafabc821e8ad8c52bc6055e2c308f285e8c18e0662685f2649b463
MD5 03c773feb2910da9a34d8158287b9dc3
BLAKE2b-256 3c41f19896be9b39c8843060e1674e33cb2e26187aef69615a058549ec8514f8

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