Skip to content

Commit

Permalink
Update developer guide
Browse files Browse the repository at this point in the history
  • Loading branch information
daryltay415 committed Apr 13, 2024
1 parent 641cb7f commit 40c4d77
Show file tree
Hide file tree
Showing 9 changed files with 194 additions and 5 deletions.
Binary file added docs/ArchitectureDiagram.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
88 changes: 83 additions & 5 deletions docs/DeveloperGuide.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
# Developer Guide
* [Acknowledgements](#acknowledgements)
* [Design & implementation](#design--implementation)
* [Design](#design)
* [Architecture](#architecture)
* [Storage component](#storage-component)
* [Parser component](#parser-component)
* [TravelActivityTypes component](#travelactivitytypes-component)
* [Ui component](#ui-component)
* [Errorhandlers component](#errorhandlers-component)
* [Implementation](#implementation)
* [Save feature](#save-feature)
* [Update feature](#update-feature)
* [Total expense feature](#total-expense-feature)
Expand Down Expand Up @@ -34,12 +41,80 @@

Source for currency exchange API: [link](https://github.com/fawazahmed0/exchange-api/blob/main/LICENSE)

## Design & implementation
## Design

### Architecture
![ArchitectureDiagram.png](ArchitectureDiagram.png)

### Overview
![Overview.png](Overview.png)
Given above is a overview of how each classes interact with one another in our software.
The architecture diagram above describes the high level design of the OmniTravel app.

**Main components of the architecture**

`omnitravel` which consists of the class `OmniTravel` has the responsibility of launching the app and shutting down.
* When the app launches, it initializes the other components in the app.
* When it shuts down, it will also shut down the other components.

The main components of the system are as follows:
* `storage`: It reads data from the folder omni.txt and writes data to it.
* `parser`: It filters the commands and executes them.
* `travelactivitytypes`: It holds the data of the app in memory.
* `ui`: The UI of the app.
* `errorhandlers`: It handles all the exceptions and checks for any errors in the app.

### Storage component
The Storage component only consists of one class `FileSave`.

The storage component,
* saves the data of the different travel activity types, including their tags, expenses, type and
description.
* it listens to the `omnitravel` component to know when to save and load the file from omni.txt into the app.
* it retrieves travel activity objects from the `travelactivitytype` component to save.

### Parser component
The parser component only consists of one class `Parser`.

The parser component,
* handles all the command inputs by the user
and carries out the appropriate actions depending on the command given.
* uses the `ui` component to print responses to the user
* sends commands to the `exchangerateapi` and `travelactivitytype` components to execute.
* receives data from the `omnitravel` component.


### TravelActivityTypes component

![TravelActivityTypeClassDiagram.png](TravelActivityTypeClassDiagram.png)
The TravelActivityTypes component consists of a few different classes:
* `Accommodation`: A subclass of travel activity related to accommodation
* `Food`: A subclass of travel activity related to food
* `Landmark`: A subclass of travel activity related to landmark
* `TravelActivtiy`: The parent class of `Accommodation`, `Food` and `Landmark`
* `TravelActivityList`: An array consisting of travel activity type objects

The `TravelActivityTypes` component,
* stores all the travel activity type objects in an array.
* listens to the `parser` component for any commands to execute.

### Ui component
The Ui component only consists of one class `Ui`.

The Ui component,
* listens to the `omnitravel`, `parser` and `travelactivitytypes` component to print out
the responses to the user.
* contains all the responses to each of the user's input command
* takes in exceptions as parameters and prints out the error message.

### Errorhandlers component
![Errorhandlers.png](Errorhandler.png)
The Errorhandler component consists of two classes `CheckParameters` and `OmniException`.
`OmniException` is a subclass of the parent class `Exception`.

The Errorhandler component,
* checks the parameters of the commands given by the user.
* handles all the exceptions and errors in the app.
* keeps a reference to `ui` component to print error messages.

## Implementation

### Save feature

Expand Down Expand Up @@ -87,6 +162,9 @@ in the travel activity list. The `update` command calls the `Parser#updateComman
Step 3. The method will then find the travel activity with the corresponding travel activity number in the `travelActivities` and then set the new date and duration
of that travel activity.

The class diagram below shows the main relationship between the classes in the update feature:
![UpdateFeatureClassDiagrma.png](UpdateFeatureClassDiagram.png)

The sequence diagram below shows how an update operation goes through the parser component:
![img_1.png](img_1.png)

Expand Down
Binary file added docs/Errorhandler.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/TravelActivityTypeClassDiagram.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/UpdateFeatureClassDiagram.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 24 additions & 0 deletions docs/team/ArchitectureDiagram.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
@startuml
'https://plantuml.com/component-diagram



Actor User as user

user ..> [omnitravel]

[omnitravel] --> "passes data"[parser]
[omnitravel] --> "Load/save"[storage]
[omnitravel] --> "uses" [ui]
[parser] --> "uses" [ui]
[parser] --> "uses" [exchangerateapi]
[parser] --> "uses" [errorhandlers]
[storage] --> "uses" [travelactivitytype]
[travelactivitytype] --> "uses" [ui]
[travelactivitytype] --> "uses" [errorhandlers]
[errorhandlers] --> "uses" [ui]
[parser] --> "uses" [travelactivitytype]
folder "omni.txt" as folder
folder .. [storage]

@enduml
30 changes: 30 additions & 0 deletions docs/team/Errorhandler.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
@startuml
'https://plantuml.com/class-diagram
skinparam packageStyle rectangle
hide class members
package errorhandlers{
class CheckParameters
class OmniException
class Exception
}

package travelactivitytypes{
}

package parser{
}

package ui{
}




OmniException --|> Exception
CheckParameters ..> OmniException
CheckParameters --> ui
parser --> CheckParameters
travelactivitytypes --> CheckParameters


@enduml
25 changes: 25 additions & 0 deletions docs/team/TravelActivityTypeClassDiagram.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
@startuml
'https://plantuml.com/class-diagram
skinparam packageStyle rectangle
hide class members
package travelactivitytype{
class TravelActivity
class Food
class Landmark
class Accommodation
class TravelActivityList
}
Food --|> TravelActivity
Landmark --|> TravelActivity
Accommodation --|> TravelActivity
TravelActivityList --> "*" TravelActivity
TravelActivityList --> ui
parser --> TravelActivityList
package ui{

}

package parser{

}
@enduml
32 changes: 32 additions & 0 deletions docs/team/UpdateFeatureClassDiagram.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
@startuml
'https://plantuml.com/class-diagram
skinparam classAttributeIconSize 0
class OmniTravel{
-invokeCommand(command: String[], line: String, list: TravelActivityList): void
}

class Parser{
+updateCommand(line: String, list: TravelActivityList): void
}
class CheckParameters{
+updateExceptions(command: String[], line: String): void
+containsWords(input String): void
}
class TravelActivityList{
+updateTravelActivity(travelActivityNumber: int, date: LocalDate, duration: String, tag: String): void
}
class TravelActivity{
+setDate(date: LocalDate): void
+setDuration(duration: String): void
+setTag(tag: String): void
}
class Ui{
+printLine(): void
}
OmniTravel ..> Ui
OmniTravel ..> Parser
Parser --> TravelActivityList
TravelActivityList --> "*"TravelActivity
TravelActivityList ..> CheckParameters

@enduml

0 comments on commit 40c4d77

Please sign in to comment.