|
| 1 | +# π OSBot-Fast-API Documentation |
| 2 | + |
| 3 | +## π― Overview |
| 4 | + |
| 5 | +**Package**: `osbot_fast_api` |
| 6 | +**Current Version**: v0.9.1 |
| 7 | +**Purpose**: A Type-Safe wrapper around FastAPI that provides strong typing, middleware support, and AWS Lambda integration through Mangum |
| 8 | +**Status**: Production Ready |
| 9 | + |
| 10 | +## π Documentation Structure |
| 11 | + |
| 12 | +This documentation follows a structured approach to thoroughly document the OSBot-Fast-API package: |
| 13 | + |
| 14 | +### Core Documentation |
| 15 | +- [Architecture Overview](./architecture/osbot-fast-api-architecture.md) - System design and component relationships |
| 16 | +- [Type-Safe Integration](./type-safe/type-safe-integration.md) - Type conversion system and patterns |
| 17 | +- [HTTP Events System](./features/http-events-system.md) - Request/response tracking and monitoring |
| 18 | +- [Middleware Stack](./features/middleware-stack.md) - Built-in and custom middleware |
| 19 | + |
| 20 | +### API Documentation |
| 21 | +- [Fast_API Class](./code/osbot_fast_api/api/Fast_API.py.md) - Main FastAPI wrapper |
| 22 | +- [Fast_API_Routes](./code/osbot_fast_api/api/Fast_API_Routes.py.md) - Route organization |
| 23 | +- [Type Converters](./code/osbot_fast_api/utils/type_safe/) - Type-Safe to BaseModel converters |
| 24 | + |
| 25 | +### Usage Guides |
| 26 | +- [Quick Start Guide](./guides/quick-start.md) - Getting started with OSBot-Fast-API |
| 27 | +- [LLM Prompts](./guides/llm-prompts.md) - Prompts for working with this package |
| 28 | +- [Testing Guide](./guides/testing.md) - Testing strategies and utilities |
| 29 | + |
| 30 | +## ποΈ High-Level Architecture |
| 31 | + |
| 32 | +```mermaid |
| 33 | +graph TB |
| 34 | + subgraph "Application Layer" |
| 35 | + APP[FastAPI Application] |
| 36 | + ROUTES[Route Handlers] |
| 37 | + SCHEMAS[Type-Safe Schemas] |
| 38 | + end |
| 39 | + |
| 40 | + subgraph "OSBot-Fast-API Core" |
| 41 | + FA[Fast_API Wrapper] |
| 42 | + FAR[Fast_API_Routes Base] |
| 43 | + TS[Type Converters] |
| 44 | + HE[HTTP Events] |
| 45 | + MW[Middleware Stack] |
| 46 | + end |
| 47 | + |
| 48 | + subgraph "Infrastructure" |
| 49 | + SERVER[Test Server] |
| 50 | + LAMBDA[Lambda Handler] |
| 51 | + UTILS[Utilities] |
| 52 | + end |
| 53 | + |
| 54 | + APP --> FA |
| 55 | + ROUTES --> FAR |
| 56 | + SCHEMAS --> TS |
| 57 | + FA --> HE |
| 58 | + FA --> MW |
| 59 | + FA --> SERVER |
| 60 | + FA --> LAMBDA |
| 61 | +``` |
| 62 | + |
| 63 | +## π Key Features |
| 64 | + |
| 65 | +### Type-Safe First |
| 66 | +- Automatic conversion between Type_Safe classes and Pydantic BaseModels |
| 67 | +- Strong typing throughout the application |
| 68 | +- Validation at API boundaries |
| 69 | + |
| 70 | +### Production Ready |
| 71 | +- Built-in HTTP event tracking |
| 72 | +- Comprehensive middleware support |
| 73 | +- Global exception handling |
| 74 | +- AWS Lambda compatibility |
| 75 | + |
| 76 | +### Developer Experience |
| 77 | +- Minimal boilerplate code |
| 78 | +- Convention over configuration |
| 79 | +- Integrated testing utilities |
| 80 | +- Clear extension points |
| 81 | + |
| 82 | +## π¦ Package Components |
| 83 | + |
| 84 | +| Component | Purpose | Location | |
| 85 | +|-----------|---------|----------| |
| 86 | +| `Fast_API` | Main FastAPI wrapper with Type-Safe support | `/api/Fast_API.py` | |
| 87 | +| `Fast_API_Routes` | Base class for route organization | `/api/Fast_API_Routes.py` | |
| 88 | +| `Fast_API__Http_Events` | HTTP request/response tracking | `/api/Fast_API__Http_Events.py` | |
| 89 | +| `Type_Safe__To__BaseModel` | Type conversion system | `/utils/type_safe/` | |
| 90 | +| `Fast_API_Server` | Test server for integration testing | `/utils/Fast_API_Server.py` | |
| 91 | + |
| 92 | +## π§ Quick Example |
| 93 | + |
| 94 | +```python |
| 95 | +from osbot_fast_api.api.Fast_API import Fast_API |
| 96 | +from osbot_fast_api.api.Fast_API_Routes import Fast_API_Routes |
| 97 | +from osbot_utils.type_safe.Type_Safe import Type_Safe |
| 98 | + |
| 99 | +# Define a Type-Safe schema |
| 100 | +class User(Type_Safe): |
| 101 | + name: str |
| 102 | + email: str |
| 103 | + age: int |
| 104 | + |
| 105 | +# Create routes |
| 106 | +class Routes_Users(Fast_API_Routes): |
| 107 | + tag = 'users' |
| 108 | + |
| 109 | + def create_user(self, user: User): |
| 110 | + return {'created': user.name} |
| 111 | + |
| 112 | + def setup_routes(self): |
| 113 | + self.add_route_post(self.create_user) |
| 114 | + |
| 115 | +# Setup application |
| 116 | +fast_api = Fast_API() |
| 117 | +fast_api.setup() |
| 118 | +fast_api.add_routes(Routes_Users) |
| 119 | +app = fast_api.app() |
| 120 | +``` |
| 121 | + |
| 122 | +## π Performance Characteristics |
| 123 | + |
| 124 | +| Operation | Complexity | Cached | |
| 125 | +|-----------|------------|---------| |
| 126 | +| Type Conversion | O(n) fields | β
| |
| 127 | +| Route Registration | O(1) | β | |
| 128 | +| HTTP Event Tracking | O(1) | β | |
| 129 | +| Middleware Execution | O(m) middleware | β | |
| 130 | + |
| 131 | +## π Documentation Navigation |
| 132 | + |
| 133 | +### By Feature |
| 134 | +- [Type Safety System](./type-safe/) |
| 135 | +- [HTTP Events](./features/http-events-system.md) |
| 136 | +- [Middleware](./features/middleware-stack.md) |
| 137 | +- [Testing](./guides/testing.md) |
| 138 | + |
| 139 | +### By Component |
| 140 | +- [Core API Classes](./code/osbot_fast_api/api/) |
| 141 | +- [Utilities](./code/osbot_fast_api/utils/) |
| 142 | +- [Examples](./code/osbot_fast_api/examples/) |
| 143 | + |
| 144 | +### By Use Case |
| 145 | +- [Building APIs](./guides/quick-start.md) |
| 146 | +- [AWS Lambda Deployment](./guides/lambda-deployment.md) |
| 147 | +- [Testing Strategies](./guides/testing.md) |
| 148 | + |
| 149 | +## π Version History |
| 150 | + |
| 151 | +- **v0.9.1** - Current stable release |
| 152 | +- Production ready with full Type-Safe integration |
| 153 | +- Comprehensive middleware support |
| 154 | +- AWS Lambda compatibility |
0 commit comments