Pancake - Decorator-driven Python web framework with IoC, MyBatis ORM, and AI workflow
Project description
Pancake Framework
A decorator-driven Python web framework with IoC, MyBatis-style ORM, and AI workflow integration.
Features
- Zero Import — All decorators and services auto-injected into builtins
- Decorator-Driven — Register controllers, mappers, services with simple decorators
- CLI Tool —
pancake create/run/check/build/plugin/config/audit - MyBatis Plus ORM — Async ORM with CRUD,
@Select/@Insert, dynamic SQL, chain queries - FastAPI Web — Controllers, filter chain (Spring Security-style), auth, middleware, WebSocket
- IoC Container — Singleton, transient, scoped dependency injection
- AI Module — Unified LLM client (OpenAI/DeepSeek/Gemini/Ollama), memory, RAG
- Redis Cache —
@cachedwith anti-penetration/avalanche/breakdown protection - Message Queue — Event-driven with SimpleBroker and RedisBroker
- Remote Calls — HTTP and gRPC via
@remote_node - Lifecycle — Init/start/stop/error hooks for components
- Plugin System — Auto-discovery, init-order control, external plugin dirs
Quick Start
pip install pancake_framework
pancake create myapp && cd myapp
pancake run
Server starts at http://127.0.0.1:8080. Health check at /health.
Minimal Example
# No imports needed — everything is in builtins
@get_controller("/hello")
def hello():
return {"message": "Hello from Pancake!"}
@Mapper
class UserMapper(BaseMapper):
_entity_class = User
_table_name = "users"
@Select("SELECT * FROM users WHERE name = #{name}")
async def find_by_name(self, name: str) -> list[User]: ...
Documentation
| Module | Description |
|---|---|
| CLI | Command-line tools |
| Web | Controllers, filter chain, auth, middleware, WebSocket |
| MyBatis ORM | Mappers, CRUD, chain queries, dynamic SQL |
| AI | LLM client, memory, RAG |
| Redis | Cache, data structures, distributed locks |
| IoC & DI | IoC container, @auto_inject, @inject |
| Config | YAML/XML/env configuration |
| Plugins | Plugin system and built-in plugins |
| Lifecycle | Component lifecycle hooks |
| Messaging | Event-driven message queue |
| Remote | HTTP and gRPC remote calls |
| Security | Password hashing, API key, CSRF, OAuth2, sessions |
Optional Dependencies
pip install pancake_framework[ai] # AI module
pip install pancake_framework[langgraph] # LangGraph workflow
pip install pancake_framework[redis] # Redis cache & messaging
pip install pancake_framework[grpc] # gRPC remote calls
pip install pancake_framework[cui] # Click CLI commands
pip install pancake_framework[gui] # Flet GUI
pip install pancake_framework[all] # All optional deps
TODO
Core / IoC
- Database migration support
- Configuration hot-reload
- Pagination
Pageobject abstraction - OpenTelemetry / metrics integration
- Graceful shutdown with signal handling
- WebSocket support
- Rate limiting middleware
- API documentation auto-generation
- More database dialects (SQLite/PG/MySQL type mapping)
- Connection pool health check and auto-reconnect
- JWT authentication support
- Scheduled tasks (cron-like)
- CLI interactive code (REPL)
- Auto-configuration — auto-detect dependencies and configure defaults
- Profiles — environment-specific config (dev / test / prod)
- Conditional beans —
@ConditionalOnProperty,@ConditionalOnClass - Bean lifecycle callbacks —
@PostConstruct,@PreDestroy - Lazy initialization —
@Lazyfor deferred bean creation - Event system —
@EventListener, application events (ContextRefreshed, etc.) - Property binding — auto-map YAML/ENV to dataclass (
@ConfigurationProperties)
Web / REST
- CORS configuration — global and per-route CORS policy
- API versioning —
/api/v1/users,/api/v2/users - Exception handler —
@ExceptionHandler, global error response - Request logging middleware — auto-log method, path, status, duration
- Response compression — gzip/brotli middleware
- File upload —
@multipart, multipart/form-data handling - Server-Sent Events —
@sse_controllerfor real-time push - Request body validation — Pydantic-style
@Validon request models - Content negotiation — JSON / XML response based on Accept header
- Async route handler — auto-detect async vs sync functions
- Static file serving — built-in static directory mount
- Request ID — auto-generate and propagate
X-Request-Id
Security
- OAuth2 support — OAuth2 client and resource server
- API key authentication —
@api_key_requiredheader-based auth - Password hashing — bcrypt/argon2 integration
- CSRF protection — token-based CSRF for form submissions
- Security headers — auto-add HSTS, X-Frame-Options, CSP
- IP whitelist/blacklist — middleware-based IP filtering
- Session management — server-side session with Redis/memory store
Data / ORM
- Transaction propagation — REQUIRED, REQUIRES_NEW, NESTED
- Soft delete —
@SoftDelete,deleted_atcolumn support - Auto timestamps —
created_at,updated_atauto-fill - Optimistic locking — version field for concurrent update safety
- Multi-datasource — connect to multiple databases simultaneously
- Database seeding — auto-insert initial data on startup
- Query logging — SQL statement logging with execution time
- Raw SQL helper —
db.execute_raw(sql)with safety checks - Relation mapping — one-to-many, many-to-many lazy/eager loading
AOP / Middleware
- AOP (Aspect-Oriented Programming) —
@Before,@After,@Aroundpointcuts - Retry mechanism —
@Retry(max=3, delay=1)for flaky operations - Circuit breaker —
@CircuitBreakerfor fault tolerance - Cache abstraction —
@Cacheable,@CacheEvict(multi-backend: memory/Redis) - Async execution —
@Asyncfor non-blocking background tasks - Method timer —
@Timedfor method execution metrics - Locking —
@DistributedLockfor concurrent access control
Observability
- Structured logging — JSON log output with correlation ID
- Health indicators — custom health checks (DB, Redis, external API)
- Distributed tracing — OpenTelemetry trace context propagation
- Log levels API — runtime log level change via REST endpoint
DevOps / CLI
- Project scaffolding —
pancake createwith templates (API / Fullstack / Microservice) - Code generation — auto-generate Mapper/Controller from table schema
- DevTools — auto-restart on code change (watchdog)
- Docker support — auto-generate Dockerfile and docker-compose.yml
- Config validation — startup validation of required config keys
- Dry run —
pancake checkwith full dependency and config validation
Performance
- C extension — convert hot-path modules (sql_parser, wrapper, jwt) to C for speed
Tests
pip install pytest pytest-asyncio
python -m pytest tests/ -v
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pancake_framework-0.2.0.tar.gz.
File metadata
- Download URL: pancake_framework-0.2.0.tar.gz
- Upload date:
- Size: 35.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
86cf541cc562a1b980c8bfdff106f9694484b5c1591569ab832356521b402b0c
|
|
| MD5 |
a456416c7c1f245670c7aa6f63675704
|
|
| BLAKE2b-256 |
378b5ea8d7307d29afb160fafb5ba6c9cf8a7138c28d89d79924ebb2f7e2b98a
|
Provenance
The following attestation bundles were made for pancake_framework-0.2.0.tar.gz:
Publisher:
publish.yml on Drayee/PancakeFramework
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pancake_framework-0.2.0.tar.gz -
Subject digest:
86cf541cc562a1b980c8bfdff106f9694484b5c1591569ab832356521b402b0c - Sigstore transparency entry: 1731619118
- Sigstore integration time:
-
Permalink:
Drayee/PancakeFramework@de79aea93527778d4c9f74f972e2d10a5be1e34b -
Branch / Tag:
refs/heads/master - Owner: https://github.com/Drayee
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@de79aea93527778d4c9f74f972e2d10a5be1e34b -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file pancake_framework-0.2.0-py3-none-any.whl.
File metadata
- Download URL: pancake_framework-0.2.0-py3-none-any.whl
- Upload date:
- Size: 44.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8d9643df7439c4eec6733d62be2be511cf1b93a8432f1c8116cc5b27c6eaeb2a
|
|
| MD5 |
3598328fb7329d1a15b8312c3011b78f
|
|
| BLAKE2b-256 |
005788a464a5577356c0095b8c444b4e6f37725a4a4f79ea5783a6829f7de201
|
Provenance
The following attestation bundles were made for pancake_framework-0.2.0-py3-none-any.whl:
Publisher:
publish.yml on Drayee/PancakeFramework
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pancake_framework-0.2.0-py3-none-any.whl -
Subject digest:
8d9643df7439c4eec6733d62be2be511cf1b93a8432f1c8116cc5b27c6eaeb2a - Sigstore transparency entry: 1731619205
- Sigstore integration time:
-
Permalink:
Drayee/PancakeFramework@de79aea93527778d4c9f74f972e2d10a5be1e34b -
Branch / Tag:
refs/heads/master - Owner: https://github.com/Drayee
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@de79aea93527778d4c9f74f972e2d10a5be1e34b -
Trigger Event:
workflow_dispatch
-
Statement type: