The database schema is managed by SQLAlchemy and contains five tables:Documentation Index
Fetch the complete documentation index at: https://mintlify.com/AndresLopezCorrales/Goods-Inventory/llms.txt
Use this file to discover all available pages before exploring further.
admin, responsible, location, items, and revision. Each table maps to a Python model class, and SQLAlchemy handles schema creation, foreign-key enforcement, and cascade rules automatically. The sections below document every column, constraint, and relationship for each model.
Models
responsible
Represents a person or department that is accountable for one or more physical locations in the inventory.
Primary key. Auto-incremented unique identifier for each responsible party.
Full name of the responsible party. Must be unique across all records and cannot be null.
location
Represents a physical storage area or room assigned to a responsible party. A location can hold many items and accumulates revision history over time.
Primary key. Auto-incremented unique identifier for the location.
Foreign key referencing
responsible.id_responsible. Links this location to its owner.A unique numeric code identifying the physical location. Cannot be null.
Optional human-readable description of the location (e.g. room name or area notes).
Timestamp of the most recent revision. Nullable — no value indicates the location has never been reviewed.
Location has many Revision records. The relationship is configured with cascade="all, delete-orphan", so deleting a location automatically removes all of its associated revisions.
items
Represents an individual inventory asset assigned to a location.
Primary key. Auto-incremented unique identifier for the item.
Foreign key referencing
location.id_location. Assigns the item to its physical location.The account or asset code for the item (e.g. a fixed-asset tag). Cannot be null.
Optional long-form description of the item.
revision
Records a single inspection or audit event for a location, capturing when it happened and any notes left by the reviewer.
Primary key. Auto-incremented unique identifier for the revision.
Foreign key referencing
location.id_location. Ties this revision to the location that was reviewed.Exact timestamp of when the revision took place. Cannot be null.
Optional free-text notes recorded during the revision.
Revision belongs to one Location. The location attribute uses back_populates='revisions' to match the revisions relationship defined on the Location model, forming a bidirectional link.
admin
Stores credentials for users who can access the admin dashboard. This model is entirely standalone — it has no foreign keys or ORM relationships to other tables.
Primary key. Auto-incremented unique identifier for the admin account.
Login username. Must be unique and cannot be null.
Password for the admin account. Cannot be null. See the warning below regarding storage.
Entity-relationship summary
The five models form a simple, linear ownership hierarchy:- One
Responsiblehas manyLocations— a responsible party is the owner of all locations assigned to them. Deleting a responsible does not automatically cascade to their locations; orphan locations should be handled at the application layer. - One
Locationhas manyItems— every item in the inventory belongs to exactly one location. - One
Locationhas manyRevisions— each inspection of a location creates a new revision record. Revisions are cascade-deleted when their parent location is removed. Adminis standalone — it participates in no relationships. Its sole purpose is authentication: the/api/loginendpoint validates credentials against this table and issues a JWT.
API serialisation (to_dict())
Each model exposes a to_dict() method that controls the JSON shape returned by the API. The three models below appear most frequently in API responses.
Location.to_dict()
Returns the full location record plus a nested snapshot of its most recent revision, making it possible to display freshness information without a second request.
last_revision_dateis serialised with.isoformat()and returned asnullwhen no revision exists.last_revisionis a nestedRevisionobject (see below), ornullif the location has never been reviewed.
Items.to_dict()
Returns a compact representation of an item. Note that account_name is exposed under the key name for a cleaner API contract.
idmaps to the internalid_itemprimary key.namemaps toaccount_name(the fixed-asset code stored in the database).
Revision.to_dict()
Returns a flat revision record. The timestamp is always present and always ISO 8601 formatted — date_time_revision is a non-nullable column.
idmaps to the internalid_revisionprimary key.commentmay benullif no notes were recorded during the revision.