You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I started by registering an account on Doodle and playing around a bit with my dashboard. Creating polls, participating in them as different users, checking out the request to `https://api.doodle.com/v2.2/users/me/polls` and its response.
32
+
5
33
### Analysys
6
-
After analyzing polls.json, I came up with a rough relational DB schema and some ideas about the tech stack.
34
+
After analyzing polls.json, I came up with the two tables I need to create to complete the tasks.
35
+
36
+
### User stories
37
+
38
+
39
+
### 1. List all polls created by a user
40
+
Create an endpoint that takes an integer `userId` param and returns with an empty list or a list of polls that the user created
41
+
42
+
### 2. Search polls by its title
43
+
Create an endpoint that takes a string `title` param and returns with an empty list or a list of polls with the exact title
44
+
45
+
### 3. List all polls created after a certain date
46
+
Create an endpoint that takes an ISO date `date` in param and returns with an empty list or a list of polls with `initiated` post the date param.
47
+
As a timestamp, the date 2020-01-01 is 2020-01-01 00:00, so an initiated timestamp of 2020-01-01 01:00 is 'after' 2020-01-01
48
+
7
49
## Technology choices
8
50
### Visual Studio Code + Remote Development / Dev Containers
9
51
With VS Code Remote Development, you can use a Docker container as a full-featured development environment. VS Code is going to work **as if it was running locally on the Linux container** I chose to develop on. Other tools offer similar solutions of course (mounting the workspace, hot-reload), but I find the extreme approach of hooking the entire "IDE" into a container quite inspiring.
@@ -18,12 +60,24 @@ Nothing really comes close.
18
60
19
61
### PostgreSQL
20
62
Easy integration with Java, UUID as primary key natively, can index JSON objects.
63
+
***
64
+
## If I had more time...
65
+
I would
66
+
- Test more!
67
+
-*Observability*: request tracing and logging for both the DB and the service
68
+
- Performance:
69
+
- Add an index for the `title` and `initiated` column (if we want it them be really fast)
70
+
- Consider replacing Tomcat with Undertow (slightly better throughput afaik)
71
+
- Based on polls.json, the database has a lot more tables than what I modeled. We could consider preloading some sort of cache storage (probably NoSQL) as the poll is created
72
+
- Read heavy system calls for read replicas
73
+
- Refactorings:
74
+
- Find a better home for `SearchQuery.java`
75
+
- Add some sort of linting / auto formatter
76
+
- If only I could find some automapping from Postres snake_case to camelCase...
77
+
- Nicer `docker-compose`: Work on making it a bit more configurable production ready, like using the devcontainer image for building and a jre image for running
78
+
79
+
## What I'd do differently
21
80
22
-
## User stories
23
-
### 1. List all polls created by a user
24
-
Create an endpoint that takes an integer `userId` param and returns with an empty list or a list of polls that the user created
25
-
### 2. Search polls by its title
26
-
Create an endpoint that takes a string `title` param and returns with an empty list or a list of polls with the exact title
27
-
### 3. List all polls created after a certain date
28
-
Create an endpoint that takes an ISO date `date` in param and returns with an empty list or a list of polls with `initiated` post the date param.
29
-
As a timestamp, the date 2020-01-01 is 2020-01-01 00:00, so an initiated timestamp of 2020-01-01 01:00 is 'after' 2020-01-01
81
+
- Consider dropping the ORM in favour of DTOs: While I had fun with the ORM, some queries into POJOs would have done the job much faster.
82
+
- Have much less trouble using dev containers (First time using them for Java!)
0 commit comments