I was really happy to do this technical test, which by its openness allows a great freedom of technical choices. I hope that my choices and my work will satisfy you. Thank you for your time :)
- Typescript is the main language
- Install docker & docker-compose
- Install make package
make install
installs the applicationmake start_dev
run the dev server- CHANGES.md
scalar Date
type User {
id: ID!
firstName: String!
lastName: String!
email: String!
picture: String
}
type Forum {
id: ID!
name: String!
forumUsers: [ForumUser]
}
type ForumUser {
id: ID!
user: User!
forum: Forum!
}
type ForumMessage {
id: ID!
content: String!
forum: Forum!
forumUser: ForumUser!
sendedAt: Date!
}
type Query {
user(id: ID!): User
forums(q: String): [Forum]
forum(id: ID!): Forum
myForums: [Forum]
forumUsers(forumId: ID!): [ForumUser]
forumMessages(forumId: ID!): [ForumMessage]
}
type Mutation {
updateProfile(firstName: String!, lastName: String!, picture: String): User
createForum(name: String!): Forum
joinForum(forumId: ID!): ForumUser
postMessage(forumId: ID!, content: String!): ForumMessage
}
You are going to need:
git
docker
docker-compose
make
- Install git
- Install docker
- Install docker-compose
- Install make
make install
The test suite can be run with:
make test
make start_dev
✌️ DB loaded and connected!
🚀 Server ready at http://localhost:4000/graphql
📦coding-challenge-gameloft
┣ 📂.husky => pre-commit hooks
┣ 📂docker => docker configuration files
┣ 📂src
┃ ┣ 📂app
┃ ┃ ┣ 📂config => app configurations
┃ ┃ ┣ 📂dev
┃ ┃ ┃ ┣ 📜authenticator.ts => singleton default user accesor
┃ ┃ ┃ ┗ 📜fixtures.ts => fixtures loader
┃ ┃ ┗ 📜app.ts => main app class
┃ ┣ 📂domain
┃ ┃ ┣ 📂document => mongodb document schemas
┃ ┃ ┗ 📂graphql => graphql schemas
┃ ┃ ┃ ┣ 📂forum => each schema element is separated in a different file: types, queries, mutations and resolvers
┃ ┃ ┃ ┃ ┣ 📜index.ts
┃ ┃ ┃ ┃ ┣ 📜mutations.ts
┃ ┃ ┃ ┃ ┣ 📜queries.ts
┃ ┃ ┃ ┃ ┣ 📜resolvers.ts
┃ ┃ ┃ ┃ ┗ 📜types.ts
┃ ┣ 📂infra
┃ ┃ ┗ 📂mongodb
┃ ┃ ┃ ┗ 📜mongooseClient.ts => small abstraction for the database connection
┃ ┣ 📂tests => test suite
┣ 📜.eslintrc.json => eslint config file
┣ 📜.nvmrc => nvm config file
┣ 📜Makefile => commands orchestrator
┣ 📜docker-compose.yml => docker-compose config file
┗ 📜tsconfig.json => typescript config file
All files and folders have not been listed here for readability.
I choose to go with the DDD approach, and add a much better decoupling compared to a classic NodeJS app.
A key concept of this architecture is therefore to put all the business logic in a single place called the domain (hexagon), which depends only on itself; this is the only way to ensure that the business logic is decoupled from technical layers. So all our graphQL resolvers and schemas are placed in the src/domain/
directory.
I also chose to use a NoSQL database to store the data, with MongoDB, to present a more realistic application.