This repository solves the Teravoz's fullstack challenge
Currently deployed to https://teravoz-challenge-grxovemtdu.now.sh/
Read the tasks answers 1, 2, 4 here
Task3 requirements and solutions
So your Node.js application has to do the following:
-
Listen to events emitted by Teravoz at /webhook endpoint. Events are and come in the following order: call.new, call.standby, call.waiting, actor.entered, call.ongoing, actor.left, call.finished. Those are life cycle events of a call.
-
When an event of type call.standby arrives, you need to delegate that call based on the given criteria above, by POSTing to Teravoz API's /actions endpoint
See call-delegate-logic, Test: Calls from returning customers are delegated to 901, Test: Calls from new customers are delegated to 900, IntegrationTest: Call delegation
-
When app is restarted, it needs to work as if it hasn't at all - returning customers will always be returning customers
See On state change save to disk, On app restart load state from disk, IntegrationTest: Restart server
-
[bonus 1] use of Docker containers
See Dockerfile, docker-compose, apps/api/Dockerfile, apps/dashboard/Dockerfile, apps/teravoz-api-fake/Dockerfile
-
[bonus 2] a little dashboard in React or other library, showing current active calls
This is a react application that allows us to simulate calls and see active calls.
-
Unfortunately, Teravoz doesn't have a sandbox environment which you could use for interacting with, so you need to mock the required interaction between your application and Teravoz API. For example, you need to simulate POSTs to your /webhook endpoint.
This application is a fake teravoz API.
Please install docker and docker-compose;
$ docker-compose build
$ docker-compose up
Open in your browser http://localhost:5000
Install now-cli
$ now --docker --public
How it works
This Dockerfile is special because in a single container we launch all 3 applications, i.e 3 differente node processes. We use pm2 and this config to manage all processes.
Install the most up-to-date node.
The Dockerfile of all application use node10. See apps/api/Dockerfile The applications rely on async/await synxtax (node8+) and we also use the new URL builtin;
This repository contains 3 different applications:
- apps/dashboard: A little dashboard in React, showing current active calls.
- apps/api: Exposes current active calls via http and handle teravoz event by exposing a /webhook endpoint.
- apps/teravoz-api-fake: A http service that mimics the teravoz api and provides simulation goodies.
Each application is a docker container and meant to be deployed separatedly. For instance using now.
This is a monorepo made using lerna to manage multiple packages. Also I'm not using yarn because of some lerna issues.
Even though there's no shared packages for this trivial application, the monorepo structure is convenient to use a single linting and formatting set of rules.
We use eslint + prettier to quite the good pretty. Take a look at .prettierrc and .eslintrc.json for details.
- Read the challenge specification
- Read the docker-compose to see how apps interact with each other.
- Read the source code of integration tests to get a feel how the api works
- Read the source code for the call-delegation-logic
- Read the source code for all routes:
- api: POST /webhook
- api: GET /calls/active
- teravoz: POST /actions
- teravoz: POST /simulation/call/new
- teravoz: POST /simulation/start
- teravoz: POST /simulation/stop
- teravoz: GET /simulation/status
- Read the Notable Packages section.
- Read apps/api README in particular Services Model
- Read apps/dashboard README in particular Architecture Decisions