Git Product home page Git Product logo

amerbank-test's Introduction

amerbank

Interview test

Using microservices, we will solve the following tasks:

Create a login and registration system.

Features

  1. Users can have two roles: admin and user
  2. They should be able to choose role upon registration
  3. Tests for login routes and services

Messages

From the feature we can infer the messages we will need in our microservices system and we can also assign it a microservice:

Feature Message
register role:user,cmd:register
login role:user,cmd:login

For simplifying the design we will choose to have one microservice handling both create and get user messages.

Thankfully, SenecaJS already has user, auth and admin plugins. The seneca-auth plugin is not anymore usable with the new seneca-web versions which now has its own auth system in place.

Secure Microservices World

In order to have a secure web site, we'd like to run our microservices in a protected environment. Our microservices should not be called from the internet. In AWS we can create private clusters with k8s and kops, whose instances will not be accessible from outside the cloud. To send messages into our microservices world we'll have an interface API as a bridge from internet HTTP requests and our private instances. See below an illustration of that design.

global-design

The user's role will be stored in the name field of the user entity provided by seneca user's plugin.

Testing

Microservices

The seneca user's plugin is already tested. It does not make sense to do further test for that module. However, a sample test is still to be found in ./services-test/user-login/test.js.

Routes

The routes are supposed to call the microservices API gate to enter into our microservices world.

We want to check that the microservice API is called the right way.

Create a comment system for registered users

Features

  1. It should be a tree-style comment system
  2. No limitation to the depth of the comments
  3. Comments need approval from admins
  4. Tests for login routes and services

Messages

Here as in the section above we will define our messages:

Feature Message
list comments role:comment,cmd:list
post comment role:comment,cmd:save
reply to a comment role:comment,cmd:reply
approve comment role:comment,cmd:approve

The messages are quite simple and bound to our business valued features. They will be implemented in the comment microservice.

Application

Services design

services-design

Commands

Open the shell and place yourself in the project's directory first.

Command name Command
Start project npm start
Monitor services npm run monitor
Run tests npm test
Run Front End npm run start-ng

Configuration

Ports

App Port
front API 4222
gate Service 4333

TODOs

Look for TODO notes within the code with a simple git grep and you'll find some unresolved dilemmas.

Current TODOs
services/comment/plugin.js:        //TODO
services/comment/plugin.js-        // the plugin 'seneca-store-query' enables to
services/comment/plugin.js-        // do 'or' queries with mysql and postgres...

amerbank-test's People

Contributors

davd33 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.