2023-10-17 17:27:09 -04:00
DATA MODELS
===========
This document describes the key top-level entities this application will be working with and the attributes of each. This is a work-in-progress.
Other top-level entities will be introduced to the application as necessary.
Representations in this document are in application context; for database structure, see SCHEMA.md in this directory.
# Person
A Person represents a person! Specifically, a Person is a person who is using/has used the web application. Many applications call this entity a "User". We call them a Person.
``` rust
2023-10-18 10:25:54 -04:00
struct PersonId {
2023-10-17 17:27:09 -04:00
id: String,
2023-10-18 10:25:54 -04:00
}
struct Person {
id: PersonId,
2023-10-17 17:27:09 -04:00
remote_id: String,
name: String,
2023-10-18 10:25:54 -04:00
handle: Option< String > ,
email: Option< Vec < String > >,
is_active: bool,
2023-10-18 12:00:47 -04:00
is_blocked: bool,
2023-10-18 10:25:54 -04:00
created_at: chrono::DateTime,
modified_at: chrono::DateTime,
modified_by: PersonId,
deleted_at: Option< chrono::DateTime > ,
deleted_by: Option< PersonId > ,
last_seen: chrono::DateTime,
2023-10-17 17:27:09 -04:00
}
```
# Tag
A Tag is a classification label that a Person wants to associate to a Label, an Artist, an Album, a Track, or a Playlist, used as a way of grouping entities together via some commonality the context of which is not programmatically relevant.
``` rust
2023-10-18 10:25:54 -04:00
struct TagId {
host: String,
2023-10-17 17:27:09 -04:00
id: String,
2023-10-18 10:25:54 -04:00
}
struct Tag {
id: TagId,
2023-10-17 17:27:09 -04:00
name: String,
}
```
# Label
A Label represents a record label (a group of people who handle promotion and/or distribution for one or more Artists).
``` rust
2023-10-18 10:25:54 -04:00
struct LabelId {
2023-10-17 17:27:09 -04:00
id: String,
2023-10-18 10:25:54 -04:00
}
struct Label {
id: LabelId,
2023-10-17 17:27:09 -04:00
name: String,
description: String,
website: String,
artists: HashMap< Artist > ,
2023-10-18 10:25:54 -04:00
tags: Option< Vec < Tag > >,
comments: Option< Vec < Comment > >,
2023-10-17 17:27:09 -04:00
}
```
# Artist
An Artist represents a musical artist.
``` rust
2023-10-18 10:25:54 -04:00
struct ArtistId {
2023-10-17 17:27:09 -04:00
id: String,
2023-10-18 10:25:54 -04:00
}
struct Artist {
id: ArtistId,
2023-10-17 17:27:09 -04:00
name: String,
bio: String,
website: String,
2023-10-18 10:25:54 -04:00
tags: Option< Vec < Tag > >,
comments: Option< Vec < Comment > >,
2023-10-17 17:27:09 -04:00
}
```
# Track
A Track represents a single piece of work by an Artist that is contained in an audio file.
``` rust
2023-10-18 10:25:54 -04:00
struct TrackId {
2023-10-17 17:27:09 -04:00
id: String,
2023-10-18 10:25:54 -04:00
}
struct Track {
id: TrackId,
2023-10-17 17:27:09 -04:00
title: String,
description: String,
duration: chrono::Duration,
artists: HashMap< Artist > ,
2023-10-18 10:25:54 -04:00
is_public: bool,
2023-10-18 12:00:47 -04:00
is_available: bool,
2023-10-18 10:25:54 -04:00
preview_source: Option< String > ,
source: String,
price: Option< rusty_money::Money > ,
created_by: PersonId,
2023-10-17 17:27:09 -04:00
created_at: chrono::DateTime,
2023-10-18 10:25:54 -04:00
modified_by: PersonId,
2023-10-17 17:27:09 -04:00
modified_at: chrono::DateTime,
2023-10-18 10:25:54 -04:00
deleted_by: Option< PersonId > ,
2023-10-17 17:27:09 -04:00
deleted_at: Option< chrono::DateTime > ,
2023-10-18 10:25:54 -04:00
tags: Option< Vec < Tag > >,
comments: Option< Vec < Comment > >,
lyrics: Option< String > ,
cover: Option< String > ,
images: Option< Vec < String > >,
2023-10-17 17:27:09 -04:00
}
```
# Album
An Album represents a work by an Artist that contains one or more Tracks.
``` rust
2023-10-18 10:25:54 -04:00
struct AlbumId {
2023-10-17 17:27:09 -04:00
id: String,
2023-10-18 10:25:54 -04:00
}
struct Album {
id: AlbumId,
2023-10-17 17:27:09 -04:00
title: String,
description: String,
artists: HashMap< Artist > ,
tracks: HashMap< Track > ,
2023-10-18 10:25:54 -04:00
is_public: bool,
2023-10-18 12:00:47 -04:00
is_available: bool,
2023-10-18 10:25:54 -04:00
preview_source: Option< String > ,
source: String,
price: Option< rusty_money::Money > ,
created_by: PersonId,
2023-10-17 17:27:09 -04:00
created_at: chrono::DateTime,
2023-10-18 10:25:54 -04:00
modified_by: PersonId,
2023-10-17 17:27:09 -04:00
modified_at: chrono::DateTime,
2023-10-18 10:25:54 -04:00
deleted_by: Option< PersonId > ,
2023-10-17 17:27:09 -04:00
deleted_at: Option< chrono::DateTime > ,
2023-10-18 10:25:54 -04:00
tags: Option< Vec < Tag > >,
comments: Option< Vec < Comment > >,
cover: Option< String > ,
images: Option< Vec < String > >,
2023-10-17 17:27:09 -04:00
}
```
# Playlist
A Playlist represents an ordered collection of Tracks assembled by a Person.
``` rust
2023-10-18 10:25:54 -04:00
struct PlaylistId {
2023-10-17 17:27:09 -04:00
id: String,
2023-10-18 10:25:54 -04:00
}
struct Playlist {
id: PlaylistId,
2023-10-17 17:27:09 -04:00
title: String,
description: String,
created_by: String,
created_at: chrono::DateTime,
modified_at: chrono::DateTime,
deleted_at: Option< chrono::DateTime >
is_public: bool,
2023-10-18 10:25:54 -04:00
cover: Option< String > ,
tracks: Vec< Track > ,
tags: Option< Vec < Tag > >,
comments: Option< Vec < Comment > >,
}
```
# Article
An Article represents a "blog post" style article written by a Person.
``` rust
struct ArticleId {
id: String,
}
struct Article {
id: ArticleId,
title: String,
body: String,
description: Option< String > ,
created_by: PersonId,
created_at: chrono::DateTime,
modified_at: chrono::DateTime,
deleted_at: Option< chrono::DateTime >
is_public: bool,
cover: Option< String > ,
images: Option< Vec < String > >,
tracks: Option< Vec < Track > >,
tags: Option< Vec < Tag > >,
comments: Option< Vec < Comment > >,
2023-10-17 17:27:09 -04:00
}
```
# Comment
A Comment represents a textual comment that a Person wants to attach contextually to an Artist, an Album, a Track, or a Playlist.
``` rust
2023-10-18 10:25:54 -04:00
enum CommentTargetType {
Label,
Artist,
Album,
Track,
Playlist,
Comment,
}
struct CommentTargetId {
label_id: Option< LabelId > ,
artist_id: Option< ArtistId > ,
album_id: Option< AlbumId > ,
track_id: Option< TrackId > ,
playlist_id: Option< PlaylistId > ,
comment_id: Option< CommentId > ,
}
struct CommentId {
2023-10-17 17:27:09 -04:00
id: String,
2023-10-18 10:25:54 -04:00
}
struct Comment {
id: CommentId,
2023-10-17 17:27:09 -04:00
body: String,
2023-10-18 10:25:54 -04:00
target_type: CommentTargetType,
target_id: CommentTargetId,
created_by: PersonId,
created_at: chrono::DateTime,
modified_at: chrono::DateTime,
deleted_at: Option< chrono::DateTime >
is_public: bool,
2023-10-17 17:27:09 -04:00
}
```
2023-10-18 12:00:47 -04:00
# Collection
A Collection represents one or more Albums and/or Tracks that are offered together as a package for Purchase
``` rust
struct CollectionId {
id: String,
}
struct Collection {
id: CollectionId,
name: String,
description: String,
created_by: Person,
created_at: chrono::DateTime,
modified_by: Person,
modified_at: chrono::DateTime,
is_public: bool,
is_available: bool,
deleted_by: Option< Person > ,
deleted_at: Option< chrono::DateTime > ,
albums: Option< Vec < Album > >,
tracks: Option< Vec < Track > >,
price: Oprion< rusty_money::Money > ,
}
```
# OtherProduct
An OtherProduct represents a product that is not a Track, Album, or Collection that is nonetheless for sale as a Purchase.
``` rust
struct OtherProductId {
id: String,
}
struct OtherProduct {
id: OtherProductId,
name: String,
description: String,
}
```
2023-10-17 17:27:09 -04:00
# Purchase
A Purchase represents one or more Tracks or Albums that a Person purchases from an Artist or Label through the server.
``` rust
2023-10-18 10:25:54 -04:00
enum PurchaseItemType {
Album,
Track,
Collection,
OtherProduct,
}
struct PurchaseItemId {
id: String,
}
struct SkuId {
id: String,
}
struct Sku {
id: SkuId,
album_id: Option< AlbumId > ,
track_id: Option< TrackId > ,
collection_id: Option< CollectionId > ,
other_product_id: Option< OtherProductId > ,
}
struct PurchaseItem {
id: PurchaseItemId,
type: PurchaseItemType,
sku: SkuId,
quantity: usize,
discount_percentage: usize,
}
2023-10-18 12:00:47 -04:00
enum PurchaseState {
InCart,
Processing,
PaymentRejected,
PaymentCompleted,
Fulfilled,
Cancelled,
Refunded,
}
2023-10-17 17:27:09 -04:00
struct Purchase {
id: String,
2023-10-18 12:00:47 -04:00
items: Vec< PurchaseItem > ,
state: PurchaseState,
purchased_by: Person,
purchased_at: Option< chrono::DateTime > ,
2023-10-17 17:27:09 -04:00
}
```