Single Source of Truth - Generating ORM, REST, GQL, MCP, SDK and Tests from Pydantic

2 weeks ago 20

What My Project Does

I built an extensible AGPL-3.0 Python server framework on FastAPI and SQLAlchemy after getting sick of writing the same thing 4+ times in different ways. It takes your Pydantic models and automatically generates:

  • The ORM models with relationships
  • The migrations
  • FastAPI REST endpoints (CRUD - including batch, with relationship navigation and field specifiers)
  • GraphQL schema via Strawberry (including nested relationships)
  • MCP (Model Context Protocol) integration
  • SDK for other projects
  • Pytest tests for all of the above
  • Coming Soon: External API federation from third-party APIs directly into your models (including into the GQL schema) - early preview screenshot

Target Audience

Anyone who's also tired of writing the same thing 4 different ways and wants to ship ASAP.

Comparison

Most tools solve one piece of this problem:

  • SQLModel generates SQLAlchemy models from Pydantic but doesn't handle REST/GraphQL/tests
  • Strawberry/Graphene Extensions generate GraphQL schemas but require separate REST endpoints and ORM definitions
  • FastAPI-utils/FastAPI-CRUD generate REST endpoints but require manual GraphQL and testing setup
  • Hasura/PostGraphile auto-generate GraphQL from databases but aren't Python-native and don't integrate with your existing Pydantic models

This framework generates all of it - ORM, REST, GraphQL, SDK, and tests - from a single Pydantic definition. The API federation feature also lets you integrate external APIs (Stripe, etc.) directly into your generated GraphQL schema, which most alternatives can't do.

Links

Documentation available on GitHub and well-organized through Obsidian after cloning: https://github.com/JamesonRGrieve/ServerFramework

I also built a NextJS companion front end that's designed to be similarly extensible.

https://github.com/JamesonRGrieve/ClientFramework

Feedback and contributions welcome!

submitted by /u/ZephyrWarrior to r/Python
[link] [comments]
Read Entire Article