The Python framework for Data Applications

Plateforme enables you to build and deploy modern data-driven applications and services in seconds with the power of SQLAlchemy, Pydantic, and FastAPI.

Plateforme

Build with ease

Write simple Python classes to define your backend database and API!

from plateforme import BaseResource, route

class Astronaut(BaseResource):
    name: str

    @route.get()
    def hello(self) -> str:
        return f'Hello {self.name}!'
> pip install plateforme
> plateforme init

What's in Plateforme?

Everything you need to build great backend.

Data modeling made easy

Build production-ready data models and APIs using simple annotations. Relationships and database schema are handled automatically.

Flexible resource inheritance

Let your application handle polymorphic operations naturally through discriminated unions. Use the built-in inheritance configuration to match your data architecture needs.

Type-safe API endpoints

Design nested resource endpoints that enforce type safety at every level. Your API hierarchy grows naturally from your data model, ensuring robust access patterns.

Dynamic API responses

Shape API responses and manipulate your resources with RestX expressive query language to meet your data requirements, offering GraphQL-like capabilities while maintaining REST simplicity.

Schema factory

Define your resource schema once and automatically derive variations. Eliminate repetitive schema declarations across your application endpoints.

Service layer

Extend your resources with custom services to handle complex business logic. From simple CRUD operations to sophisticated workflows, services supercharge your resource capabilities.

Project modularity

Structure your application using shareable packages and flexible namespaces. Deploy reusable components and organize resources efficiently across your application domains.

Fine-grained configuration

Customize every aspect of your application through powerful built-in options, from application-level settings to individual resources and services.

Built-in CLI

Manage your entire project lifecycle through our comprehensive CLI. From initialization to deployment, access powerful commands to streamline your development workflow.

Built on a foundation of Python's
most trusted libraries

Forget boilerplate,
Write only code that matters

Focus on building features that drive value while we handle the technical details.

Data Composition

Use expressive data models

Our framework's data modeling approach lets you focus on your domain logic using familiar Python patterns. Define resources as classes, establish relationships with type hints, and let the framework handle the technical implementation.

It's designed for teams that value clean architecture and maintainable code, making it natural to express complex data relationships while maintaining simplicity.

Type-safe resources: Define your domain objects using standard Python classes and type hints. The framework automatically handles validation, serialization, and database mapping.

Learn more

Relationships made easy: Establish relationships between resources using Python's type system. Let the framework manage indexes, foreign keys, and cascading operations.

Learn more
1from plateforme import BaseResource, ConfigDict, Field
2
3class Material(BaseResource):
4    code: str = Field(unique=True)
5    name: str
6    rocket_parts: list['RocketPart'] = Field(default_factory=list)
7
8class Rocket(BaseResource):
9    code: str = Field(unique=True)
10    name: str
11    parts: list['RocketPart'] = Field(default_factory=list)
12
13class RocketPart(BaseResource):
14    __config__ = ConfigDict(
15        indexes=[{'rocket', 'material'}]
16    )
17    rocket: Rocket
18    material: Material
19    quantity: int
Database Diagram

API Design

Craft powerful endpoints in seconds

Transform your resource methods into fully configurable API endpoints. Use decorators to define routes, customize responses, and leverage all FastAPI capabilities while maintaining clean, focused business logic.

The framework seamlessly handles request parsing, validation, and response serialization, letting you concentrate on what your endpoints should do rather than how to implement them.

Configurable endpoints: Design your endpoints with complete control over validation, responses, and dependencies. All FastAPI's powerful features are available through simple decorators.

Learn more

Enhanced navigation: Build hierarchical endpoints that naturally follow your data structure and relationships. Access nested resources through type-safe, automatically generated URLs.

