Overview
Framefox is a Python web framework built on top of FastAPI, providing a structured, modular architecture for building scalable web applications. The framework follows a layered architecture pattern with clear separation of concerns.Core Components
The framework consists of three primary components that work together:1. Application
TheApplication class is the central entry point for all interactions with Framefox, whether via web or CLI.
/home/daytona/workspace/source/framefox/application.py:14-58
- Singleton Pattern: Ensures only one application instance exists
- Dual Boot Modes: Supports both web (
boot_web()) and CLI (boot_cli()) modes - Service Management: Initializes the ServiceContainer and BundleManager
2. Kernel
TheKernel is the core of the web application, responsible for initializing and configuring the FastAPI app.
/home/daytona/workspace/source/framefox/core/kernel.py:25-52
/home/daytona/workspace/source/framefox/core/kernel.py:65-76
3. Bundles
Bundles are modular packages that extend Framefox functionality. They can register services, commands, and configuration./home/daytona/workspace/source/framefox/core/bundle/abstract_bundle.py:16-55
Component Interaction
Request Lifecycle
Understanding how a request flows through Framefox:1. Request Entry
A request enters the FastAPI application managed by the Kernel.2. Middleware Processing
The request passes through configured middleware layers:- Trailing slash handler
- Security middleware
- Session middleware
- Custom middleware
3. Routing
The Router matches the request to a registered route:/home/daytona/workspace/source/framefox/core/routing/router.py:77-82
4. Controller Resolution
The ControllerResolver lazy-loads and instantiates the controller with dependencies:/home/daytona/workspace/source/framefox/core/controller/controller_resolver.py:70-88
5. Dependency Injection
The Route decorator automatically injects services into controller methods:/home/daytona/workspace/source/framefox/core/routing/decorator/route.py:27-58
6. Response Generation
The controller method executes and returns a response (HTML, JSON, redirect, etc.).7. Response Processing
The response passes back through middleware and is sent to the client.Architecture Flow Diagram
Key Design Principles
Separation of Concerns
Each component has a specific responsibility:- Application: Bootstrapping and initialization
- Kernel: Web application configuration
- Router: Request routing
- Controllers: Business logic
- ServiceContainer: Dependency management
Dependency Injection
All framework components use dependency injection for loose coupling and testability.Modular Architecture
Bundles allow extending the framework without modifying core code.Lazy Loading
Controllers and services are loaded on-demand for optimal performance.Next Steps
MVC Pattern
Learn how Framefox implements the MVC pattern
Dependency Injection
Master the ServiceContainer and DI system
Routing
Understand the routing system and decorators
Creating Bundles
Build custom bundles to extend Framefox