Skip to content

Commit 0101490

Browse files
authored
JY7CI provide documentation (#14)
* JY7CI improving documentation * JY7CI fixing readme * JY7CI fixing readme * JY7CI fixing readme * JY7CI documentation done * JY7CI documentation all finished * JY7CI documentation all finished
1 parent 875ad0f commit 0101490

File tree

1 file changed

+71
-9
lines changed

1 file changed

+71
-9
lines changed

README.md

Lines changed: 71 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,33 +2,83 @@
22

33
## 1. Stack
44

5-
**cross-platform**
6-
**docker**
7-
85
This project was built on top of the following stack:
9-
- **Programming language:** Python (v3.8.3)
10-
- **Framework:** Django (v3.0.8)
11-
- **API:** GraphQL through Graphene
12-
- **Database:** Postgres
6+
- **Programming language:** Python (3.8.3)
7+
- **Framework:** Django (3.0.8)
8+
- **API:** GraphQL
9+
- **Database:** Postgres/Postgis
10+
- **Container:** Docker/Compose
1311

1412
## 2. Installation
1513

14+
In order to make this project cross-platform it was built on top of docker containers.
15+
So please, install it if you don't have it yet.
16+
17+
Docker: https://docs.docker.com/get-docker/
18+
19+
Docker Compose: https://docs.docker.com/compose/install/
20+
21+
Go to project root:
22+
```shell
1623
cd ze-backend-code-challenge
24+
```
1725

26+
Before starting make sure to stop running containers:
27+
```shell
1828
docker stop $(docker ps -a -q)
29+
```
30+
31+
Now build the application:
32+
```shell
1933
docker-compose up -d --build
34+
```
35+
36+
Once it's done, you can check logs by running:
37+
```shell
2038
docker-compose logs -f
39+
```
2140

41+
At this point application must be running already. Access:
2242
http://localhost:8000/admin
2343

44+
Now we need to migrate the database schema:
45+
```shell
2446
docker-compose exec backend python manage.py migrate --noinput
47+
```
48+
49+
In case you want to login to admin you'll need a superuser. Run:
50+
```shell
2551
docker-compose exec backend python manage.py createsuperuser
52+
```
53+
It will ask you for username, email and password.
54+
55+
Running all unit and API tests:
56+
```shell
2657
docker-compose exec backend python manage.py test --keepdb
58+
```
2759

2860
## 3. Challenge resolution
29-
...
61+
Before talking about code I'd like to clarify the development process that I used throughout the project.
62+
63+
First of all, I did the analyses, created tasks and put them on a Kanban Board: https://github.com/muriloacs/ze-backend-code-challenge/projects/1
64+
65+
After that I started creating dedicated branches on Git for each one of those tasks. Each one of them led to a PR: https://github.com/muriloacs/ze-backend-code-challenge/pulls?q=is%3Apr+
66+
67+
I set the Github project to only allow "Squash and Merge" on PRs so the Git history looks crystal clear.
68+
69+
This application is able to create partners and search for them through either an ID or by location.
70+
The location search ensures to seek the nearest partner which the coverage area includes the location.
71+
APIs are exposed through the GraphQL endpoint: http://localhost:8000/graphql.
72+
73+
Database table is properly indexed in order to make search faster.
74+
75+
I tried to keep the project clean and the code readable to humans as I always do :)
76+
77+
Now let's play around with the API: http://localhost:8000/graphql
3078

3179
### 3.1. Create a partner:
80+
Create a partner and copy the returned id so you can use it in the next Query.
81+
```
3282
mutation {
3383
partner(
3484
input: {
@@ -56,8 +106,11 @@ mutation {
56106
}
57107
}
58108
}
109+
```
59110

60111
### 3.2. Load partner by id:
112+
Use here the partner id that was returned in the Mutation.
113+
```
61114
query {
62115
partner (id: "UGFydG5lclR5cGU6MQ==") {
63116
id
@@ -74,10 +127,15 @@ query {
74127
}
75128
}
76129
}
130+
```
77131

78132
### 3.3. Search partner by location:
133+
After saving some partners you can query by location (lat/long).
134+
135+
The search ensures to find the nearest partner which the coverage area includes the location.
136+
```
79137
query {
80-
partner (lat: 9.055862678251549, long: 7.493147848993504) {
138+
partner (location: {lat: 9.055862678251549, long: 7.493147848993504}) {
81139
id
82140
tradingName
83141
ownerName
@@ -92,8 +150,11 @@ query {
92150
}
93151
}
94152
}
153+
```
95154

96155
### 3.4. Search all partners:
156+
In case you want to search all partners.
157+
```
97158
query {
98159
allPartners {
99160
edges {
@@ -114,3 +175,4 @@ query {
114175
}
115176
}
116177
}
178+
```

0 commit comments

Comments
 (0)