Documentation
Melange is an OpenFGA-to-PostgreSQL compiler. It takes your authorization model (written in OpenFGA DSL) and compiles it into specialized PostgreSQL functions that run permission checks directly inside your database.
What is an Authorization Compiler?
The pattern is similar to Protocol Buffers or GraphQL Code Generator: define a schema, run a compiler, get code tailored to your definitions.
Melange applies this pattern to authorization:
flowchart LR
schema["schema.fga<br/>(OpenFGA DSL)"] --> melange["melange<br/>compile"]
melange --> funcs["PostgreSQL Functions<br/>(check_permission, etc)"]
Instead of a generic runtime that interprets your model at query time, Melange generates a SQL function for each relation in your schema. The authorization logic runs as PostgreSQL code: transaction-aware, query-planned, and with zero network hops.
How It Works
- Define your model - Write an OpenFGA schema (
.fgafile) describing types, relations, and permission rules - Compile to SQL - Run
melange migrateto generate and install specialized PostgreSQL functions - Query permissions - Call the generated functions from any language or directly in SQL
Read more about Melange’s architecture and how it works here.
Why Compile to PostgreSQL?
| Traditional FGA | Melange |
|---|---|
| Separate authorization service | Authorization lives in your database |
| Network round-trip for every check | Single SQL query |
| Eventual consistency with your data | Transaction-aware, always consistent |
| Generic graph traversal at runtime | Specialized functions per relation |
| Sync tuples to external store | Query your existing tables directly |
Key Features
- Per-Relation Code Generation - Each relation gets its own check function, not a generic interpreter
- Works with Your Tables - Permissions derived from a view over your existing data (no tuple sync)
- Transaction Aware - Permission checks see uncommitted changes within the same transaction
- Language Agnostic - Generated SQL functions callable from Go, Python, Node.js, or any PostgreSQL client
- OpenFGA Compatible - Use familiar OpenFGA DSL syntax for authorization models
Getting Started
Concepts
Architecture and design.
Guides
Using Melange’s client libraries, middleware patterns, and operational workflows. For direct SQL access, see the SQL API reference.
Reference
Technical reference documentation.