Skip to content

ContextCore/MightyCalc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Mighty Calculator

MightyCalc is a demo project to show usage of Akka cluster and DDD/ES/CQRS design in the real world.

MightyCalc is a calculator app with REST API. It provides basic functionality like:

  • Perform calculations (add, subtract, multiply, divide, square root, cube root, power, and factorial).
  • A report showing the operations that have been done during the given period
  • Allow user to add its own functions

Usage

MightyCalc exposes SwaggerUI for human interaction. Check online example or run MC locally and go to http://localhost:30010.

Deployment

MightyCalc is designed for Kubernetes deployment but doesn't depend on k8s-specific features. So it could be deployed by any other tools supporting Docker containers. To deploy MC to k8s use environment creation script. It supports several k8s providers, like Google Kubernetes Engine, Docker for Desktop, and Minikube.

Each component is shipped as Docker image, you can find it on docker hub. Images are built by CI\CD pipeline

Components

MightyCalc consists of four main components:

  • API nodes - expose REST API and delegate all the work to worker nodes. Uses the database to get reports data. Exposes SwaggerUI generated by API reference Implemented with Asp.Net Core and Akka.Net.
  • Worker nodes - perform the calculation requested by API, implement the business logic in CQRS/ES/DDD manner.
  • Database - PosgreSQL database instance. Hosts three databases: journal, readmodel, snapshotstore
  • Seed nodes - used to form Akka cluster and connect API nodes to Worker nodes.
  • C# API Client - provides a library for REST API access, autogenerated from API reference.

Maintainance

Api, worker and seed nodes host Petabridge.Cmd, and it can be used to get various useful information and perform operations. Like get the current cluster status.

Usage example, from the k8s host:

kubectl exec -it seed-0 -- /bin/bash        
pbm localhost:9110  

Build

MightyCalc is supposed to run build as a part of Docker image creation. A single Dockerfile will can produce several components: api, seed and worker nodes, test pod. See build command examples at CI/CD pipeline.

API is determined by OpenAPI specs, swaggerUI and the client will be generated out of it during the build.