Domain Entity Relationship Diagram
The data model for this full-stack application is built using Database Schema and Table Definitions, which integrates SQLAlchemy ORM with Pydantic validation. The core of the domain consists of two primary database entities: User and Item.
Key Entities
- User: Represents a registered user in the system. It includes authentication details (
email,hashed_password), authorization flags (is_active,is_superuser), and profile information (full_name). Users are uniquely identified by aUUID. - Item: Represents a resource owned by a user. Each item has a
title, an optionaldescription, and a timestamp. It is linked to aUservia a foreign key. - Token: A non-persistent model used for authentication responses, containing the JWT
access_token. - Message: A utility model used for generic API responses (e.g., success messages).
Relationships
- User to Item: A one-to-many relationship where one
Usercan own multipleItems. This is enforced by a foreign key constraint onitem.owner_idwith a cascade delete policy, meaning if a user is deleted, all their items are also removed. - Authentication: While not a direct database relationship, the
TokenPayload(decoded from the JWT) contains asubfield that corresponds to theUser.id, allowing the system to identify the current user for each request.
Key Architectural Findings:
- The codebase uses SQLModel to define both database tables and API schemas in a single class definition.
- Primary keys were migrated from Integers to UUIDs to improve security and scalability.
- The User entity includes both authentication (hashed_password) and authorization (is_superuser) fields.
- A one-to-many relationship exists between User and Item, with cascade delete enabled at the database level.
- Utility models like Token and Message are used for standardized API communication but are not persisted in the database.
Loading diagram...