Contributors Wanted Β Β π€Weβre actively seeking contributors to help build packages for major application transports like gRPC, MQTT, GraphQL, Server-Sent Events (SSE), and more. Our Core, HTTP, and WebSocket packages are production-ready and serve as excellent reference implementations. If youβre interested in contributing, please reach out on GitHub !
Package Status
Production Ready β
polyflux-core - Core building blocks and shared components (comprehensive test coverage)
polyflux-http - HTTP client and server with ASGI integration (120 tests)
polyflux-websocket - WebSocket client and server with broadcasting (277 tests)
In Development π§
polyflux-grpc - gRPC client and server implementation
polyflux-mqtt - MQTT client and broker for IoT applications
polyflux-graphql - GraphQL client and server implementation
polyflux-sse - Server-Sent Events client and server
polyflux-kafka - Apache Kafka client for distributed streaming
Use the production-ready packages as reference implementations when building new protocol packages.
Prerequisites
Python 3.12+ - Required for modern type annotations and PEP 695 generics
uv - Primary package and environment manager
Git - Version control
Important : Always use uv for all Python operations. Never use system Python, pip, or direct commands.
Setup & Installation
1. Clone and Setup
git clone https://github.com/greysonlalonde/polyflux.git
cd polyflux
2. Environment and Dependencies
# Create and activate virtual environment (handled automatically by uv)
uv sync --all-groups
# Verify installation
uv run python --version # Should be 3.12+
3. Install Pre-commit Hooks
uv run pre-commit install
Development Workflow
Core Commands
Linting & Testing
Code Formatting
Type Checking
# Run full quality check (required before committing)
./scripts/lint-and-test.sh
# Check specific path
./scripts/lint-and-test.sh packages/http/
# Run only tests
./scripts/test-all-packages.sh
# Format code with ruff
uv run ruff format .
# Lint and auto-fix issues
uv run ruff check --fix .
# Full type checking with mypy
uv run mypy --no-incremental .
# Check specific package
uv run mypy packages/http/
Quality Standards
All code must meet these standards:
π¨ Code Formatting - Consistent style with ruff format
π Linting - Clean code with ruff check
π‘οΈ IDE Support - Full autocomplete and error detection
β
Tests - All tests must pass
π Pre-commit - Hooks must pass on every commit
Creating New Packages
Package Generation
Use the automated package creator:
# Basic package
uv run scripts/create-package.py grpc
# With dependencies
uv run scripts/create-package.py mqtt asyncio-mqtt "paho-mqtt==1.6.1"
# Custom class name
uv run scripts/create-package.py grpc --class-name GRPC "grpcio>=1.50.0"
This creates a complete package structure with:
Client and server implementations
Configuration setup
Message types
Error handling with validation
Comprehensive test framework
Documentation templates
Generated Package Structure
packages/new-package/
βββ src/polyflux/new_package/
β βββ __init__.py # Package exports
β βββ client/
β β βββ __init__.py
β β βββ base.py # Unified client implementation (all protocols)
β β βββ configurable.py # Configuration schema
β βββ server/
β β βββ __init__.py
β β βββ base.py # Unified server implementation (all protocols)
β β βββ configurable.py # Server configuration
β β βββ exceptions.py # Server-specific exceptions
β β βββ types.py # Server-specific types
β β βββ utils.py # Protocol-specific utility functions
β βββ shared/
β βββ __init__.py
β βββ protocol_data_unit.py # PDU definitions
β βββ types.py # Shared type definitions
β βββ utils.py # Shared utility functions
βββ tests/ # Comprehensive test suite
βββ pyproject.toml # Package configuration
βββ README.md # Package documentation
Code Standards
Interface Design β
from typing import Protocol, runtime_checkable, Any
from polyflux.core import BaseExchange
from polyflux.core.shared.contracts.protocol_data_unit import Inbound
@runtime_checkable
class GrpcClient (BaseExchange[Inbound], Protocol ):
"""gRPC-specific client protocol."""
async def call_method ( self , service : str , method : str , ** kwargs : Any) -> bool :
"""Call gRPC method."""
...
async def disconnect ( self ) -> None :
"""Close gRPC connection."""
...
class GrpcClientImpl ( GrpcClient ):
"""Concrete gRPC client implementation."""
async def exchange ( self , ** kwargs : Any) -> Inbound:
# Implementation here
...
Configuration Setup β
from typing import TypedDict, NotRequired
from polyflux.core import BaseConfigSchema
class GrpcConfigSchema ( BaseConfigSchema ):
host: str # Required
port: int # Required
timeout: NotRequired[ float ] # Optional (inherited)
ssl_enabled: NotRequired[ bool ] # Optional
credentials: NotRequired[dict[ str , str ]] # Optional
Anti-Patterns β
# Bad: Missing type annotations
def connect_grpc ( host ):
return grpc_client.connect(host)
# Bad: Not using protocols
class GrpcClient :
def call_method ( self , method ):
pass
# Bad: Hardcoded configuration
class Client :
def __init__ ( self ):
self .timeout = 30 # Should be configurable
Testing
Test Structure
# Run all tests
./scripts/test-all-packages.sh
# Run specific package tests
uv run pytest packages/http/tests/ -v
# Run with coverage
uv run pytest packages/http/tests/ --cov=polyflux.http
# Run specific test
uv run pytest packages/http/tests/test_client.py::test_http_exchange -v
Test Categories
Unit Tests - Individual component testing
Integration Tests - End-to-end client/server scenarios
Interface Tests - Implementation validation
Configuration Tests - Setup validation
Reliability Tests - Error handling and circuit breaker patterns
External Service Tests - Real service integration (with fallbacks)
Writing Tests
Use production-ready packages as examples for test patterns:
import pytest
from polyflux.http import HttpClient, HttpClientConfigSchema
@pytest.mark.asyncio
async def test_http_client_exchange ():
"""Test HTTP client exchange functionality."""
config: HttpClientConfigSchema = {
"base_url" : "https://httpbin.org" ,
"timeout" : 10.0
}
client = HttpClient()
client.configure(config)
async with client:
response = await client.exchange(
target = "/get" ,
method = "GET"
)
assert response[ "status_code" ] == 200
assert b "httpbin" in response[ "data" ]
# WebSocket test example (from production package)
from polyflux.websocket import WebSocketClient
@pytest.mark.asyncio
async def test_websocket_client_exchange ():
"""Test WebSocket client exchange functionality."""
async with WebSocketClient() as client:
await client.connect( "wss://echo.websocket.org" )
response = await client.exchange(
target = "wss://echo.websocket.org" ,
message_type = "text" ,
data = "Hello WebSocket!"
)
assert response[ "message_type" ] == "text"
assert "Hello WebSocket!" in response[ "data" ]
Build and Release
Building Packages
# Build all packages
./scripts/build-all.sh
# Build specific package
cd packages/http && uv build
# Publish (maintainers only)
./scripts/publish.sh
Version Management
# Bump version across all packages
./scripts/bump-version.sh 0.2.0
# Check for dead code
./scripts/check-dead-and-duplicate.sh
Contributing Guidelines
Pull Request Process
Fork and Branch
git checkout -b feature/grpc-implementation
Follow Standards
Implement using Protocol-first design
Add comprehensive type annotations
Write tests for all functionality
Update documentation
Quality Checks
# Must pass before submitting PR
./scripts/lint-and-test.sh
Commit Guidelines
feat(grpc): implement gRPC client with service discovery
- Add GrpcClient protocol implementation
- Implement async context manager support
- Add service discovery and load balancing
- Include comprehensive type annotations
- Add reliability patterns with circuit breaker
Closes #123
Review Checklist
Code Review Standards
Interface Implementation - Must implement all required interfaces
Type Annotations - Every function, method, and variable must be typed
Error Handling - Proper exception hierarchy and error propagation
Async Patterns - Proper async/await usage and context managers
Documentation - Clear docstrings and usage examples
IDE Configuration
PyCharm Setup
Interpreter : Use the .venv created by uv
Source Roots : Mark all src/ directories as source roots
Type Checking : Enable mypy plugin/inspections
Formatting : Configure ruff as the formatter
VS Code Setup
{
"python.defaultInterpreterPath" : ".venv/bin/python" ,
"python.linting.mypyEnabled" : true ,
"python.formatting.provider" : "ruff" ,
"python.linting.ruffEnabled" : true
}
Debugging and Troubleshooting
Common Issues
# Ensure you're using uv commands
uv sync --all-groups
uv run python -c "import polyflux.core"
# Run mypy with verbose output
uv run mypy --no-incremental --show-error-codes packages/http/
# Run tests with verbose output and no capture
uv run pytest packages/http/tests/ -v -s --tb=long
Getting Help
Architecture Guidelines
Package Design Principles
Interface-First - Always define interfaces before implementation
IDE Support - Complete autocomplete and error detection
Async Native - Built for async/await from the ground up
Configuration - Simple setup for all components
Reliability - Circuit breaker patterns and graceful error handling
Testability - Comprehensive test coverage with protocol conformance tests
Extending Polyflux
When creating new protocol packages:
Study Existing - Review the HTTP and WebSocket packages as reference implementations
Protocol Analysis - Understand the target protocolβs characteristics
Message Design - Create appropriate message structures
Error Hierarchy - Design protocol-specific exception classes
Configuration - Create simple configuration setup
Testing Strategy - Plan unit, integration, and conformance tests
The goal is to provide developers with a consistent, type-safe, and protocol-agnostic interface for any communication protocol.