Brikl backend engineer assignment
Introducing the Alpha
Alpha is the new startup company we are developing a cutting edge task management system with modern technology.
Functionality
Task management
-
Create a new list via the mutation
createList
that takes as an inputCreateListInput
that includestitle
anduserId
and it returnsList
that includesid
,title
of the created list andcreator
which is user that creates the list. Here are graphQL types respectively.-
List
typetype List { id: Int! title: String! creator: User }
-
createList
mutation call:mutation { createList(input: { title: "todo", userId: "54861299-75de-4fe7-8982-79f55bf127ad", }) { id, title, creator{ id } } }
-
-
Create a new task in a list (the task should be prepended to the list and the status should indicate it has not been completed) via the mutation
createTask
that takes as an inputCreateTaskInput
that includestitle
of task andlistId
that will belongs to. Mutation will returnTask
type that was persisted in database.-
Task
typetype Task { id: Int! title: String! completed: Boolean position: Int list: List }
-
createTask
mutation call:mutation { createTask(input: { title: "init db schema", listId: 1, }) { id, title, completed, position, list{ id } } }
-
-
Update a task (title and status) via mutation
updateTask
that takes as an inputid
of the task andUpdateTaskInput
that holds newtitle
andstatus
of the task> Mutation will returnTask
that with updated fields.updateTask
mutation call:mutation { updateTask(input: { title: "init db schema", status: true, }) { id, title, completed } }
-
Delete a task or list via mutation
deleteList
anddeleteTask
withid
as argument, and returns deletedTask
. -
Move a task to a specific position in the list via mutation
moveTaskToPosition
that takesposition
new task posistion andtaskId
, and returnsTask
with updated position. -
Retrieve all lists and their tasks via query
listsWithTasks
, and it will return all lists with their tasks.listsWithTasks
query call:query{ listsWithTasks{ id, title, creator { id, username }, tasks { title, completed, position } } }
- Result of the query:
{ "data": { "listsWithTasks": [ { "id": 1, "title": "todo", "creator": null, "tasks": [ { "title": "init bd schema", "completed": false, "position": 0 }, { "title": "init graphQL schema", "completed": false, "position": 0 }, { "title": "init code schema", "completed": false, "position": 0 } ] } ] } }
Getting start
Prerequisites
Make sure you have these tools installed
- Docker
- Node.js
- Node package manager, preferably
pnpm
Setup
This is the instruction to setup this project and run in your local machine. Note that this instruction uses pnpm
as a package manager. You may replace these commands corresponding to your package manager.
- Install dependencies.
- Run
docker compose up -d
to start docker containers in background. - Run
pnpm db:migrate
to initiate database. - Run
pnpm codegen
to generate TypeScript definition for GraphQL and Prisma client. - Run
pnpm start
to start the project. - Go to
http://localhost:4000
, you should see Apollo Playground with several queries. You may change the port according toGATEWAY_PORT
in your.env
file. You may change ports of the other microservices serversUSER_SERVICE_PORT
,LIST_SERVICE_PORT
orTASK_SERVICE_PORT