Entity overview
The database consists of the following core entities:User
User accounts and authentication
Artist
Artist profiles and metadata
Label
Record label information
Release
Albums, singles, and EPs
Track
Individual songs
Lyrics
Song lyrics with timestamps
Role
User roles
Permission
System permissions
RolePermission
Role-permission mappings
Base entity
All entities extend theAbstractEntity class, which provides common fields:
AbstractEntity
Unique identifier for the entity. Auto-generated using PostgreSQL’s UUID generation.
Timestamp when the entity was created. Automatically set to
CURRENT_TIMESTAMP on creation.Timestamp when the entity was last updated. Automatically updated to
CURRENT_TIMESTAMP on any modification.All entities inherit these fields automatically. They don’t need to be explicitly defined in child entities.
Core entities
User
Represents user accounts in the system. Users can create labels, artists, and releases. Table name:user
User’s email address. Must be unique and valid.
- Max length: 255 characters
- Validation: Email format validation
- Unique constraint: Yes
User’s full name.
- Max length: 255 characters
User’s phone number (optional).
- Max length: 255 characters
- Unique constraint: Yes (composite with email)
Account status.
- Values:
ACTIVE,INACTIVE,SUSPENDED - Default:
ACTIVE
Hashed password. Not included in query results by default.
- Max length: 255 characters
- Select:
false(excluded from queries)
- Has many
labels(one-to-many with Label) - Has many
artists(one-to-many with Artist) - Has many
releases(one-to-many with Release) - Has many
createdRoles(one-to-many with Role) - Has many
createdRolePermissions(one-to-many with RolePermission)
api/src/entities/user.entity.ts:14
Artist
Represents artists who create music. Artists belong to users and can be associated with multiple releases. Table name:artists
Artist’s name or stage name.
Artist’s status in the system.
- Values:
ACTIVE,INACTIVE - Default:
ACTIVE
Foreign key to the user who owns this artist profile.
- Belongs to
user(many-to-one with User)onDelete: CASCADE- Artist is deleted when user is deletedonUpdate: CASCADE- Artist’s userId updates when user id changes
- Has many
releasesthroughReleaseArtist(one-to-many)
api/src/entities/artist.entity.ts:13
Label
Represents record labels that publish music releases. Table name:labels
Label’s name.
- Max length: 255 characters
Label’s contact email address (optional).
- Max length: 255 characters
Description of the label (optional).
- Max length: 255 characters
Foreign key to the user who owns this label.
Country where the label is based.
- Values: ISO country codes (e.g.,
RW,US,GB) - Default:
RW(Rwanda)
- Belongs to
user(many-to-one with User) - Has many
releases(one-to-many with Release)
api/src/entities/label.entity.ts:15
Release
Represents music releases (albums, singles, EPs) distributed through the platform. Table name:releases
Release title.
URL or path to the release cover art image (optional).
Universal Product Code for the release (optional).
Date when the release is published.
Release version (e.g., “Deluxe Edition”, “Remastered”) - optional.
Year the release was produced.
Label’s catalog number for the release (optional).
Foreign key to the associated label (optional).
Foreign key to the user who created this release.
title, releaseDate, productionYear, userId, labelId, and version must be unique.
Relationships:
- Belongs to
label(many-to-one with Label)onDelete: CASCADE- Release is deleted when label is deletedonUpdate: CASCADE
- Belongs to
user(many-to-one with User)onDelete: CASCADE- Release is deleted when user is deletedonUpdate: CASCADE
- Has many
artiststhroughReleaseArtist(one-to-many) - Has many
tracks(one-to-many with Track)
api/src/entities/release.entity.ts:15
Track
Represents individual tracks (songs) within a release. Table name:tracks
Track title.
Track duration in seconds.
Whether the track contains explicit content.
- Default:
false
Foreign key to the release this track belongs to.
International Standard Recording Code - unique identifier for the recording (optional).
- Unique constraint: Yes
- Belongs to
release(many-to-one with Release) - Has many
lyrics(one-to-many with Lyrics)
api/src/entities/track.entity.ts:7
Lyrics
Stores synchronized lyrics for tracks with optional timestamps. Table name:lyrics
Lyrics content stored as JSON array of line objects.Format:Each line can optionally include a timestamp.
Foreign key to the associated track.
Language code for the lyrics (e.g.,
en, fr, rw).- Default:
en
- Belongs to
track(many-to-one with Track)
api/src/entities/lyrics.entity.ts:7
ReleaseArtist
Junction table linking releases to artists (many-to-many relationship). Table name:release_artists
Foreign key to the release.
Foreign key to the artist.
- Belongs to
release(many-to-one with Release) - Belongs to
artist(many-to-one with Artist)
api/src/entities/releaseArtist.entity.ts:10
Authorization entities
These entities manage user roles and permissions for access control.Role
Defines roles that can be assigned to users. Table name:roles
Role name.
- Unique constraint: Yes
Description of the role’s purpose (optional).
Foreign key to the user who created this role.
- Belongs to
createdByuser (many-to-one with User) - Has many
permissionsthroughRolePermission(one-to-many)
api/src/entities/role.entity.ts:7
Permission
Defines system permissions that can be granted to roles. Table name:permissions
Permission name.
- Unique constraint: Yes
Description of what the permission grants (optional).
- Has many
rolesthroughRolePermission(one-to-many)
api/src/entities/permission.entity.ts:5
RolePermission
Junction table linking roles to permissions (many-to-many relationship). Table name:role_permissions
Foreign key to the role.
Foreign key to the permission.
Foreign key to the user who created this assignment (optional).
roleId and permissionId must be unique.
Relationships:
- Belongs to
role(many-to-one with Role) - Belongs to
permission(many-to-one with Permission) - Belongs to
createdByuser (many-to-one with User)
api/src/entities/rolePermission.entity.ts:8
Entity relationship diagram
Database management
Migrations
In development mode, TypeORM automatically synchronizes the schema. For production, use proper migrations to manage schema changes safely.
Seeding
Populate the database with initial data using the seed script:api/src/seeds/.
Cascading deletes
Several relationships haveCASCADE delete configured:
- Deleting a User cascades to their Artists, Releases, Labels
- Deleting a Label cascades to its Releases
- Deleting a Release cascades to its Tracks
Related resources
Development setup
Set up your local database
Environment variables
Configure database connection
Monorepo structure
Explore entity files in the codebase
API reference
API endpoints that use these entities