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.
Installation
Prism is distributed as a Swift package. No Homebrew formulas, no CocoaPods, no extra tooling — just add it to your Package.swift.
Requirements
Requirement Minimum Swift 6.0+ macOS 14.0+ (Sonoma) Linux Not currently supported (Network.framework is Apple-only) Xcode 16.0+ (optional, for IDE support)
Prism uses Apple’s Network.framework for its TCP layer, which means it currently runs on macOS only . Linux support via raw sockets is on the roadmap.
Swift Package Manager
Add Prism as a dependency in your Package.swift:
// swift-tools-version: 6.0
import PackageDescription
let package = Package (
name : "my-server" ,
platforms : [. macOS (. v14 )],
dependencies : [
. package ( url : "https://github.com/byescaleira/prism.git" , from : "4.4.0" )
],
targets : [
. executableTarget (
name : "my-server" ,
dependencies : [
. product ( name : "PrismServer" , package : "prism" )
]
)
]
)
Then build:
Pin to a specific version for production stability: .package(url: "...", exact: "4.4.0"). Use from: for automatic minor/patch updates.
Available Products
Prism is a monorepo with multiple library products. You only need to import what you use:
Product What it includes PrismServerThe full server framework — HTTP, routing, middleware, database, WebSocket, GraphQL, MCP, and all 36+ modules PrismFoundationCore utilities shared across all Prism modules (logging, extensions, protocols)
For server development, you’ll almost always want PrismServer — it includes everything.
Project Scaffolding
Prism includes a built-in project generator that creates a production-ready project structure for you:
import PrismServer
// Generate a complete project
try PrismServerScaffold. generate (
name : "my-api" ,
directory : "./my-api"
)
This creates:
my-api/
Package.swift # Pre-configured with Prism dependency
Sources/
main.swift # Server with example routes
Dockerfile # Multi-stage build for production
.gitignore # Swift-appropriate gitignore
You can also create a project manually — the scaffold is a convenience, not a requirement. The quickstart guide walks through manual setup step by step.
Docker
The scaffold generates a Dockerfile, but you can also write your own. Here’s a production-ready setup:
# Build stage
FROM swift:6.0-jammy AS builder
WORKDIR /app
COPY Package.swift Package.resolved ./
RUN swift package resolve
COPY Sources/ Sources/
RUN swift build -c release
# Run stage
FROM swift:6.0-jammy-slim
WORKDIR /app
COPY --from=builder /app/.build/release/my-server .
EXPOSE 8080
CMD [ "./my-server" ]
Build and run:
docker build -t my-server .
docker run -p 8080:8080 my-server
The multi-stage build keeps your production image small — it only includes the compiled binary and Swift runtime, not the build tools or source code.
Configuration
Prism reads configuration from environment variables and .env files using PrismConfig:
Environment Variables
.env File
Environment Profiles
PORT = 3000 HOST = 0.0.0.0 PRISM_ENV = production swift run
Create a .env file in your project root: PORT = 3000
HOST = 0.0.0.0
DATABASE_PATH = ./data/app.db
SESSION_SECRET = your-secret-key-here
Create environment-specific files that override the base: PRISM_ENV = production
PORT = 80
DATABASE_PATH = /data/app.db
PRISM_ENV = development
PORT = 8080
DATABASE_PATH = :memory:
Prism loads .env first, then .env.{PRISM_ENV}, with environment variables taking highest priority.
Access configuration in your code:
let config = PrismConfig. load ()
let port = config. port // UInt16, from PORT env var (default 8080)
let host = config. host // String, from HOST env var (default "0.0.0.0")
let isProd = config. isProduction // Bool, checks PRISM_ENV == "production"
// Custom keys
let dbPath = config. get ( "DATABASE_PATH" , default : ":memory:" )
let maxConn = config. getInt ( "MAX_CONNECTIONS" , default : 5 )
let debug = config. getBool ( "DEBUG" , default : false )
let secret = try config. require ( "SESSION_SECRET" ) // Throws if missing
Verify Installation
Create a minimal server to verify everything works:
import PrismServer
let server = PrismHTTPServer ( port : 8080 )
await server. get ( "/" ) { _ in
. json ([ "status" : "ok" , "framework" : "Prism" , "version" : "4.4.0" ])
}
print ( "Server starting on http://localhost:8080" )
try await server. start ()
try await Task. sleep ( for : . seconds (. max ))
In another terminal:
curl http://localhost:8080
# {"status":"ok","framework":"Prism","version":"4.4.0"}
If you see the JSON response, Prism is installed and working.
IDE Setup
Open the package directory in Xcode: Xcode resolves dependencies automatically. You get full autocomplete, jump-to-definition, and debugging. Install the Swift extension for VS Code. It provides SourceKit-LSP integration with autocomplete and diagnostics. Open the project folder: No IDE needed. Build and run from the command line: swift build # Compile
swift run # Build and run
swift test # Run tests
Next Steps
Quickstart Tutorial Build a complete REST API with database, validation, and error handling.
Core Concepts Understand how the server, routing, and middleware pipeline work together.