Skip to content

sequence diagrams

Mustafa Atik edited this page Dec 18, 2016 · 10 revisions

Sequence Diagrams

In this wiki page, you can find sequence diagrams which show interactions between system components in an ordered way. To draw these diagrams shown below, an online sequence diagrams tool, https://www.websequencediagrams.com/, is used.

title A user is typing
Dashboard->RESTful API: GET /api/foods/?q=keyword\nask for matching food names
RESTful API->SuggestionView: view.get(request)
SuggestionView->SuggestionView: keyword = request.params["q"]
SuggestionView->USDA API: fcd.find(keyword)
USDA API-->SuggestionView: foods = [matching food names]
SuggestionView->EntryModel: objects.all(user=request.user)\fetch user's past consumptions\n matching the query
EntryModel-->SuggestionView: history = [food consumptions]

SuggestionView->Recipes: objects.all(user=request.user)\get history of user
Recipes-->SuggestionView: recipes = [food consumptions]

SuggestionView-->SuggestionView: result = [recipes + history + foods] \n merge the three results
RESTful API-->Dashboard: HTTPResponse(result)

GET_food_suggestions

title A user selects a food name on the suggestion
User->Dashboard: select a food name
Dashboard->RESTful API: <<HTTP GET Request>>\n/api/food/{{ndbno}}/measures/
RESTful API->FoodReport: redirect request
FoodReport->USDA API Wrapper: get_measures(ndbno)
USDA API Wrapper->USDA API: get a full report by ndbno
USDA API-->USDA API Wrapper: full report of associated food
USDA API Wrapper-->USDA API Wrapper: extract measures
USDA API Wrapper-->FoodReport: list of possible measures
FoodReport-->FoodReport: format the result
FoodReport-->Dashboard: <<JSONResponse(...)>>\nmatching names
Dashboard-->User: update measure selection form 

GET_measures

title A user is adding his/her consumption
User->Dashboard: submit consumption form
Dashboard->RESTful API: <<HTTP POST Request>>\n/api/entries/
RESTful API->EntryView: redirect request
EntryView->EntryView: entry.save()
EntryView->EntryView: insert_nutrients(entry, post)
EntryView->USDA API Wrapper: get_nutrients(ndbno)
USDA API Wrapper-->USDA API: fetch full report
USDA API-->USDA API Wrapper: full report of associated food
USDA API Wrapper-->USDA API Wrapper: extract measures
USDA API Wrapper-->EntryView: full report
EntryView-->EntryView: calculate nutrients by selected measure
EntryView-->Dashboard: <<JSONResponse(...)>>\nentry
Dashboard-->User: show consumption entry to user

POST_consumption

title A user is typing an activity name
User->Dashboard: typing activity name
Dashboard->RESTful System: ask for matching activity names
RESTful System->ActivityDB: query activity names
ActivityDB-->RESTful System: matching activity names
RESTful System-->RESTful System: format the result
RESTful System-->Dashboard: matching activity names
Dashboard-->User: display a suggestion list
title A user is adding his/her activity
User->Dashboard: submit activity form
Dashboard->RESTful System: post form data
RESTful System-->RESTful System: calculate energy burnt
RESTful System->Database: save activity as an entry
RESTful System->Database: save outtake nutrients
RESTful System-->Dashboard: activty entry record
Dashboard-->User: display the activty \nin the entry list
title A user is displaying consumption history
User->Dashboard: display consumption history view
Dashboard->RESTful API: <<HTTP GET Request>>\n/api/entries/
RESTful API->EntryView: redirect request
EntryView->EntryModel: Entry.objects.all()
EntryModel->EntryView: list of entries
EntryView-->Dashboard: <<JSONResponse(...)>>\n entry list
Dashboard-->User: show entries to user

GET_entries

title A user is updating his or her weight
Dashboard->RESTful API: HTTP POST /api/weights/\n{date: "2016-01-12", weight: 73.2}
RESTful API->UserWeightView: view.create(request)

UserWeightView->UserWeightView: date = request.POST["date"]
UserWeightView->UserWeightView: weight = request.POST["weight"]
UserWeightView->UserWeightView: user = request.user
UserWeightView->UserWeightModel: model.create(user, date, weight)
UserWeightModel-->UserWeightView: record = model instance

UserWeightView-->RESTful API: response
RESTful API-->Dashboard: HTTPResponse(record)

@TODO add image view

Clone this wiki locally