Learn more
1from plateforme import BaseResource
2from plateforme.api import AsyncSessionDep, route
3from plateforme.database import func, select
4
5class Material(BaseResource):
6    ...
7
8    @route.post()
9    async def update_name(self, name: str) -> str:
10        self.name = name
11        return f'Material name updated to {name!r}.'
12
13    @route.get()
14    @classmethod
15    async def count(cls, session: AsyncSessionDep) -> int:
16        query = select(func.count()).select_from(cls)
17        result = await session.execute(query)
18        return result.scalar()
$curl -X POST http://api.example.com/resources \
-H 'Content-Type: application/json' \
-d '{ "name": "my-resource", "description": "A new resource" }'
{ "id": "123", "name": "my-resource", "description": "A new resource" }
1from plateforme import ConfigDict, CRUDResource
2
3class Rocket(CRUDResource):
4    __config__ = ConfigDict(
5        api_max_depth=1,
6        api_max_selection=10,
7    )
8    ...

API Endpoints

Supercharge your API

Turn your resources into fully-featured REST APIs with a single class inheritance. CRUD resource and service automatically provides a complete set of endpoints with powerful querying capabilities and configurable behavior.

Control your API's behavior through simple configuration options while maintaining security and performance boundaries. The framework handles pagination, field selection, data validation, and much more automatically.

Get started

Available endpoints

Generated from CRUD

GET/rockets
GET/rockets/{rockets_key}
Request
{
  "include": {
    "__all__": { "code": true, "name": true }
  }
}
Response
{
  "code": "FAL-9",
  "name": "Falcon 9"
}
POST/rockets
PATCH/rockets
PATCH/rockets/{rockets_key}
Request
{
  "payload": {
    "code": "F9"
  },
  "include": {
    "__all__": { "code": true, "name": true }
  }
}
Response
{
  "code": "F9",
  "name": "Falcon 9"
}
PUT/rockets
Request
{
  "payload": {
    "code": "ARI-6",
    "name": "Ariane 6",
    "description": "European launch vehicle."
  }
}
Response
[
  {
    "id": 2,
    "type": "rocket",
    "code": "ARI-6",
    "name": "Ariane 6",
    "description": "European launch vehicle.",
    "parts": []
  }
]
DELETE/rockets
DELETE/rockets/{rockets_key}

Write complex queries

Shape API responses and manipulate resources with RestX expressive query language.

READ

Retrieves parts from rocket ID 4 where material codes start with 'NC', returning part IDs, quantities, and material details (code and name).

REQUEST
GET http://localhost:8000/rockets?.parts*.id=3 HTTP/1.1
content-type: application/json

{
  "include": {
    "__all__": {
      "id": true,
      "material": {
        "code": true,
        "name": true
      },
      "quantity": true
    }
  }
}
RESPONSE
[
  {
    "id": 3,
    "material": {
      "code": "NC-150",
      "name": "Nose Cone"
    },
    "quantity": 2
  },
  {
    "id": 4,
    "material": {
      "code": "NC-600",
      "name": "Navigation Computer"
    },
    "quantity": 5
  }
]

CREATE

Adds multiple rockets with nested parts using either material IDs or new material data.

POST http://127.0.0.1:8001/rockets HTTP/1.1
content-type: application/json

{
  "payload": [
    {
      "name": "Atlas V",
      "code": "ATL-6",
      "parts": [
        {
          "material": 3,
          "quantity": 1
        },
        ...
      ]
    },
    {
      "name": "Ariane 6",
      "code": "ARI-6",
      "parts": [
        {
          "material": {
            "name": "Attitude Control System",
            "code": "AC-650"
          },
          "quantity": 2
        },
        ...
      ]
    }
  ]
}

UPDATE

Updates parts list for all rockets with codes containing 'ARI', replacing existing parts with new ones.

PATCH http://127.0.0.1:8001/rockets?.code=like~%ARI% HTTP/1.1
content-type: application/json

{
  "payload": {
    "parts": [
      {
        "material": 1,
        "quantity": 2
      },
      {
        "material": 4,
        "quantity": 1
      }
    ]
  }
}