Introduction
The @frame/models package encapsulates the entire transactional persistence layer of the monorepo. It defines schemas, manages connections, and exports the data models consumed by other applications (such as apps/nest or apps/next).
Fundamentals
Section titled “Fundamentals”The core of this package is isolating database infrastructure from the rest of the business logic, creating a single source of truth for the FRAME ecosystem.
[!TIP] Environment Agnosticism The package runs efficiently in both Node.js environments and Edge runtimes, thanks to the flexibility of our underlying ORM layer.
Data Ecosystem
Section titled “Data Ecosystem”Our persistence strategy rests on the following core technologies:
- PostgreSQL: Our primary relational database engine, connected via the lightweight
pgdriver. - Drizzle ORM: A typed ORM that bridges TypeScript and the SQL schema without sacrificing performance.
- Zod: Used to infer Data Transfer Objects (DTOs) directly from the transactional database models.
Primary Responsibilities
Section titled “Primary Responsibilities”- Connection Management: Provide preconfigured clients for interacting with the database.
- Data Modeling: Map logical SQL tables into usable TypeScript constructs.
- Universal DTOs: Export strict schemas that ensure data entering and leaving the server is structurally valid.
- Authentication (Better Auth): Provide Better Auth with the base tables it needs to manage sessions, accounts, and profiles.