DEV Community

Cover image for Let's create microservices system from scratch - series intro
DigitalCrafting
DigitalCrafting

Posted on • Edited on

Let's create microservices system from scratch - series intro

Intro

Well, the title seems like a bold statement, so let's clarify what I mean by microservices system. I do not mean a framework of any kind to be used in production, only a project to learn about the challenges of the microservices architecture and how it might work under the hood.

I do not intend this series to be step by step guide since it would probably be at least 100 articles long by the end. I will, instead, try to write about design choices, how to write some of the mechanisms and highlight some interesting problems (from full stack developer point of view) I stumble upon along the way.

What are we building

First of all, what type of system are we aiming for ? This will determine what kind of services we will need, as well as non-functional requirements of the system.

Recently I've been playing Middle-earth: Shadow of War and I thought to myself: why not create management application for the Saurons army ? Hence the idea for The One System to Rule Them All (The One for short). Then I decided to turn it into a learning experience and so I will not limit myself to Java and Angular which I know, but will also try to learn other languages along the way.

Technology stack

The technologies I intend to use and learn at least the basics of, are:

  1. For services:
    • Java (Zulu) and Spring BOOT (there is a limit to what I can write from scratch ;))
    • Haskell - because I never used Functional Language before
    • Python - because it's widely popular
    • GoLang - because why not
  2. For frontend:
  3. For deployment:
  4. Architecture pattern:

Now, having decided that for a start, are we going to use libraries such as Netflix Hystrix, Ribbon ? Are we going to use RabbitMQ ? Well, no. Since this is a learning experience, we will try to implement it ourselves. It may not end up being the best code ever, but it will give us overview of how this libraries are implemented which in turn, can help us debug or implement other solutions better in the professional life.

The architecture (v0.0.1)

Ok, having more or less decided on the tech stack, we now need to design the actual architecture. The One is basically a resources management system where the resources range from uruks through the outposts up to the food chains and weapon storages.

Every management system needs to have some kind of users database to allow access control, authentication and authorization services and UI app to allow user friendly access. But since the chosen architecture is microservices, we cannot simply write one Spring BOOT app and be done with it, we also need:

  • API Gateway to connect to different services
  • Service Discovery to allow us dynamically starting and stopping services
  • Logger Service to aggregate logs from every service
  • Service monitoring
  • And a few other things

The basic diagram will look like this (I omitted some things in order to make it a little smaller):

Alt Text

It may seem like it won't be much work - and normally in a company it probably wouldn't - but we are going to build this from scratch, therefore, the first milestone will be:

  1. Create API Gateway Service, that proxies requests to User Service, to address obtained from Service Discovery.
  2. User Service and API Gateway will wait for Service Discovery startup before starting themselves.
  3. After startup, User Service will register itself with Service Discovery, passing the IP and PORT on which it's available.
  4. There will be script to build and run everything either locally or using docker.

Summary

I think the milestone we've set for ourselves is relatively easy but will be a bit challenging to implement from scratch :) See you in the next part.

Here's the repo for this project. Feel free to copy it and tinker around :)

Top comments (0)