Documentation

Get Started with Schema2AI

Complete guide to building schema-driven APIs for greenfield and brownfield projects

Quick Start: Greenfield

Start a new project from scratch

greenfield-quickstart.shbash
# 1. Create your schema.mmd
cat > schema.mmd << 'EOF'
erDiagram
    User {
        String username  %% @validate { required: true }, @unique
        String email     %% @validate { required: true }, @unique
        String password  %% @validate { required: true, min_length: 8 }
        
        %% @ui { title: "Users", icon: "fa-user" }
    }
EOF

# 2. Generate the server
s2ai-builder --schema schema.mmd --output ./server

# 3. Deploy the server
cd server && python -m uvicorn main:app --host 0.0.0.0 --port 5000

# 4. Launch the UI
s2ai-face --server http://localhost:5000

Best For

  • • New projects
  • • Prototypes & MVPs
  • • Schema-first design

Time to First API

~5 minutes

From schema to deployment

Quick Start: Brownfield

Work with existing databases

brownfield-quickstart.shbash
# 1. Extract schema from existing database
s2ai-import --db mongodb://localhost:27017/mydb --output schema.mmd

# 2. Review and refine the generated schema
vim schema.mmd

# 3. Generate the server
s2ai-builder --schema schema.mmd --output ./server

# 4. Deploy the server
cd server && python -m uvicorn main:app --host 0.0.0.0 --port 5000

# 5. Launch the UI
s2ai-face --server http://localhost:5000

Best For

  • • Legacy systems
  • • Existing databases
  • • API modernization

Supported Databases

  • • MongoDB
  • • PostgreSQL
  • • MySQL
  • • SQLite
  • • Elasticsearch

Schema Syntax Guide

Comprehensive example showing all schema.mmd features

schema.mmdmermaid
erDiagram
    User {
        String username          %% @validate { required: true, min_length: 3 }, @unique
        String email             %% @validate { required: true, pattern: { regex: "email" } }, @unique
        String password          %% @validate { required: true, min_length: 8 } @ui { display: "secret" }
        Boolean isActive         %% @validate { default: true }
        ObjectId roleId
        
        %% @ui { title: "Users", icon: "fa-user", iconColor: "#3498db" }
        %% @service { authn: { provider: "cookies.redis", route: "login/user" } }
    }
    
    Role {
        String role              %% @validate { required: true } @unique
        Json permissions         %% @validate { required: true }
        
        %% @service { authz: { provider: "rbac" } }
        %% @ui { title: "Roles", icon: "fa-shield" }
    }
    
    Role ||--o{ User: "has"

@validate

Define field requirements, formats, and constraints

@ui

Control field display in s2ai.face

@service

Configure authentication and authorization

Relationships

Define entity relationships with ER syntax

Complete Documentation

Explore detailed guides for each component of the ecosystem

Getting Started

Quick introduction to Schema2AI concepts and workflow

s2ai.import

Extract schemas from existing databases (Brownfield)

s2ai.builder

Generate complete server from schema

Schema Syntax

Complete reference for schema.mmd format

Installation

Get started with Schema2AI in minutes

Install via pip

pip install schema2ai-builder schema2ai-import schema2ai-face schema2ai-genius

Prerequisites

  • • Python 3.8 or higher
  • • Node.js 16+ (for s2ai.face)
  • • Database server (optional, for brownfield)