What is Teo?

This article gives a high-level overview of what Teo is and how it works.

If you want to get started with a practical introduction and learn about writing Teo server and generate clients, head over to the Getting started documentation.

To learn more about the motivation for Teo, check out the Why Teo? page.

What is Teo?

Teo is a schema-centered web server framework. It consists of the following parts:

  • Teo schema: Intuitive and innovative schema language which is descriptive and readable
  • Teo server: A high performance core written in Rust and API bindings for Node.js, Python and Rust
  • Teo CLI: A CLI tool that reads schema and perform jobs including database migration, running server and seeding data
  • Teo query client: Auto-generated type-safe query builder for multiple platforms and languages

How does Teo work?

Like any other web server frameworks, developers write code, start server and deploy. What is unique to Teo is most of the coding can be done with the intuitive schema language. For features Teo schema language doesn't provide, Teo allows developers to generate ORM model entities, write custom code and route handlers in backend languages.

Teo schema

Developers declare configurations, enums and models all within these schema files. These files can be splitted and included. Here is an example of a minimalist Teo schema.

schema.teo
connector {
  provider: .mysql,
  url: "mysql://127.0.0.1:3306/hello"
}
 
server {
  bind: ("0.0.0.0", 5001)
}
 
client ts {
  provider: .typeScript,
  dest: "../hello-client/"
  package: true,
  host: .string("http://127.0.0.1:5001"),
  gitCommit: true
}
 
model User {
  @id @autoIncrement @readonly
  id: Int
  @unique @onSet($if($presents, $isEmail))
  email: String
  name: String?
}

With this schema, Teo synthesizes HTTP request handlers for the model entity User. When server is running, the frontend apps can send request to create, update, delete and read users.

Teo server

Developers can declare custom route handlers in the schema and implement it with server code. Ruby, Node.js and Python are supported.

schema.teo
interface EmptyInput { }
 
interface HelloOutput {
  hello: String
}
 
declare handler hello(EmptyInput): HelloOutput

Depending on the server side programming language that you choose, the implementation to the handler declared above is implemented in below.

src/main.rs
app.main_namespace().define_handler("hello", || async move {
  Ok(Response::data(teon!({ "hello": "world!" })))
});

Teo query client

Teo cares about developer experience. Instead of copy and paste data access objects into different frontend projects, Teo generate for us. For example, to access the aforementioned User model, with TypeScript client, we can do:

const createResult = await teo.user.create({
  create: {
    email: "ada2@teodev.io",
    name: "Ada",
  }
})
console.log(createResult.data)

Teo query client is type-safe and smart.

Typical Teo workflows

Teo simplifies the backend server development. Normally developers update schemas and generate query clients. If custom code is required, generate model entities and write custom logic with one of the backend programming languages that Teo supports. On server start, database migration is automatically performed. You can also trigger migration by its own command. Teo web server is performant, and reliable.