This document outlines a modular architecture approach for the Process system that preserves independence between components while enhancing maintainability and flexibility.
The current architecture has several strengths that should be preserved:
core/
directory provide shared functionality without tight coupling.Instead of consolidating services, define clear protocol contracts that each service must implement:
project/
├── protocols/ # Protocol definitions (language-agnostic)
│ ├── process_api.proto # Core Process API definition
│ ├── resource_api.json # Resource API schema
│ └── openapi/ # OpenAPI specifications
These protocol definitions serve as the contract between services, allowing any implementation to be compatible as long as it adheres to the protocol.
Each service should be able to function independently while optionally leveraging the core framework:
project/
├── core/ # Core framework (optional for services)
│ ├── config.py # Configuration utilities
│ ├── logging.py # Logging utilities
│ └── error_handling.py # Error handling utilities
├── process/ # Core Process implementation
├── grpc/ # gRPC service (can be separate repo)
├── rest/ # REST service (can be separate repo)
└── mcp/ # MCP service (can be separate repo)
Services can choose to use the core framework via:
To allow services to be implemented in different languages while still integrating with the Process engine, use an adapter pattern:
grpc/
├── adapters/ # Adapters for different Process implementations
│ ├── process_adapter.py # Python adapter for Process
│ └── process_client.py # Client for remote Process service
This allows the gRPC service to either:
Each service should have its own configuration system that can operate independently:
grpc/
├── config/ # Service-specific configuration
│ ├── default.yaml # Default configuration
│ └── production.yaml # Environment-specific overrides
When used with the core framework, the service can leverage the shared configuration utilities, but it’s not required.
To support implementations in different languages, provide examples or templates:
templates/
├── python/ # Python service template
├── go/ # Go service template
└── rust/ # Rust service template
Each template demonstrates how to implement a service that adheres to the protocol contracts.
# Using core framework
from core.logging import get_logger
from core.config import load_config
# Or implementing directly
import logging
def get_logger(name):
return logging.getLogger(name)
// Implementing the same protocol contract
package main
import (
"google.golang.org/grpc"
pb "myproject/protocols/process"
)
type ProcessServer struct {
// Implementation details
}
func (s *ProcessServer) ProcessText(ctx context.Context, req *pb.ProcessRequest) (*pb.ProcessResponse, error) {
// Implementation
}
To add a new WebSocket service:
websocket/
This can be done without modifying any existing code, demonstrating the true modularity of the architecture.
This enhanced modular architecture preserves the independence of services while providing optional shared functionality through the core framework. It allows for true polyglot implementation, where each service can be written in the most appropriate language while still maintaining compatibility with the overall system.
By focusing on clear protocol contracts and minimal dependencies, the system becomes more maintainable, flexible, and future-proof.