Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.prism.byescaleira.com/llms.txt

Use this file to discover all available pages before exploring further.

What is Prism?

Prism is a server-side Swift framework that does something no other framework does: it ships with zero third-party dependencies. Every feature — from HTTP routing to WebSocket support, from SQLite databases to GraphQL engines — is built entirely on Apple’s own frameworks: Network.framework, Foundation, SQLite3, CryptoKit, and Compression. This isn’t a toy. Prism includes 36+ production-ready modules covering everything you need to build modern server applications.
Hello World in Prism
import PrismServer

let server = PrismHTTPServer(port: 8080)

await server.get("/") { request in
    .json(["message": "Hello, Prism!"])
}

await server.get("/users/:id") { request in
    let id = request.parameters["id"]!
    .json(["id": id, "name": "Alice"])
}

try await server.start()
That’s a running HTTP server. No configuration files, no boilerplate, no dependency resolution. Just Swift.

Why Prism?

Zero Dependencies

No SwiftNIO, no AsyncHTTPClient, no third-party anything. Your Package.resolved stays clean. Your builds stay fast. Your attack surface stays small.

Swift 6.3 Native

Built from the ground up with strict concurrency. Actors, Sendable, structured concurrency — not retrofitted, but designed for it.

Batteries Included

36+ modules out of the box. Database, sessions, GraphQL, MCP, WebSocket rooms, cron jobs, file uploads — all native.

How does Prism compare?

FeaturePrismVaporHummingbird
Third-party deps020+10+
HTTP layerNetwork.frameworkSwiftNIOSwiftNIO
DatabaseBuilt-in SQLiteFluent (separate)Custom
GraphQLBuilt-inThird-partyThird-party
MCP ServerBuilt-inNoneNone
WebSocket RoomsBuilt-inThird-partyManual
Swift 6 concurrencyNative actorsPartialPartial
Prism doesn’t compete with Vapor on ecosystem size. It competes on simplicity, control, and zero-dependency builds. If you want a framework where you understand every line of code running in production, Prism is built for you.

Key Features

Prism organizes its features into focused modules that work together seamlessly:
Full HTTP/1.1 server on Network.framework. Pattern-based routing with :params and * wildcards. Route groups with shared prefixes and middleware. Support for all HTTP methods.
CORS, logging, authentication, rate limiting, compression, request tracing, API versioning, lifecycle hooks — all built-in. Stack them declaratively.
SQLite via the C API. Query builder, model protocol with CRUD, migrations, connection pooling, and relationship queries (hasMany, belongsTo, hasOne).
WebSocket with RFC 6455 compliance. Named rooms with join/leave/broadcast. Server-Sent Events. Actor-based event bus with typed pub/sub.
Schema DSL, recursive descent parser, field-level resolvers, introspection, and an embedded GraphiQL playground. No third-party GraphQL libraries.
Model Context Protocol implementation with JSON-RPC 2.0. Register tools, resources, and prompts. Stdio and HTTP/SSE transports.
Environment config with .env files. Health checks and metrics endpoints. Cron scheduler. Background task manager. Graceful shutdown. Multi-process cluster mode.
TLS via Network.framework. HMAC-SHA256 signed sessions. Input validation with 14 built-in rules. HSTS and security headers. Bearer token authentication.

A Real Example

Here’s a more realistic API — a task manager with database, authentication, and validation:
Task Manager API
import PrismServer

let server = PrismHTTPServer(port: 8080)
let db = try PrismDatabase(path: "tasks.db")

// Run migrations
let migrator = PrismMigrator(database: db)
try await migrator.migrate([
    PrismMigration(
        name: "create_tasks",
        up: "CREATE TABLE tasks (id INTEGER PRIMARY KEY, title TEXT NOT NULL, done INTEGER DEFAULT 0)",
        down: "DROP TABLE tasks"
    )
])

// Global middleware
await server.use(PrismCORSMiddleware())
await server.use(PrismLoggingMiddleware())
await server.use(PrismErrorMiddleware(includeStackTrace: true))

// List tasks
await server.get("/tasks") { request in
    let rows = try await db.query("SELECT * FROM tasks")
    let tasks = rows.map { row in
        ["id": row["id"], "title": row["title"], "done": row["done"]]
    }
    return .json(tasks)
}

// Create task with validation
await server.post("/tasks") { request in
    let result = request.validateJSON { v in
        v.field("title", .required, .minLength(1), .maxLength(200))
    }
    if let error = result.errorResponse() { return error }

    let title = request.formData["title"] ?? ""
    let changes = try await db.execute(
        "INSERT INTO tasks (title) VALUES (?)",
        parameters: [.text(title)]
    )
    return .json(["created": true], status: .created)
}

// Toggle task completion
await server.patch("/tasks/:id") { request in
    let id = request.parameters["id"]!
    try await db.execute(
        "UPDATE tasks SET done = NOT done WHERE id = ?",
        parameters: [.text(id)]
    )
    return .json(["updated": true])
}

try await server.start()

What Can You Build?

REST APIs

JSON APIs with routing, validation, authentication, rate limiting, and database persistence. Full CRUD in minutes.

Real-Time Apps

Chat applications, live dashboards, collaborative tools — using WebSocket rooms, SSE, and the event bus.

GraphQL Servers

Define schemas, write resolvers, and serve a GraphQL playground — all without leaving Swift.

AI Tool Servers (MCP)

Build MCP-compatible servers that expose tools, resources, and prompts to AI assistants like Claude.

Microservices

Lightweight services with health checks, metrics, tracing, and cluster mode for horizontal scaling.

Full-Stack Swift

Server-rendered HTML with the template engine, static file serving, and session management.

Next Steps

1

Install Prism

Add Prism to your Swift package and start building. Installation guide →
2

Build Your First API

Follow the quickstart tutorial to build a REST API from scratch. Quickstart →
3

Explore Features

Dive into specific features like GraphQL, WebSockets, or Database.