Skip to content

Assignment 4: Backend Design & Implementation (alpha)

Data modeling

Abstract data model

concept Authentication
    purpose
        provide authentication
    principle
        after registration, returns the object associated with provided credentials if they're right
    state
        registered: set User
        username, password: registered -> one String
    actions
        register(name, pwd: String, out u: User)
        authenticate(name, pwd: String, out u: User)
concept Authentication
    purpose
        provide authentication
    principle
        after registration, returns the object associated with provided credentials if they're right
    state
        registered: set User
        username, password: registered -> one String
    actions
        register(name, pwd: String, out u: User)
        authenticate(name, pwd: String, out u: User)
concept Session[User]
    purpose
        provide authentication for extended period
    principle
        after a session starts (and before it ends), authentication won't be needed again, until the session is ended.
    state
        // if a session goes inactive, it's removed from
        // the relation
        user: Session -> one User
    actions
        start(u: User, out s: Session)
        getUser(s: Session, out u: User)
        end(s: Session)
concept Session[User]
    purpose
        provide authentication for extended period
    principle
        after a session starts (and before it ends), authentication won't be needed again, until the session is ended.
    state
        // if a session goes inactive, it's removed from
        // the relation
        user: Session -> one User
    actions
        start(u: User, out s: Session)
        getUser(s: Session, out u: User)
        end(s: Session)
concept Tag[Item]
    purpose
        provide systematic classification
    principle
        after associating tags to objects, when given a set of tags, returns a set of objects that have those tags associated (has to include all of them)
    state
        tags: set Tag
        tagging: tags -> many Item
    actions
        setTagToItem(tag: Tag, item: Item)
        deleteTagFromItem(tag: Tag, item: Item)
        allWithTag(tag: set Tag, out u: set Item)
concept Tag[Item]
    purpose
        provide systematic classification
    principle
        after associating tags to objects, when given a set of tags, returns a set of objects that have those tags associated (has to include all of them)
    state
        tags: set Tag
        tagging: tags -> many Item
    actions
        setTagToItem(tag: Tag, item: Item)
        deleteTagFromItem(tag: Tag, item: Item)
        allWithTag(tag: set Tag, out u: set Item)
concept TextToImage[Post]
    purpose
        create images that convey the tone of a text
    principle
        for every post, there'll be a thumbnail, a visual representation of the tone in the text.
    state
        thumbnails: set Thumbnail
        assignments: thumbnails -> many Post
    actions
        generateImage(post: Post, out u: Thumbnail)
        deleteThumbnail(post: Post)
concept TextToImage[Post]
    purpose
        create images that convey the tone of a text
    principle
        for every post, there'll be a thumbnail, a visual representation of the tone in the text.
    state
        thumbnails: set Thumbnail
        assignments: thumbnails -> many Post
    actions
        generateImage(post: Post, out u: Thumbnail)
        deleteThumbnail(post: Post)
concept Feed[Item, User]
    purpose
        bring together content from multiple sources into a single, centralized location
    principle
        add objects to a feed, that can be retrieved when lookup (sorted differently according to whom it belongs)
    state
        items: set Item
        feeds: set items
        assignments: feeds -> many User
    actions
        createFeed(user: User, out u: Feed)
        addToFeed(item: Item, user: User, out u: Feed)
        removeFromFeed(item: Item, user: User)
        lookupFeed(user: User, out u: Feed)
concept Feed[Item, User]
    purpose
        bring together content from multiple sources into a single, centralized location
    principle
        add objects to a feed, that can be retrieved when lookup (sorted differently according to whom it belongs)
    state
        items: set Item
        feeds: set items
        assignments: feeds -> many User
    actions
        createFeed(user: User, out u: Feed)
        addToFeed(item: Item, user: User, out u: Feed)
        removeFromFeed(item: Item, user: User)
        lookupFeed(user: User, out u: Feed)
concept Post[User]
    purpose
        allow users to contribute to the community
    principle
        after creating content, it is made into an object that allows removing and editing
    state
        posts: set Post
        author: posts -> User
        content: posts -> String
    actions
        addPost(text: String, out u: Post)
        removePost(post: Post)
        editPost(newText: String, out u: Post)
concept Post[User]
    purpose
        allow users to contribute to the community
    principle
        after creating content, it is made into an object that allows removing and editing
    state
        posts: set Post
        author: posts -> User
        content: posts -> String
    actions
        addPost(text: String, out u: Post)
        removePost(post: Post)
        editPost(newText: String, out u: Post)
concept Highlight[Post]
    purpose
        set apart important items among a set of items
    principle
        after adding or removing objects and their dates, given a date, returns a summary of the most important objects related to that date
    state
        dateToPosts: Date -> many Post
        highlights: Date -> Highlight
    actions
        addPost(date: Date, post: Post)
        removePost(date: Date, post: Post)
        getHighlights(date: Date, out u: Highlight)
concept Highlight[Post]
    purpose
        set apart important items among a set of items
    principle
        after adding or removing objects and their dates, given a date, returns a summary of the most important objects related to that date
    state
        dateToPosts: Date -> many Post
        highlights: Date -> Highlight
    actions
        addPost(date: Date, post: Post)
        removePost(date: Date, post: Post)
        getHighlights(date: Date, out u: Highlight)
app ADDapp
    include Authentication
    include Session
    include Post
    include Feed[Post.Post]
    include TextToImage[Post.Post]
    include Tag[Post.Post]
    include Highlight[Post.Post]
app ADDapp
    include Authentication
    include Session
    include Post
    include Feed[Post.Post]
    include TextToImage[Post.Post]
    include Tag[Post.Post]
    include Highlight[Post.Post]

Diagram


Deployment

Link