Fakultas Ilmu Komputer UI

README.md 6.15 KB
Newer Older
Kefas Satrio Bangkit Solideantyo's avatar
Kefas Satrio Bangkit Solideantyo committed
1
2
[![pipeline status](https://gitlab.cs.ui.ac.id/ppl-fasilkom-ui/2021/DD/pt-gizi-sehat-dietela/dietela-backend/badges/staging/pipeline.svg)](https://gitlab.cs.ui.ac.id/ppl-fasilkom-ui/2021/DD/pt-gizi-sehat-dietela/dietela-backend/-/commits/staging) [![coverage report](https://gitlab.cs.ui.ac.id/ppl-fasilkom-ui/2021/DD/pt-gizi-sehat-dietela/dietela-backend/badges/staging/coverage.svg)](https://gitlab.cs.ui.ac.id/ppl-fasilkom-ui/2021/DD/pt-gizi-sehat-dietela/dietela-backend/-/commits/staging)

3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
## Dietela Mobile Application (Backend)

This repository contains codebase for Dietela backend system

### About Dietela

Dietela is an Android-based application that provides personalised diet and online nutritionist consultation services.

### How to Run

1. Clone dietela-backend repository from gitlab

```
git clone https://gitlab.cs.ui.ac.id/ppl-fasilkom-ui/2021/DD/pt-gizi-sehat-dietela/dietela-backend.git
```

2. cd into the project directory

```
cd dietela-backend
``` 

3. Install virtualenv if it doesn’t exist yet

```
pip install virtualenv
```

4. Prepare and activate a Python virtual environment

Windows
```
virtualenv venv
venv\Scripts\activate
```

Linux
```
virtualenv env
source env/bin/activate
```

5. Install required packages

```
pip install -r requirements.txt
```

6. Create a postgres database called dietela-backend for the main local database

```
# Login to your postgres account
CREATE DATABASE dietela_backend;
```

7. Create a postgres database called test-dietela-backend for the testing local database

```
# Login to your postgres account
CREATE DATABASE test_dietela_backend;
```

8. Create a `.env` file inside the root project, copy the variables below and configure it according to your postgres username and password:

```
DATABASE_URL=postgres://<username>:<password>@127.0.0.1:5432/dietela_backend
TEST_DATABASE=test-dietela_backend
```

9. Do database migrations

```
python manage.py migrate
```

10. Run

```
python manage.py runserver
```

### Deployment

1. Create a Heroku application through heroku.com

2. Setup postgres database in Heroku

    Create 2 postgres database add-ons through the heroku app’s resources page.
    
    One will be used for production and the other for testing.

3. Set CI/CD script by creating .gitlab-ci.yml file

    Create stages needed

    For this case, the stages are `test` for testing, `sonar-scanner` for sonar scanner, and `deploy` for deployment

    View [this file](https://gitlab.cs.ui.ac.id/ppl-fasilkom-ui/2021/DD/pt-gizi-sehat-dietela/dietela-backend/-/blob/staging/.gitlab-ci.yml) for reference

4. Set variables needed in .gitlab-ci.yml file at Settings > CI/CD > Variables
 
    HEROKU_APIKEY = `your api key from your account settings`

    HEROKU_APP_HOST = `the heroku app host or url`

    HEROKU_APPNAME = `the heroku app name`
    
    SONARQUBE_PROJECT_KEY = `the project key of your sonarqube`
    
    SONARQUBE_TOKEN = `the token of your sonarqube`
    
    DATABASE_URL = `your database url from your heroku production database credential`
    
    TEST_DATABASE_URL = `your database url from your heroku testing database credential`
    
    TEST_DATABASE = `the database name from your heroku testing database credential`

5. Configure `settings.py`:

```
import dj_database_url
 
DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
        'TEST': {
            'NAME': os.environ.get('TEST_DATABASE'),
        },
    }
}
 
# Heroku: Update database configuration from $DATABASE_URL.
db_from_env = dj_database_url.config(conn_max_age=600)
DATABASES['default'].update(db_from_env)
```

6. Create `deployment.sh` file

```
#!/bin/bash
python manage.py makemigrations
python manage.py migrate
```

7. Create `Procfile` file

```
migrate: bash deployment.sh
web: gunicorn dietela_backend.wsgi --log-file -
```

8. Commit and push to your repository


### Current Features

- PBI 1: Dietela Quiz & Profile Dietku (Client)

    Clients are required to fill out a quiz related to the design needs of the diet program that will be made by Dietela team

- PBI 2: Dietela Quiz & Profile Dietku (Dietela team)

    Dietela team can store client data to provide quiz results containing programs and nutritionists recommendation to clients

- PBI 3: Choose Plan

    Clients can continue by choosing recommended diet program that is suitable for their needs

172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
- PBI 4: Registration

    Clients can register an account to access Dietela's authenticated-only features

- PBI 5: Login

    Clients can do authentication using a registered account to access Dietela's authenticated-only features

- PBI 6: Logout

    Clients can sign out from the Dietela app

- PBI 7: Checkout

    Clients can choose a diet program and a nutritionist then proceed to do the payment

- PBI 8: Payment Integration

    Clients can perform payment using a third party payment gateway (Midtrans)

192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
- PBI 9: Diet Questionnaire

    Clients can access advanced questionnaire to continue the process of personalizing their diet

- PBI 10: Profile Dietku Nutritionist

    Nutritionists can process the data from the questionnaire filled out by the clients and send it back to related clients

- PBI 11: Profile Dietku Client

    Clients can receive information provided by nutritionists on the Profile Dietku page

- PBI 12: Profile Dietku Tim Dietela/Admin

    Dietela's team can see the recap of client answers to the questionnaire and export the recap of the data in the form of a CSV file
207

208
209
210
211
212
213
214
215
216
217
218
219
220
- PBI 13: Progress Diet Client

    Client can see questions about the diet personalization and answer them for diet report purposes.

- PBI 14: Progress Diet Nutritionist
    
    Nutritionist can receive information about their clients' diet reports and process them to give feedbacks.

- PBI 15: Progress Diet Both Pages
    
    Client can see the Nutritionist's feedbacks and the Nutritionist can edit the feedbacks.


221
222
223
224
225
226
227
228
229
230
231
232
233
### Developers


Team **we fall in love with PPL we cant have**

- Doan Andreas Nathanael - 1806205123
- Glenda Emanuella Sutanto - 1806133774
- Kefas Satrio Bangkit Solideantyo - 1806204972
- Muzaki Azami Khairevy - 1806205470
- Wulan Mantiri - 1806205666

## Acknowledgements
* CS UI - Software Engineering Project 2021