Code Monkey home page Code Monkey logo

cote-workshop's Introduction

Microservices case study with cote.js

This project aims to show a microservices architecture built with cote.js, an auto-discovery mesh network framework for building fault-tolerant and scalable applications.

It's an example e-commerce application with a complete feature set from admin interface to end user interface, and 4 different microservices for dealing with payments, products, purchases and user management.

The admin interface is implemented on a REST server to demonstrate how cote.js would work within an existing express-based application. Product, user and purchase management is done via REST calls to the admin server, where they are then forwarded to respective microservices.

The client interface is implemented entirely in cote; the server only serves a single index.html. It's a breakthrough implementation, which basically means you can host your website statically (on for example, S3), and have all the benefits of a server and the microservices architecture.

Installation

Run the following commands:

git clone [email protected]:dashersw/cote-workshop.git
cd cote-workshop
npm install
node init-db.js

Getting the system up and running

There are four backend services, an admin interface and an end-user interface.

Quickstart

For the quickest start, have PM2 installed globally and then just type:

pm2 start cote-workshop.json

This will run all the 6 services you need, and you can monitor your services with pm2 monit or use any pm2 commands at your disposal.

Admin interface will be available in http://localhost:5000

End user interface will be available in http://localhost:5001

Monitoring will be available in http://localhost:5555

Navigate to the admin and (multiple) end user interfaces and add / delete / buy some products to see everything updating in real time!

Manual start

Run the admin interface:

node admin/server

Admin interface will be available in http://localhost:5000

Run the end user interface in a separate terminal window (or tab):

node end-user/server

End user interface will be available in http://localhost:5001

Now run the services in separate terminal windows (or tabs):

node services/payment-service
node services/product-service
node services/purchase-service
node services/user-service

Navigate to the admin and (multiple) end user interfaces and add / delete / buy some products to see everything updating in real time!

Monitoring

There's a built-in monitor service which lets you visualize the connections between microservices. The monitoring service is automatically started via pm2, or if you want to manually start it, run:

node monitor.js

It's a simple monitoring GUI, and will be available in http://localhost:5555

Running locally with host names

This repo includes a proxy service which binds on port 80 to host the application via certain host names.

The proxy supports these virtual hosts;

http://local-admin.cotejs.org for the admin interface and redirects requests to localhost:5000.

http://local-end-user.cotejs.org for the end user interface and redirects requests to localhost:5001.

http://local-monitoring.cotejs.org for the monitoring interface and redirects requests to localhost:5555.

Then you have to modify your /etc/hosts file to include 127.0.0.1 local-admin.cotejs.org local-end-user.cotejs.org local-monitoring.cotejs.org. Now when you visit either of these addresses in your browser, you will be redirected to the respective service.

Docker installation

This repository includes a full-featured docker-compose.yml to start all the necessary services including a PostgreSQL database via Docker.

Run the following to launch all services;

docker-compose up

This will build necessary local images and then launch a cluster of services. If you edit your /etc/hosts file to accomodate the given domain names, you can interact with the application via your browser.

cote-workshop's People

Contributors

dashersw avatar drubin avatar robophil avatar fatihacet 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.