https://github.com/plateformeio/plateforme
The Python framework for Data Applications
https://github.com/plateformeio/plateforme
api app asgi async data db fastapi plateforme pydantic python restx services sqlalchemy
Last synced: about 2 months ago
JSON representation
The Python framework for Data Applications
- Host: GitHub
- URL: https://github.com/plateformeio/plateforme
- Owner: plateformeio
- License: mit
- Created: 2024-05-19T21:51:36.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2025-02-21T05:40:27.000Z (2 months ago)
- Last Synced: 2025-02-21T06:27:34.518Z (2 months ago)
- Topics: api, app, asgi, async, data, db, fastapi, plateforme, pydantic, python, restx, services, sqlalchemy
- Language: Python
- Homepage: https://plateforme.io
- Size: 833 KB
- Stars: 5
- Watchers: 0
- Forks: 0
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
- Security: SECURITY.md
- Roadmap: ROADMAP.md
Awesome Lists containing this project
README
# Plateforme Core - OSS (alpha release)
[](https://github.com/plateformeio/plateforme/actions?query=event%3Apush+branch%3Amain+workflow%3Aci)
[](https://pypi.python.org/pypi/plateforme)
[](https://pepy.tech/project/plateforme)
[](https://github.com/plateformeio/plateforme)
[](https://github.com/plateformeio/plateforme/blob/main/LICENSE)Plateforme enables you to build and deploy modern data-driven applications and services in seconds with the power of [SQLAlchemy](https://github.com/sqlalchemy/sqlalchemy), [Pydantic](https://github.com/plateforme/plateforme), and [FastAPI](https://github.com/tiangolo/fastapi).
## Help
See the [documentation](https://docs.plateforme.io) for more details.
## Installation
Install using `pip install -U plateforme` or `conda install plateforme -c conda-forge`.
For more details and advanced installation options, see the [installation guide](https://docs.plateforme.io/latest/start/install) from the official documentation site.
## A basic example
### Create a simple application
```python
from typing import Selffrom plateforme import Plateforme
from plateforme.api import route
from plateforme.resources import ConfigDict, CRUDResource, Fieldapp = Plateforme(debug=True, database_engines='plateforme.db')
class Rocket(CRUDResource):
code: str = Field(unique=True)
name: str
parts: list['RocketPart'] = Field(default_factory=list)
launched: bool = False@route.post()
async def launch(self) -> Self:
self.launched = True
return selfclass RocketPart(CRUDResource):
__config__ = ConfigDict(indexes=[{'rocket', 'code'}])
rocket: Rocket
code: str
quantity: int
```### Validate and use data
```python
some_data = {
'code': 'FAL-9',
'name': 'Falcon 9',
'parts': [
{'code': 'dragon', 'quantity': 1},
{'code': 'raptor', 'quantity': 9},
{'code': 'tank', 'quantity': 1},
],
}rocket = Rocket.resource_validate(some_data)
print(repr(rocket))
#> Rocket(code='FAL-9')print(repr(rocket.parts[0].code))
#> 'dragon'
```### Persist data
```python
# Create the database schema
app.metadata.create_all()# Persist the data
with app.session() as session:
session.add(rocket)
session.commit()# Query the data
with app.session() as session:
rocket = session.query(Rocket).filter_by(code='FAL-9').one()print(repr(rocket))
#> Rocket(id=1, code='FAL-9')
```### Run the application
```bash
uvicorn main:app
```### Play with the API
#### Use the built-in CRUD and query engine
With the built-in CRUD and query engine, you can easily create, read, update, and delete resources. The following query finds all parts in rocket `#1` whose part codes contain the sequence `ra`.
```http
GET http://localhost:8000/rockets/1/parts?.code=like~*ra* HTTP/1.1
``````json
[
{
"id": 1,
"type": "rocket_part",
"code": "dragon",
"quantity": 1
},
{
"id": 2,
"type": "rocket_part",
"code": "raptor",
"quantity": 9
}
]
```#### Use custom routes
You can also define custom routes to perform more complex operations. The following request launches rocket `#1` and persists in the database the `launched` flag to `true`.
```http
POST http://localhost:8000/rockets/1/launch HTTP/1.1
``````json
{
"id": 1,
"type": "rocket",
"code": "FAL-9",
"name": "Falcon 9",
"parts": [
...
],
"launched": true
}
```### Use the built-in CLI
Plateforme comes with a built-in CLI to help you automate common tasks. For instance, the following commands initialize a new project, build it, and start the server.
```bash
# Initialize the project
plateforme init# Build the project
plateforme build# Start the server
plateforme start --reload
```For detailed documentation and more examples, see the [official documentation](https://docs.plateforme.io/latest/start).
## Contributing
For guidance on setting up a development environment and how to make a contribution to Plateforme, read the [contributing guidelines](https://docs.plateforme.io/latest/about/community/contributing) from the official documentation site.
## Reporting a security vulnerability
See our [security policy](https://github.com/plateformeio/plateforme/security/policy).