Skip to content

Task 1: Abstract Data Models

Concepts

Concept: User
Purpose: Authenticate Users
Principle: After a user registers with a username and password, they can authenticate as that user by providing a matching username and password
State:

registered: set User
username, password: registered -> one String\

Actions:

register (n, p: String, out u: User)
authenticate (n, p: String, out u: User)


Concept: Session [User]
Purpose: Authenticate user for extended period
Principle: after a session starts (and before it ends), the getUser action returns the user identified at the start
State:

active: set Session
user: active -> one User

Actions:

start (u: User, out: s: Session)
getUser (s: Session, out u: User)
end (s: Session)


Concept: Post
Purpose: Display content
Principle: A user can start a post, add content of their liking, which can include text, images, etc., and submit the post for (allowed) users to view
State:

posts: set Post
content: posts -> one String
author: posts -> one User
dateCreated: posts -> one Date
id: posts -> one ID

Actions:

create (c: String, u: User, out p: Post)
delete (p: Post)
update (p: Post, c: String)
getPost (id: ID, out p: Post)
getAllUserPosts (a: User, out p: set Post)
isAuthor (p: Post, u: User)


Concept: Friend [User]
Purpose: Relates two users by allowing them to view each other’s content
Principle: When a user makes a new post, it will be sent to all of their friends for viewing (unless they had their access manually reduced)
State:

friendships: one Friendships
users: Friendships -> set User
friends: users -> set User
feed: users -> set Post

Actions:

addFriendship (u1: User, u2: User)
removeFriendship (u1: User, u2: User)
getUserFriends (u: User, out f: set Friend)
getFeed(u: User, out f: set Post)
addToFeed (u: User, p: Post)
removeFromFeed (u: User, p: Post)


Concept: ItemTimer [Item]
Purpose: Stores item for a certain duration
Principle: A timer is set to start at time t0 and finish after duration dt, after duration dt, item can be retrieved
State:

timers: set ItemTimer
forItem: timers -> one Item
startTime: timers -> one Date
duration: timers -> one Number

Actions:

setItem (t: ItemTimer, i: Item)
setStart (t: ItemTimer, d: Date)
setDuration (t: ItemTimer, dt: Number)
stop (t: ItemTimer)
continue (t: ItemTimer)
reset (t: ItemTimer)
isFinished (t: ItemTimer)
getTimerByItem (i: Item, out t: ItemTimer)
system finished (out i: Item)


Concept: TemporaryStorage [User]
Purpose: Temporarily store items
Principle: Items that are stored can be taken back out, or the items in storage can be cleared
State:

storages: set Storage
items: storages -> set Item
owners: storages -> one User

Actions:

addItem (u: User, i: Item)
removeItem (u: User, i: Item)
removeAllItems(u: User, out i: set Item)
getItem (u: User, out i: Item)
getAllItems (u: User, out i: set Item)
clearItems (u: User)
getOwner (s: Storage, out u: User)
getStorage (u: User, out: Storage)


Concept: Bookmark [User]
Purpose: Directly navigates a user to a particular page on the site
Principle: The user navigates to a page, bookmarks the page, and can later select that bookmark to navigate to the page in one step
State:

bookmarks: set Bookmark
owner: bookmarks -> one User
name: bookmarks -> one String
destinations: bookmarks -> one URL

Actions:

create (u: User, name: String, destination: URL)
delete (b: Bookmark)
rename (u: User, name: String)
getBookmarks (u: User)
getDestination (u: User, name: String, out destination: URL)


Concept: ViewingRestrictions [User]
Purpose: Manages viewing access of items between users that are friends
Principle: If user 1 has restricted viewing access to another user’s item(s), user 1 will not be able to view the item(s) even if they are friends
State:

restrictions: one ViewingRestrictions
users: restrictions -> set User
items: users -> set Item
restrictedUsers: items -> set User

Actions:

unrestrictUser (u1: User, u2: User)
restrictUser (u1: User, u2: User)
unrestrictUserOneItem (u1: User, u2: User, i: Item)
restrictUserOneItem (u1: User, u2: User, i: Item)
getRestrictedUsers (u1: User, out u: set User)
getRestrictedUsersOneItem (u1: User, i: Item, out u: set User)
isUserRestricted (u1: User, u2: User)
isUserRestrictedOneItem (u1: User, u2: User, i: Item)
addItem (u: User, i: Item)
removeItem(u: User, i: Item)

Synchronizations

App Minimaloo

  include User
  include Session[User]
  include Post
  include Friend [User]
  include ItemTimer [User]
  include TemporaryStorage [User]
  include Bookmark [User]
  include ViewingRestrictions [User]
  include Event [User]
  include Invitation [User, Event]

sync login (username: String, password: String, out s: Session)
  when User.authenticate(username, password, out user)
  Session.start(user, out session)

sync logout (s: Session)
  when Session.getUser (s, out u)
  ItemTimer.getTimerByItem(u, out t)
  ItemTimer.stop(t)
  ItemTimer.reset(t)
  removeSeenPosts(u)
  Session.end(s)

sync createPost (c: String, u: User)
  when Post.create(c, u, out p)
  ViewingRestrictions.addItem(u, p)
  Friend.getUserFriends (u, out friends)
  for (f of friends) ViewingRestriction.isUserRestrictedOneItem (u, f, p)
    Friend.addToFeed (f, p)

sync deletePost (post: Post, n: String, p: String)
  when User.authenticate(n, post, out u)
  Post.isAuthor(post, u)
  Post.delete(post)
  Friend.getUserFriends(u, out friends)
  VisibilityRestrictions.removeItem(u, post)
  for (f of friends) Friend.removeFromFeed(f, post)
    TemporaryStorage.removeItem(f, post)

sync markPostAsSeen (p: Post)
  when ItemTimer.finished(out u)
  TemporaryStorage.addItem (u)

sync removeSeenPosts (u: User)
  when TemporaryStorage.removeAllItems(u, out posts)
  for (p of posts) Friends.removeFromFeed(u, p)

sync deleteEvent (e: Event, n: String, p: String)
  when User.authenticate(n, p, out u)
  Event.isOwner(e, u)
  Event.delete(e)
  Friend.getUserFriends(u, out friends)
  VisibilityRestrictions.removeItem(u, e)
  for (f of friends) Friend.removeFromFeed(f, e)
    TemporaryStorage.removeItem(f, e)

sync deleteInvitation (i: Invitation, n: String, p: String)
  when User.authenticate(n, p, out u)
  Invitation.isOwner(i, u)
  Invitation.delete(i)
  Friend.getUserFriends(u, out friends)
  VisibilityRestrictions.removeItem(u, i)
  for (f of friends) Friend.removeFromFeed(f, i)
    TemporaryStorage.removeItem(f, i)

Global Data Model

Global Data Model


Backend Code Repository

Backend Repository


Deployment

Deployment to Vercel


RESTful Routes

server/routes.ts in Backend Repository