Fakultas Ilmu Komputer UI

README.md 4.64 KB
Newer Older
WILLIAM GATES's avatar
WILLIAM GATES committed
1
2
# Home Industry API

WILLIAM GATES's avatar
WILLIAM GATES committed
3
4
[![pipeline status](https://gitlab.cs.ui.ac.id/ppl-fasilkom-ui/2020/ppl-c/diskominfo-depok-tpu-online/post-rpl-backend/badges/master/pipeline.svg)](https://gitlab.cs.ui.ac.id/ppl-fasilkom-ui/2020/ppl-c/diskominfo-depok-tpu-online/post-rpl-backend/commits/master)
[![coverage report](https://gitlab.cs.ui.ac.id/ppl-fasilkom-ui/2020/ppl-c/diskominfo-depok-tpu-online/post-rpl-backend/badges/master/coverage.svg)](https://gitlab.cs.ui.ac.id/ppl-fasilkom-ui/2020/ppl-c/diskominfo-depok-tpu-online/post-rpl-backend/commits/master)
5
6
7

## Table of Contents

WILLIAM GATES's avatar
WILLIAM GATES committed
8
9
10
11
12
- [Environment Variables](#environment-variables)
  - [Local](#local)
  - [CI](#ci)
  - [Staging](#staging)
  - [Production](#production)
13
14
15
16
- [Local Configuration](#local-configuration)
- [Deployed API URLs](#deployed-api-urls)
- [API Documentation](#api-documentation)

WILLIAM GATES's avatar
WILLIAM GATES committed
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
## Environment Variables

### Local

Key | Required | Example
--- | --- | ---
`DATABASE_HOST` | yes | `127.0.0.1`
`DATABASE_NAME` | yes | `home_industry`
`DATABASE_PASSWORD` | yes | `postgres`
`DATABASE_PORT` | yes | `5432`
`DATABASE_USER` | yes | `postgres`
`DEBUG` | no | `True`
`DJANGO_SETTINGS_MODULE` | yes | `home_industry.settings.local`
`SECRET_KEY` | yes | `7&s33ax$lxxzti1)0y=8#tu!$7bdy)p$1@kn06tp&8x8i9#h2u`

### CI

Key | Required | Example
--- | --- | ---
`DJANGO_SETTINGS_MODULE` | yes | `home_industry.settings.ci`
`SECRET_KEY` | yes | `7&s33ax$lxxzti1)0y=8#tu!$7bdy)p$1@kn06tp&8x8i9#h2u`

### Staging

Key | Required | Example
--- | --- | ---
`AWS_ACCESS_KEY_ID` | yes | `AKIAIOSFODNN7EXAMPLE`
`AWS_REGION_NAME` | yes | `ap-southeast-1`
`AWS_SECRET_ACCESS_KEY` | yes | `wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY`
`AWS_STORAGE_BUCKET_NAME` | yes | `homeindustry-api`
WILLIAM GATES's avatar
WILLIAM GATES committed
47
`DATABASE_URL` | yes | `postgres://postgres:postgres@ec2-117-21-174-214.compute-1.amazonaws.com:5432/home_industry`
WILLIAM GATES's avatar
WILLIAM GATES committed
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
`DEBUG` | no | `True`
`DJANGO_SETTINGS_MODULE` | yes | `home_industry.settings.staging`
`HOME_INDUSTRY_ADMIN_SITE_URL` | no | `https://homeindustry.com/admin/`
`HOME_INDUSTRY_ADMIN_SITE_USER_PATH` | no | `users/`
`HOME_INDUSTRY_ADMIN_SITE_PRODUCT_PATH` | no | `products/`
`HOME_INDUSTRY_ADMIN_SITE_TRANSACTION_PATH` | no | `transactions/`
`HOME_INDUSTRY_ADMIN_SITE_PROGRAM_PATH` | no | `programs/`
`HOME_INDUSTRY_ADMIN_SITE_PROGRAM_DONATION_PATH` | no | `program-donations/`
`SECRET_KEY` | yes | `7&s33ax$lxxzti1)0y=8#tu!$7bdy)p$1@kn06tp&8x8i9#h2u`

### Production

Key | Required | Example
--- | --- | ---
`AWS_ACCESS_KEY_ID` | yes | `AKIAIOSFODNN7EXAMPLE`
`AWS_REGION_NAME` | yes | `ap-southeast-1`
`AWS_SECRET_ACCESS_KEY` | yes | `wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY`
`AWS_STORAGE_BUCKET_NAME` | yes | `homeindustry-api`
`DATABASE_HOST` | yes | `127.0.0.1`
`DATABASE_NAME` | yes | `home_industry`
`DATABASE_PASSWORD` | yes | `postgres`
`DATABASE_PORT` | yes | `5432`
`DATABASE_USER` | yes | `postgres`
`DJANGO_SETTINGS_MODULE` | yes | `home_industry.settings.production`
`HOME_INDUSTRY_ADMIN_SITE_URL` | no | `https://homeindustry.com/admin/`
`HOME_INDUSTRY_ADMIN_SITE_USER_PATH` | no | `users/`
`HOME_INDUSTRY_ADMIN_SITE_PRODUCT_PATH` | no | `products/`
`HOME_INDUSTRY_ADMIN_SITE_TRANSACTION_PATH` | no | `transactions/`
`HOME_INDUSTRY_ADMIN_SITE_PROGRAM_PATH` | no | `programs/`
`HOME_INDUSTRY_ADMIN_SITE_PROGRAM_DONATION_PATH` | no | `program-donations/`
`SECRET_KEY` | yes | `7&s33ax$lxxzti1)0y=8#tu!$7bdy)p$1@kn06tp&8x8i9#h2u`

80
81
## Local Configuration

WILLIAM GATES's avatar
WILLIAM GATES committed
82
- Install Python 3.6 or higher and PostgreSQL
83
- Create Python virtual environment
WILLIAM GATES's avatar
WILLIAM GATES committed
84
85
86
87
88
89
  ```bash
  $ cd /path/to/project/directory
  $ python3 -m venv env
  $ source env/bin/activate
  $ pip3 install -r requirements.txt
  ```
90
- Create PostgreSQL database
WILLIAM GATES's avatar
WILLIAM GATES committed
91
- Set up environment variables (change as needed)
WILLIAM GATES's avatar
WILLIAM GATES committed
92
93
94
95
96
97
98
99
100
  ```bash
  $ export DATABASE_HOST='127.0.0.1'
  $ export DATABASE_NAME='home_industry'
  $ export DATABASE_PASSWORD='postgres'
  $ export DATABASE_PORT='5432'
  $ export DATABASE_USER='postgres'
  $ export DJANGO_SETTINGS_MODULE='home_industry.settings.local'
  $ export SECRET_KEY='7&s33ax$lxxzti1)0y=8#tu!$7bdy)p$1@kn06tp&8x8i9#h2u'
  ```
101
- Migrate the database
WILLIAM GATES's avatar
WILLIAM GATES committed
102
103
104
  ```bash
  $ python3 manage.py migrate
  ```
105
106
- Set up API configuration by modifying `api_config.yaml`
- Create or update the API configuration in database
WILLIAM GATES's avatar
WILLIAM GATES committed
107
108
109
110
111
112
113
  ```bash
  $ python3 manage.py createorupdateapiconfig
  ```
- Create Superuser
  ```bash
  $ python3 manage.py createsuperuser
  ```
WILLIAM GATES's avatar
WILLIAM GATES committed
114
115
116
117
- Run server
  ```bash
  $ python3 manage.py runserver
  ```
118
119
120

## Deployed API URLs

WILLIAM GATES's avatar
WILLIAM GATES committed
121
122
- Staging: [https://industripilar-staging.herokuapp.com](https://industripilar-staging.herokuapp.com)
- Production: [https://api.industripilar.com](https://api.industripilar.com)
123
124
125

## API Documentation

WILLIAM GATES's avatar
WILLIAM GATES committed
126
[https://industripilar-staging.herokuapp.com/docs/](https://industripilar-staging.herokuapp.com/docs/)