Compile natural language API descriptions into complete Swift/Vapor backend services with Fluent ORM database integration and async/await routing.
| File / Directory | Purpose |
|---|---|
| Sources/App/Models/ | Fluent model classes with @ID, @Field wrappers |
| Sources/App/Migrations/ | AsyncMigration structs for schema creation |
| Sources/App/Controllers/ | RouteCollection structs with handler methods |
| Sources/App/configure.swift | Database, migrations, and route registration |
| Sources/App/routes.swift | Top-level route definitions |
| Package.swift | Swift Package Manager manifest |
Every generated model is a Fluent Model and Content. The engine generates the corresponding AsyncMigration struct automatically, including prepare(on:) to create the schema and revert(on:) to roll it back. Supported databases include PostgreSQL, MySQL, and SQLite.
The engine recognizes phrases like "requires authentication" or "protected" and applies Vapor's UserToken.authenticator() middleware to those routes. Public routes are grouped separately and require no token.
| Field | Type | Value / Default | Modifier |
|---|---|---|---|
| id | UUID | @ID(key: .id) | Fluent primary key |
| title | String | required | @Field(key: "title") |
| completed | Bool | default: false | @Field(key: "completed") |
| GET /todos | route | list all | async throws |
| POST /todos | route | create | async throws |
// Sources/App/Models/Todo.swift
import Vapor
import Fluent
final class Todo: Model, Content {
static let schema = "todos"
@ID(key: .id)
var id: UUID?
@Field(key: "title")
var title: String
@Field(key: "completed")
var completed: Bool
init() {}
init(id: UUID? = nil, title: String, completed: Bool = false) {
self.id = id; self.title = title; self.completed = completed
}
}
// Sources/App/Controllers/TodoController.swift
import Vapor
struct TodoController: RouteCollection {
func boot(routes: RoutesBuilder) throws {
let todos = routes.grouped("todos")
todos.get(use: list)
todos.post(use: create)
}
func list(req: Request) async throws -> [Todo] {
try await Todo.query(on: req.db).all()
}
func create(req: Request) async throws -> Todo {
let todo = try req.content.decode(Todo.self)
try await todo.save(on: req.db)
return todo
}
}