advanced-alchemy-getting-started
Getting Started
Execution Workflow
- Confirm prerequisites: Python 3.9+, SQLAlchemy 2.x, and whether the project needs sync or async database access.
- Install
advanced-alchemy, oradvanced-alchemy[cli]if database migration commands are required. - Choose the correct config pair:
SQLAlchemyAsyncConfigplusAsyncSessionConfigorSQLAlchemySyncConfigplusSyncSessionConfig. - Start with one model, one repository, and one service before wiring framework-specific plugins or middleware.
- Decide early whether the app will use Litestar, FastAPI, Flask, or standalone SQLAlchemy patterns.
Implementation Rules
- Prefer the smallest viable setup before adding service layers, framework helpers, or multiple binds.
- Keep session configuration explicit, especially
expire_on_commit=Falsein request-driven applications. - Choose sync versus async once per integration boundary and avoid mixing styles casually.
- Keep the first CRUD path runnable end-to-end before introducing migrations, seeding, or custom types.
Example Pattern
from advanced_alchemy.config import AsyncSessionConfig, SQLAlchemyAsyncConfig
alchemy_config = SQLAlchemyAsyncConfig(
connection_string="sqlite+aiosqlite:///app.db",
session_config=AsyncSessionConfig(expire_on_commit=False),
create_all=True,
)
Validation Checklist
- Confirm the selected config class matches the driver and execution style.
- Confirm metadata creation or migrations can see the same models as runtime code.
- Confirm a repository or service can open a session and perform one basic read or write.
- Confirm framework integration is deferred until the underlying SQLAlchemy setup works.
Cross-Skill Handoffs
- Use
advanced-alchemy-modelingfor base classes, mixins, and relationships. - Use
advanced-alchemy-repositoriesandadvanced-alchemy-servicesonce CRUD is working. - Use
advanced-alchemy-litestar,advanced-alchemy-fastapi, oradvanced-alchemy-flaskfor framework wiring. - Use
advanced-alchemy-cliandadvanced-alchemy-database-seedingafter the base setup is stable.
Advanced Alchemy References
More from alti3/litestar-skills
litestar-responses
Build Litestar responses with typed return values, explicit Response containers, layered response classes, headers, cookies, status-code control, redirects, files, streams, server-sent events, ASGI app returns, and background tasks. Use when shaping outbound HTTP behavior, correcting response contracts, or choosing the right Litestar response primitive. Do not use for request parsing, validation, or authentication policy design.
22litestar-logging
Configure Litestar logging with `LoggingConfig`, `queue_listener`, exception logging policy, selective stack-trace suppression, standard logging, picologging, Structlog, and custom logging config subclasses. Use when establishing or refactoring application logging behavior, request-level logs, or production-safe error logging in Litestar. Do not use for metrics/tracing instrumentation or exception-response contract design.
22litestar-authentication
Implement Litestar authentication with custom authentication middleware, built-in security backends, JWT and session flows, route inclusion and exclusion rules, and typed auth context on `Request` / `ASGIConnection`. Use when establishing identity, issuing or validating credentials, or attaching authenticated user context in Litestar. Do not use for generic request parsing, broad security audits, or unrelated transport concerns.
22litestar-middleware
Design and apply Litestar middleware for cross-cutting concerns such as CORS, CSRF, allowed-host checks, compression, rate limiting, logging, sessions, request enrichment, policy enforcement, and custom ASGI pipeline control. Use when behavior must wrap broad route sets consistently across the ASGI stack. Do not use for route-specific business rules, simple response mutation better handled by lifecycle hooks, or auth/guard policy work that belongs in security-focused skills.
20litestar-routing
Design and implement Litestar routing with app/router/controller composition, handler decorators, path and parameter modeling, route indexing/reverse lookups, ASGI mounting, and layered route metadata. Use when creating or refactoring endpoint topology and URL contracts. Do not use for purely internal service logic unrelated to HTTP route structure.
18litestar-dto
Configure Litestar DTO behavior for inbound parsing and outbound serialization, including layer-scoped `dto`/`return_dto`, `DTOConfig` policies, `DTOData` update workflows, and custom `AbstractDTO` implementations. Use when API payload contracts differ from internal model structures. Do not use when internal models can be exposed safely without transformation.
18