Schema-driven Python framework

Draft the schema.
Ship the API.

tamilPY reads one schema.tpy file and generates a fully layered FastAPI app — models, migrations, services, and routes — for SQLite, PostgreSQL, MySQL, or MongoDB. You write the fields. It writes the plumbing.

Where it fits

Use cases

Built for developers who'd rather write a schema once than write the same CRUD boilerplate again.

Speed

Startup MVPs

Turn one schema file into a running API in minutes, before the idea gets cold.

Consistency

Internal tools

Every project gets the same models, migrations, services, and routes — no drift between teams.

Learning

Learning FastAPI

Read a clean, layered architecture: repository → service → controller → route, generated in the open.

Flexibility

Multi-database apps

Pick SQLite, PostgreSQL, MySQL, or MongoDB at build time. Switch later with one command.

Getting started

Install

Install from PyPI, then scaffold your first project.

$ pip install tamilPY
$ tpy new myapp
$ cd myapp

Revision 01

The build sequence

The exact path an application developer follows, start to serve.

01SCOPE

Create the app

tpy new myapp scaffolds folders, schema.tpy, the logger, and seed files.

02DRAFT

Edit the schema

Define models and fields in schema.tpy — types, primary keys, required, unique.

03BUILD

Build & choose database

tpy build asks for SQLite, PostgreSQL, MySQL, or MongoDB, then host, port, user, and password — and writes .env for you.

04APPLY

Migrate + seed

Run tpy migrate, then tpy seed, to apply the schema and load sample data.

05SERVE

Serve the API

tpy serve starts FastAPI. Logs stream to the console and to storage/logs/app.log.

Capability map

What tamilPY gives you

One schema file drives generation, migrations, and a layered FastAPI app.

Feature 01

Schema-first generation

Edit schema.tpy, run tpy build or tpy crud, and get models, migrations, schemas, repositories, services, controllers, and routes.

Feature 02

Multi-database

SQLite, PostgreSQL, MySQL, or MongoDB via the build wizard. Reconfigure anytime with tpy db configure.

Feature 03

Auto database create

tpy migrate creates the Postgres/MySQL database when missing, then applies ordered migrations.

Feature 04

Full CRUD REST API

Each model gets list, show, create, update, and delete endpoints under a plural prefix (e.g. /users).

Feature 05

Layered architecture

Repository → Service → Controller → Route — generated consistently so every project looks the same.

Feature 06

Migrate · seed · serve

Apply schema with migrations, load sample data with seeders, run the API with tpy serve or python main.py.

Feature 07

Logging & health

Console + storage/logs/app.log via app/logger.py. Probe liveness with GET /health.

Feature 08

React admin dashboard

tpy admin generates a Vite + React dashboard in admin/ with list, create, edit, and delete for every schema model. See screenshots →

Feature 09

JWT auth

tpy auth adds login, register, refresh, and logout with AuthRole + User defaults. Dashboard access is limited to super-admin and developer. See auth guide →

Feature 10

Doctor & DB tools

tpy doctor checks project files. tpy db info / tpy db ping inspect and test the connection.

Generated UI

React admin dashboard

Run tpy admin (or tpy build --with-ui) to generate a Vite + React dashboard in admin/ — list, create, edit, and delete for every model in schema.tpy.

$ tpy serve
$ tpy admin
$ cd admin && npm install && npm run dev

API at http://127.0.0.1:8000 · Admin UI at http://127.0.0.1:5173

TPY Admin — User list page with table and New User action
01 · List Browse records in a data table
TPY Admin — New User create form
02 · Create Add a record from a generated form
TPY Admin — Edit User form with Save changes
03 · Edit Update fields and save changes
TPY Admin — Delete confirmation dialog on User list
04 · Delete Confirm and remove a record
Generated

From one schema

src/data/models.js is built from schema.tpy. Shared list and form pages cover every model — no hand-written page per entity.

Stack

Vite + React

Modern SPA under admin/ with Layout, DataTable, and RecordForm components wired to your FastAPI CRUD routes.

Refresh

Re-run anytime

After schema changes, run tpy admin again to regenerate the dashboard so the UI stays in sync with your models. With tpy auth enabled, the UI includes login and role checks.

Security

JWT authentication

Run tpy auth for Django-style auth: default AuthRole + User, JWT access + refresh tokens, and an admin login gate.

$ tpy auth
$ pip install -r requirements.txt
$ tpy migrate && tpy seed
$ tpy serve
$ tpy admin

Default login: admin@example.com / admin123 (super-admin)

Schema

Default tables

  • AuthRole — super-admin, admin, developer
  • User — name, email, password (hashed), role_id
API

Auth endpoints

  • POST /auth/register
  • POST /auth/login — access + refresh
  • POST /auth/refresh
  • POST /auth/logout
  • GET /auth/me
Roles

Dashboard access

super-admin and developer can open the React admin UI. The admin role is API-only.

Tokens

Access + refresh

Short-lived access JWT (default 15m) plus long-lived refresh JWT (default 7d). Logout revokes the refresh token server-side.

Language reference

schema.tpy patterns

Types, constraints, defaults, indexes, foreign keys, and multi-model examples.

Shape

File structure

# optional provider line
database postgres

model ModelName {
  field: type constraint...
}

Use # for comments. Keywords are case-insensitive.

Types

Field types

  • int — integer
  • string — text / VARCHAR
  • float — floating point
  • bool — boolean
  • uuid — UUID primary keys
  • datetime — timestamp
Constraints

