Schema-driven Python framework · v0.1.10

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. v0.1.10 adds tpy studio, starter templates, incremental make:* commands, and shared schema serialize/validate.

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
$ pip install "tamilPY[redis]"    # optional
$ pip install "tamilPY[all]"      # all drivers
$ 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.

Read guide →
Feature 02

Multi-database

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

Read guide →
Feature 03

Auto database create

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

Read guide →
Feature 04

Full CRUD REST API

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

Read guide →
Feature 05

Layered architecture

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

Read guide →
Feature 06

Migrate · seed · serve

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

Read guide →
Feature 07

Logging & health

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

Read guide →
Feature 08

React admin dashboard

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

Read guide →
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.

Read guide →
Feature 10

Doctor & DB tools

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

Read guide →
01–02

Query & relations

Fluent QueryBuilder. Schema relations { } with eager with_() loading.

Read guide →
03–05

Events · Queue · Schedule

Sync event bus, background jobs (tpy queue work), cron-style tpy schedule run.

Read guide →
06–08

Cache · API · Validation

Memory / file / Redis cache. ApiResponse envelopes. Pipe-rule validate().

Read guide →
09–13

Kernel · Middleware · Health

Application providers & plugins, middleware groups, /health, lifecycle hooks.

Read guide →
14–17

Log · Config · Storage · Routes

Log channels, nested Config, file storage, tpy route cache.

Read guide →
18–20

Optimize · CLI · Watch

tpy optimize, richer CLI (-V, about), tpy watch rebuild on schema change.

Read guide →

Runtime platform

API reference & DX guides

Runtime platform (Query Builder through watch) plus v0.1.10 Studio, templates, and make commands.

DX · 0.1.10

Studio visual builder

tpy studio
# http://127.0.0.1:4200 — schema · DB · auth · build SSE

Local UI with preview/diff before writing schema.tpy. No end-user npm required.

Read guide →
DX · 0.1.10

Starter templates

tpy new myapp --template crm
tpy templates list
tpy admin --template crm

crm · institute-admin · inventory · helpdesk · blog-cms with admin themes.

Read guide →
DX · 0.1.10

make:model · controller · service

tpy make:model Invoice --fields "amount:float,status:enum(draft,paid)"
tpy make:service Invoice --force

Incremental generation + # tpy:generated:sha256: markers.

Read guide →
Query

Query Builder & relations

repo.query().where("status", "draft").order_by("created_at").get()
repo.query().with_("author").find(id)

Schema relations { belongs_to User as author via user_id }. Eager load with with_().

Read guide →
Events

Event & Listener

bus = EventDispatcher()
bus.listen(OrderPlaced, LogOrder())
bus.dispatch(OrderPlaced("ord_1"))

listen · dispatch · dispatch_until · wildcard "*" · event.stop().

Read guide →
Queue

Background jobs

Queue(SyncQueueDriver()).push(SendWelcomeEmail("u1"))
# CLI: tpy queue table | tpy queue work --driver database

Drivers: sync, database, redis (tamilPY[redis]).

Read guide →
Schedule

Task scheduler

# app/schedule.py
def register(schedule):
    schedule.command("cache:clear").daily()
# CLI: tpy schedule run | list

Cron helpers, overlap locks, due-task runner.

Read guide →
Cache

Cache manager

cache.put("key", value, ttl=60)
cache.get("key", default=None)
# CLI: tpy cache clear

Stores: memory, file (storage/framework/cache), Redis.

Read guide →
HTTP

ApiResponse

return ApiResponse.success(data)
return ApiResponse.created(row)
return ApiResponse.paginated(items, meta)
return ApiResponse.validation_error(exc)

Uniform JSON envelopes for FastAPI controllers.

Read guide →
Validation

Pipe rules

data = validate(payload, {
  "email": "required|email",
  "age": "required|integer|min:18",
  "role": "nullable|in:admin,user",
})

Custom rules via Validator.extend(...).

Read guide →
Kernel

Application · Providers · Plugins

Application(".").register(AppServiceProvider).create()
# or Application(".").mount(existing_fastapi)

Container make() / singleton(). Entry-point plugins supported.

Read guide →
HTTP

Middleware · Health · Lifecycle

  • Middleware groups via MiddlewareManager
  • GET /health · GET /health/ready
  • boot / shutdown / before / after / exception hooks
Read guide →
Ops

Logging & Config

get_logger("app").info("booted")
cfg = Config.load_auto(".")
cfg.get("app.name")
# tpy config show | cache | status | clear

Prefer cache with TPY_CONFIG_CACHE=1.

Read guide →
Storage

Files & route cache

Storage.disk("local").put("a.txt", b"hi")
# tpy route cache | list --cached | clear
# tpy optimize   # config + routes

Local disk + S3-ready driver surface.

Read guide →
DX

CLI UX & Watch

tpy -V
tpy about
tpy commands
tpy watch                 # rebuild on schema.tpy change
tpy watch --with-db

Pair with tpy serve --reload in a second terminal.

Read guide →

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 & ORM

Use references <Model> on a field. Optional relations { } for eager loading:

user_id: uuid references User
relations {
  belongs_to User as author via user_id
  has_many Comment as comments
}

Define referenced models earlier so migrations run in order.

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 new <name> --template <t> — starter schema
  • tpy templates list | show
  • tpy studio — visual builder (:4200)
  • tpy build — DB wizard + generate CRUD
  • tpy build --skip-db — generate using existing .env
  • tpy build --with-ui — generate CRUD and admin/
  • tpy make:model | make:controller | make:service
  • tpy crud — regenerate layers from schema only
  • tpy admin [--template] — 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
Platform

Queue · Schedule · Cache

  • tpy queue table — create job tables
  • tpy queue work — run worker
  • tpy schedule run — run due tasks
  • tpy schedule list — list schedule
  • tpy cache clear — flush cache
Platform

Config · Routes · Optimize

  • tpy config show | cache | status | clear
  • tpy route cache | list | clear
  • tpy optimize — config + route cache
  • tpy watch — rebuild on schema change
  • tpy about · tpy commands · tpy -V

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
  • tpy watch — rebuild on schema change
  • tpy optimize — production caches
  • storage/logs/app.log — log file
  • /health · /health/ready
  • /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