Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Post List Proposal #1

Open
Atternatt opened this issue Apr 5, 2022 · 0 comments
Open

Post List Proposal #1

Atternatt opened this issue Apr 5, 2022 · 0 comments
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed

Comments

@Atternatt
Copy link
Owner

Atternatt commented Apr 5, 2022

Implement a post list

Created: March 31, 2022
Last Edited Time: April 25, 2022
Type: Project Kickoff 🚀

Overview

On this proposal we are going to define the scope of the new feature we are going to design related with the main screen of the app and consist on showing a list of posts from this API

Problem Statement

  • The current app does nothing and only shows a blank screen

Proposed Solution

  • Implement the main feature of the app that consist on showing up a list of posts from https://jsonplaceholder.typicode.com

Success Criteria

  • The app can be compiled with the expected use cases defined in User Stories
  • All the tests are passed
  • The total coverage of the feature is greater than 60%
  • All the business layer is tested

User Stories

  1. The user can see a list of posts by just opening the app. The user will see a loading state each time the app loads some data
   flowchart LR
   subgraph 1
   A[Open App]-->B[Load Posts];
   B-->C{Did it work?};
   C--YES-->D(Show Posts);
   C--NO-->E(Show Error Screen);
   end
   subgraph 2
   H((Posts Loaded))-->I[Refresh]
   I---->B
   end
   1==>2
   
Loading
  1. The user can make a forced refresh of the data (even if the data is the same)
  2. If there is no data to show the app will show an empty screen with a message “No posts to show” no matter the type of the error.

Scope

  • Main screen of the app

Requirements

  • Unit tests for the business layer

Optional

  • Integration tests for the viewmodel
    • Success state
    • 500/404 code error
    • No connection error

Non-Requirements

  • Instrumentation tests

Architecture

Arch Spec

Class Diagram for the business layer

classDiagram
class GetListUseCase~P~ {
<<interface>>
+invoke() List~P~
}
class DefaultGetPostsUseCase {
+invoke() List~Post~
}
GetListUseCase<|..DefaultGetPostsUseCase
class GetListRepository~P~ {
<<interface>>
+invoke() List~P~
}
class DefaultGetPostsRepository {
+invoke() List~Post~
}
GetListRepository<|..DefaultGetPostsRepository
DefaultGetPostsUseCase o.. GetListRepository
class GetListDataSource~P~ {
<<interface>>
+invoke() List~P~
}
class PutListDataSource~P~ {
<<interface>>
+invoke(List~P~) List~P~
}
class StoreDataSource~P~ {
<<interface>>
}
PutListDataSource<|..StoreDataSource
GetListDataSource<|..StoreDataSource
class Mapper~F,P~ {
<<interface>>
+map(F) P 
}
class Bijection~F,P~ {
<<interface>>
+revert(P) F 
}
Mapper<|..Bijection
class MappedDataSource~F,P~
MappedDataSource o..Mapper~F,P~
class BijectedDataSource~F,P~
StoreDataSource<|..BijectedDataSource
BijectedDataSource o.. Bijection
GetListDataSource<|--MappedDataSource
class NetworkGetPostsDataSource {
+invoke() List~PostDTO~
}
class DatabasePostsDataSource {
-List~PostDBO~
+invoke() List~PostDBO~
}
MappedDataSource <|..NetworkGetPostsDataSource
BijectedDataSource<|..DatabasePostsDataSource
DefaultGetPostsRepository o.. GetListDataSource
DefaultGetPostsRepository o.. StoreDataSource

class PostsViewModel {
- state MutableFlow~State~
+loadPosts() Flow~State~
}
PostsViewModel..> GetListUseCase : calls

class State~P~ {
<<sealed class>>
}
class Error {
+message String
}
class Loading
class Loaded~P~ {
+value List~P~
}
class Idle
State<|--Error
State<|--Loading
State<|--Loaded
State<|--Idle
PostsViewModel--State

class Post {
+id int
+title String
+body String
}
class PostDTO {
+id int
+title String
+body String
}
class PostDBO {
+id int
+title String
+body String
}
Post--DefaultGetPostsUseCase
PostDTO--NetworkGetPostsDataSource
PostDBO--DatabasePostsDataSource
Loading

Sequence Diagram

sequenceDiagram
actor User
participant Fragment
participant ViewModel
participant UseCase
participant Repository
participant NetworkDataSource
participant DatabaseDataSource
par fragment workflow
Fragment-->>Fragment : onCreate
and User manually refresh
opt 
User-->Fragment: refresh
end
end
Fragment-->>+ViewModel : loadPosts
ViewModel-->+UseCase : invoke
rect rgb(242, 249, 255)
note right of UseCase : Background
UseCase-->+Repository: invoke
Repository-->+NetworkDataSource: get posts
NetworkDataSource-->-Repository: response
alt if response is not OK
Repository-->+DatabaseDataSource: get posts
DatabaseDataSource-->-Repository: response
else
Repository-->+DatabaseDataSource: store posts
end
Repository-->-UseCase: response
end
UseCase-->-ViewModel : response
ViewModel-->-Fragment : response
Loading
@Atternatt Atternatt changed the title Post List C4 Model proposal Post List Proposal Apr 25, 2022
@Atternatt Atternatt added enhancement New feature or request help wanted Extra attention is needed good first issue Good for newcomers labels Apr 26, 2022
@Atternatt Atternatt self-assigned this Apr 26, 2022
@Atternatt Atternatt removed their assignment Sep 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant