Skip to content
GitHubDiscord

Lexigram | Modern Python Framework

Build large Python systems without losing control.

Most Python frameworks let you write code freely — then spring surprises on you when things grow.

❌ 5000 lines of startup code
❌ Dependencies scattered everywhere
❌ Tight coupling hiding in plain sight
❌ No clear boundaries between components

Lexigram enforces the structure before you need it.


You don’t wire dependencies by hand:

# ❌ Manual wiring — brittle at scale
service = UserService(PostgresRepo(), RedisCache())

You declare what you need:

# ✅ Declaration — the container wires it
class UserService:
def __init__(self, repo: UserRepository, cache: Cache):
...

And the container resolves it:

service = await container.resolve(UserService)

Thats it. No globals. No magic. Just control.


Terminal window
pip install lexigram lexigram-web
from lexigram import Application
from lexigram.web import WebProvider
app = Application(name="hello")
app.add_provider(WebProvider())
@app.controller()
class HelloController:
@get("/hello")
async def hello(self) -> dict:
return {"message": "Hello, Lexigram"}
if __name__ == "__main__":
app.run()

http://localhost:8000/hello


graph TB
    subgraph "lexigram-contracts"
        C1[Protocols]
        C2[Types]
        C3[Exceptions]
    end
    subgraph "lexigram"
        M1[Module]
        M2[Provider]
        M3[Container]
    end
    subgraph "Extensions"
        E1[lexigram-web]
        E2[lexigram-ai-*]
        E3[lexigram-sql]
    end
    C1 & C2 & C3 --> M2
    M1 & M2 & M3 --> E1 & E2 & E3

Rules that make it work:

RuleWhy it matters
lexigram-contracts — zero depsContracts never pull in implementations
lexigram — only contractsCore stays clean
Extensions — only core + contractsPackages are truly pluggable

Type Safety That Scales

690+ mypy violations fixed. Full type inference on container operations. Your IDE knows what you have.

Async-Native

Everything is async by default. Sync code is the exception, not the rule. Built for Python 3.11+.

42 Packages, One Graph

Web, AI, SQL, events, tasks, auth, cache, search — all under one dependency hierarchy.

Lifecycle-Managed

Providers boot in dependency order. Connections open before use, close on shutdown. No more connection pool leaks.


Encapsulate registration and initialization for a service group.

class DatabaseProvider(Provider):
name = "database"
priority = ProviderPriority.INFRASTRUCTURE
async def register(self, container: ContainerRegistrarProtocol) -> None:
container.singleton(DatabaseProtocol, PostgresDatabase)
async def boot(self, container: BootContainerProtocol) -> None:
db = await container.resolve(DatabaseProtocol)
await db.connect()

Terminal window
pip install lexigram lexigram-web
from lexigram import Application
from lexigram.web import WebProvider
app = Application(name="my-app", config=Config.from_env())
app.add_provider(WebProvider())
if __name__ == "__main__":
app.run()