When it comes to enterprise APIs, there are some must-have aspects like scalability, maintainability, documentation, test automation, CI/CD, monitoring, and more. Adopting a microservice architecture can help teams and companies to leverage some of the mentioned aspects and this is the reason why it became so popular nowadays. For sure microservices comes with a price and not everything is vanilla ice, it demands developers to think a bit out of the code and gain skills that go beyond being a good coder. Developers need to have skills related to infrastructure, containers, messages queues, api-gateway, logging, traceability, cache and cache invalidation, auth-protocols. You may say that some of these skills are also demanded in a big monolithic. But they do are required for having at least a decent microservice approach.
This tutorial goal is to use examples and a concreted use case to transmit a simple but professional Know-how for building enterprise quality software using microservices. We are going to touch with practical example, videos and code what I consider are the basic must to have pieces of architecture and skills that developer should know.
To go throw the tutorial we are going to follow a small use case solution for a “Trip Agency”. Basically it is about a system that allows the management of Customers and a pool of holiday offers. The system must support the creation of bookings(Association between Customers and a Holiday Offer). The APIs should also consider a role base authentication system for Administrators and Tour Operators.
Architecture Diagram for the use case solution
- Introduction to Microservices.
- Tech stack discussion for Trip Agency.
- Creating our first customer-api express version 1.
- Containerizing NodeJS with Docker.
- Containers Orchestration with docker-compose.
- Conceptualizing and mocking the customer-api
- Initial dev Setup: VSCode, Linting etc.
- Creating swagger.yaml specification for customer-api.
- Swagger based development driving.
- Express base application with Scaffolding from scratch.
- Having a mocked API ready to use in minutes with express-swagger-middleware.
- Real TDD
- Automatic test generation base on swagger using oatts.
- Improving auto generated oatts test with json templates.
- Lines code coverage with nyc.
- Coding Part I
- Mongoose Model.
- Coding customer-api controllers, step by step using TDD.
- Errors and Global Async Error Handling
- Swagger UI Browser services to expose and document our rest APIs.
- Coding Part II
- Introduction to Elasticsearch as object store and search engine for holidayHub-api.
- Creating holidayHub-api swagger specification.
- Using TDD to implement our holidayHub-api Microservices.
- Deployment and CI/CD
- Orchestration of the overall stack and customer-api for local testing using docker-compose.
- Introduction to Gitlab CI/CD(jobs, runners and registry).
- Gitlab stage for building check lint, test and deploying local .using own runners(Docker in Docker or Shell).
- Kubernetes Introduction and helm.
- How to deploy NodeJs application to kubernetes.
- Deploy from gitlab to kunernetes.
- AWS Deployment
- Using ECR as container registry.
- Deploying microservices using ECS.
- Configuring the Application Load balancer.
- Using AWS api-gateway
- Coding Part III
- Implementing booking-api Microservice with MongoDB
- Authentication and Authorization
- Deploying keycloak as Identity and Access Management in our Microservices infrastructure.
- Creating users and roles for Trip Agency
- API gateway
- Introduction to api-gateway.
- Having a reliable API gateway in NodeJS.
- Authentication check and base Authorization at the api-gateway entry level.
- Handling cache at the api-gateway level.
- Why to expose the APIs behind the api-gateway.
- Metrics and Monitoring
- Deploy APM dashboard into our kubernetes cluster.
- Adding apm-agent to our NodeJS Microservices to expose metrics and logs.
- Creating some basic dashboard for monitoring and alerts.
- Intro to Graphql and Apollo server.
- Graphql gateway implementation.
- Autogenerated graphql endpoint from swagger rest APIs.
- Extending graphql queries and mutations.
- Event Driving Microservices and Messages Queues
- Introduction to amqp protocol
- Deploying a RabitMQ server into our Kubernetes infrastructure.
- Conecting to RabitMQ from our NodeJS Microservices.
- Publishing and Consuming events from our Microservices.