Field constraints

  • primary — primary key
  • required — required in create API
  • unique — UNIQUE column
  • nullable — allow NULL / optional
  • index — create an index
  • default <value> — column default
  • references <Model> — foreign key

Non-primary fields without nullable become NOT NULL in SQL.

Providers

database line

  • database sqlite
  • database postgres
  • database mysql
  • database mongodb

Usually written for you by tpy build / tpy db configure.

Examples

Copy-paste schemas

Start from these patterns, then run tpy crud.

# 01 — starter User
database sqlite

model User {
  id: uuid primary
  name: string required
  email: string unique required
  age: int
}
# 02 — defaults + index
database postgres

model Product {
  id: uuid primary
  title: string required index
  price: float required
  active: bool default true
  stock: int default 0
  status: string default "draft"
  notes: string nullable
  created_at: datetime nullable
}
# 03 — foreign keys (references)
database postgres

model User {
  id: uuid primary
  email: string unique required
}

model Post {
  id: uuid primary
  title: string required index
  body: string nullable
  user_id: uuid references User
  published: bool default false
}
Relations

Foreign keys

Use references <Model> (or foreign <Model>) on a field. It defaults to the target's id; target a column with references Model.column.

user_id: uuid references User
author: uuid references User.id

Compiles to REFERENCES "user" ("id"). Define the referenced model earlier in the schema so its migration runs first.

Defaults

Default values

Add default <value> — a number, quoted string, or true / false.

stock: int default 0
active: bool default true
status: string default "draft"

Fields with a default become optional in the create API.

Indexes

Column index

Add the index keyword to generate an index:

title: string required index

Emits CREATE INDEX idx_<table>_<column>. Primary keys are already indexed.

Migrations

File naming

Generated as ordered files from model order in the schema:

  • 001_user_migration.py
  • 002_post_migration.py
API shape

Routes from a model

Model User → prefix /users:

  • GET /users/
  • GET /users/{id}
  • POST /users/
  • PUT /users/{id}
  • DELETE /users/{id}

CLI reference

All commands

Full client command surface — including helpers that are easy to miss.

Project

Scaffold & generate

  • tpy new <name> — create project
  • tpy build — DB wizard + generate CRUD
  • tpy build --skip-db — generate using existing .env
  • tpy build --with-ui — generate CRUD and admin/
  • tpy crud — regenerate layers from schema only
  • tpy admin — generate the React admin dashboard
  • tpy auth — JWT auth, AuthRole + User, role seeds
  • tpy doctor — validate project files
  • tpy version — show framework version
Database

Configure & inspect

  • tpy db configure — interactive DB wizard
  • tpy db info — show provider + URL
  • tpy db ping — test connection
Migrate

Schema apply

  • tpy migrate — create DB if needed + apply pending
  • tpy migrate up — same as migrate
  • tpy migrate rollback — undo latest
  • tpy migrate status — list applied migrations
  • tpy seed — run database/seeds
Runtime

Serve the API

  • tpy serve — uvicorn on app.main:app
  • tpy serve --host 0.0.0.0
  • tpy serve --port 8080
  • tpy serve --reload / --no-reload
  • python main.py — root launcher
  • GET /health — health check

Output map

What gets generated

After tpy build / tpy crud, each model produces this backend stack. Add tpy admin for the generated React dashboard.

01MODEL

app/models/<name>.py

Pydantic model of your fields.

02MIGRATE

database/migrations/NNN_<name>_migration.py

Ordered up / down table migration.

03SCHEMA

app/schemas/<name>.py

Create, Update, and Response request/response models.

04REPO

app/repositories/<name>.py

SQL data access: all, find, create, update, delete.

05SERVICE

app/services/<name>.py

Thin business layer over the repository.

06HTTP

app/controllers + app/routes

FastAPI handlers and routers wired into app/main.py.

Scaffold

Project layout

Created by tpy new myapp.

myapp/
  main.py                 # uvicorn launcher → app.main:app
  schema.tpy
  tpy.toml
  .env
  app/
    main.py               # FastAPI app + /health
    logger.py
    models/  schemas/  repositories/
    services/  controllers/  routes/
    providers/database.py
  database/
    migrations/           # 001_user_migration.py …
    seeds/
  storage/logs/
  admin/                  # Vite + React dashboard from tpy admin
  tests/

Reference sheet

Useful guide

The commands you'll reach for every day.

Sheet 01

Project

  • tpy new <name> — create project
  • tpy build — DB wizard + generate CRUD
  • tpy build --skip-db — use existing .env
  • tpy crud — regenerate CRUD from schema
  • tpy admin — generate React admin UI
  • tpy auth — enable JWT auth
  • tpy doctor — validate project health
Sheet 02

Database

  • tpy db configure — change DB anytime
  • tpy db info — show provider + URL
  • tpy db ping — test connection
  • tpy migrate — create DB if needed + migrate
  • tpy migrate rollback — undo latest
  • tpy migrate status — list applied
  • tpy seed — run database/seeds
Sheet 03

Runtime

  • tpy serve — start API server
  • python main.py — root launcher
  • app/logger.py — client logger
  • storage/logs/app.log — log file
  • /health — health endpoint
  • /docs — Swagger UI
Sheet 04

Example schema

model User {
  id: uuid primary
  name: string required
  email: string unique
  age: int
}

More patterns → Schema section

Spec plate

Author

The person behind tamilPY.

Selvaganapathi Arumugam

Selvaganapathi Arumugam

SOFTWARE DEVELOPER — CREATOR, TAMILPY

Builds tamilPY (TPY Framework), focused on practical developer experience, clean layered architecture, and schema-first application generation.

→ View portfolio