$ show utilmeta/utilmeta-py
UtilMeta is a progressive Python meta-framework for building declarative APIs with integrated ORM, authentication, caching, client generation, and operations monitoring. The codebase provides a modular architecture with backend adaptors for Django, Flask, FastAPI, Sanic, Tornado, and Starlette, allowing developers to write framework-agnostic API services. Core features include declarative API classes with route mounting, request parameter extraction via decorators, automatic OpenAPI spec generation, a plugin system for cross-cutting concerns (CORS, caching, rate limiting), and a full ORM layer that compiles queries to Django/SQLAlchemy/Peewee backends. The ops module offers built-in service monitoring, logging, alerting, and supervisor connectivity for production management. Key entry points are the UtilMeta service class, the API base class, the CLI tool (meta), and the operations configuration. External dependencies include Django, databases libraries, jwcrypto, psutil, and utype for type validation.
The LLM identified 5 files worth highlighting for reuse:
Implements CacheEntity with key tracking, hit counting, and eviction policies using Redis Lua scripts. The entity pattern abstracts cache backend differences and provides atomic batch operations (increment, relate). Reusable as a standalone caching abstraction for any Python project that needs efficient, tracked cache entries with minimal coupling.
Provides a custom Error class with cause chaining, formatted traceback with source code context, and HTTP status mapping. The class supports async traceback capture and is standalone, making it easily reusable in any Python application for structured error propagation and logging.
Implements CORS as a plugin that hooks into API request/response processing. It handles preflight requests, origin validation, and header injection. The plugin pattern (process_request/process_response) is generic and can be extracted into other web frameworks with minimal changes.
Provides a Server-Sent Events (SSE) response class with event parsing, timeout handling, and async iteration support. It dynamically creates subclasses per event type. Reusable as a standalone SSE implementation for any Python HTTP framework, requiring only a simple adaptor.
Defines abstract base classes for ORM adaptors: ModelAdaptor, ModelQueryAdaptor, ModelFieldAdaptor. These provide a clean contract for translating schema queries to backend-specific operations (create, update, delete, bulk operations). Reusable in any project that needs to support multiple ORM backends, with clear separation of concerns.