A web framework with server-side components defined as Pydantic models
Project description
Fortitude Framework
Fortitude is a web framework that enables server-side components defined as Pydantic models, which can be used as input and output schemas for endpoints registered as tools in an external registry.
Features
- Define data models with Pydantic
- Automatic CRUD API endpoints
- Server-side NextJS UI components
- Tool registry integration
- CLI for project management
- MCP (Model Context Protocol) integration for LLM sampling
- Advanced Rails-like scaffolding for rapid development
- Domain-driven design support
- Microservices architecture
- Database migrations
Installation
# Clone the repository
git clone https://github.com/your-username/fortitude.git
cd fortitude
# Install dependencies
pip install -e .
Quick Start
# Create a new project
fort new myproject
cd myproject
# Install dependencies
pip install -r requirements.txt
cd ui && npm install && cd ..
# Generate a model
fort model User
# Start the servers
fort start
Project Structure
myproject/
├── ui/ # NextJS UI server
│ ├── app/ # App router
│ ├── components/ # React components
│ ├── public/ # Static assets
│ └── package.json
├── backend/ # Backend API server
│ ├── models/ # Pydantic models
│ ├── endpoints/ # API endpoints
│ └── mcp/ # MCP integration
├── main.py # Main application entry point
└── requirements.txt
Creating Models
Models are defined as Pydantic classes that inherit from FortitudeBaseModel:
from fortitude.backend.models import FortitudeBaseModel
from pydantic import Field
from typing import Optional
class User(FortitudeBaseModel):
name: str
email: str
age: Optional[int] = None
Register the model in your main application:
from backend.models.user import User
app.register_model(User)
Advanced Rails-like Scaffolding
Fortitude offers powerful Rails-like scaffolding capabilities with both standard and advanced options:
Basic Resource Generation
# Generate a complete resource scaffold
fort resource Product
This creates:
- Pydantic model
- CRUD controller
- Service layer
- UI components (list, form, detail views)
- MCP integrations
- Tests
Advanced Resource Generation
# Generate an advanced resource scaffold with relationships, validation, and more
fort resource Product --advanced
The advanced scaffold includes:
- Models with relationships, validations, and computed properties
- Full-featured controllers with authentication
- Service layer with caching, transactions, and error handling
- Advanced UI components with filtering, sorting, pagination
- Comprehensive test suite
- Deployment configurations
Domain-Driven Design
# Generate a domain-driven design scaffold
fort domain Store User:name,email,age Product:name,price,stock Order
This creates a complete domain structure with:
- Core domain models
- Value objects
- Repositories
- Domain services
- Application services
- Aggregates
- Entity relationships
Microservices
# Generate microservices
fort microservice auth --type api
fort microservice worker --type worker
fort microservice gateway --type gateway
fort microservice ai-assistant --type mcp-server
Generates specialized microservices with:
- Containerization
- API gateways
- Service discovery
- Health checks
- Message queues
Custom Scaffolds
For maximum flexibility, generate and customize your own scaffolds:
# Generate a scaffold configuration (standard or advanced)
fort generate Task --advanced --output task_scaffold.py
# Edit the configuration file to customize everything
# Then create the scaffold
fort scaffold task_scaffold.py --advanced
MCP Integration
Fortitude provides comprehensive MCP support with both client and server capabilities:
Running an MCP Server
# Start an MCP server
fort mcp-server --name "My MCP Server" --port 8888
# Create a custom sampling handler
fort mcp-handler my_handler --type sampling
# Create a tool handler
fort mcp-handler my_tool --type tool
# Create a resource handler
fort mcp-handler my_resource --type resource
Using MCP with Models
# Generate an MCP client for a model
fort model-mcp-client User --endpoint http://localhost:8888/mcp
# Generate an MCP server for a model
fort model-mcp-server User --port 8889
Sampling from LLMs
# Sample from LLM using MCP
result = await endpoint.sample_llm(
prompt="What insights can you provide about this data?",
system_prompt="You are a data analysis expert",
max_tokens=1000
)
The client will display the sample request and handle user approval through the MCP protocol.
Accessing the UI
Once the servers are running:
- UI Server: http://localhost:9996
- API Server: http://localhost:9997
- API Documentation: http://localhost:9997/docs
- MCP Server: http://localhost:8888/mcp (when running)
Registry Integration
Endpoints are automatically registered as tools in the external registry at https://arthurcolle--registry.modal.run, making them available for agents to use.
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 fortitude_framework-0.1.0.tar.gz.
File metadata
- Download URL: fortitude_framework-0.1.0.tar.gz
- Upload date:
- Size: 85.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.1 CPython/3.12.4 Darwin/24.4.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
332de9ec84d3048b867eb39f80d2f3e624373a6ccd7d2cbe1f01c30e843fc4eb
|
|
| MD5 |
c109074e146aa07cadfae361fd518d82
|
|
| BLAKE2b-256 |
39dcd8893dd1bdeca8e5a4d32e0ba2dfd43d17c560d99c91f810e3d2af32220d
|
File details
Details for the file fortitude_framework-0.1.0-py3-none-any.whl.
File metadata
- Download URL: fortitude_framework-0.1.0-py3-none-any.whl
- Upload date:
- Size: 110.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.1 CPython/3.12.4 Darwin/24.4.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aeda381f0f422afc6e70971441b22c5842d7adb79a6831c126e75af67765e7ac
|
|
| MD5 |
3e4fd8ebde5855cac90959f5f0ff4486
|
|
| BLAKE2b-256 |
4833fda0cb848eb61a38d4f7db064d48111d643e685db1ff0f3f019195f19b59
|