DEV Community

Cover image for Building a Microservice Application using C#, ASP.NET Core, Docker & Kubernetes
Marcel Michau
Marcel Michau

Posted on • Edited on

Building a Microservice Application using C#, ASP.NET Core, Docker & Kubernetes

Photo by Anas Alshanti on Unsplash


Hello everyone!

This is my first post on dev.to, so I'm very new to this. :)

I'd like to share something which I built recently.

After reading the .NET Microservices: Architecture for Containerized .NET Applications book, I felt inspired to build something using the concepts I learned in the book. But you know how it goes, I got the old writer's block when deciding what on Earth I'm going to build. I didn't want to write yet another to-do app because I wanted to play around with the Domain-Driven Design (DDD) & Command Query Responsibility Segregation (CQRS) concepts described in the book. A simple to-do app would not have the appropriate domain complexity which would allow me to flex my newly acquired DDD muscle (the muscle in question is still quite small, I've only just gotten into this).

I wanted to tackle a problem which was just complex enough to apply some DDD patterns, but not too complex such that it requires expert knowledge to understand. Therefore, I chose a completely imaginary problem.

How often do you find yourself in the need to decide between multiple options? Whether it's where to go for your next team lunch, which book to read next, which Game of Thrones character to dress up as for Halloween, or how to arrange your Steam wishlist. Don't you wish there was something that could make this decision process easier? Fortunately, there is a method that plenty of industry experts use to gather feedback on specific topics: Surveys. But what if you don't have the time or resources to compile a survey, send it out to multiple respondents, wait for their feedback, consolidate the results and then finally make your decision? This is where Fake Survey Generator comes in...

Fake Survey Generator UI

Yes, the interface is basic, but it's also minimal.

How it works: you capture some basic info about the survey you'd like to create:

Creating a Survey

Click on Create Survey, and the results will be calculated:

Survey Results

There. It's definitive. The community has spoken.

Fake Survey Generator features

The back-end side of the app is built with a variety of frameworks, tools & libraries predominantly centered around the C# .NET stack, while the front-end side is currently a basic React app written in TypeScript. In a nutshell, it's slightly more complex than a to-do app, but it's built as if it were a real-world, production-ready microservice application. Therefore, it uses a real database, has authentication, validation rules, health checks, fault handling, logging, caching, unit tests, integration tests & a CI/CD pipeline that deploys to Kubernetes. In short, overkill.

I mainly built Fake Survey Generator as a platform to teach myself new concepts and to try stuff out, while also serving as a reference application when building new things. There are still plenty of features I'd like to add to the app in due course such as asynchronous messaging using queues, experimenting with GraphQL & gRPC, and adding some more bounded contexts.

Hopefully it can serve as a useful reference for any other .NET devs out there who are interested in topics such as Clean Architecture, DDD, CQRS as well as Docker & Kubernetes.

More information & guidelines on how to run everything can be found on the project README on GitHub:

GitHub logo MarcelMichau / fake-survey-generator

A slightly more-than-trivial full-stack application built with DDD & CQRS concepts

Logo by Undraw

Fake Survey Generator

This is an app. That generates surveys. Fake ones. For fun. That is all

Build Status

Open in github.dev

Screenshot

Screenshot

What is this?

This is a .NET | C# | React | TypeScript full-stack application of moderate complexity (not just a to-do app), used as a playground for experimentation. Simply put: This is where I mess around with code. It is heavily inspired by the .NET Microservices: Architecture for Containerized .NET Applications book, as well as its companion reference application eShopOnContainers. It also incorporates various elements from different repos & blog posts which served as inspiration.

It is built using Vertical Slice Architecture principles with CQRS (Command Query Responsibility Segregation) and DDD ( Domain-Driven Design) thrown into the mix. It doesn't follow these principles to the letter, but provides a decent example of how to apply the basics of these principles.

It is heavily centered…

I'm keen to hear any feedback, and of course, PRs, contributions & suggestions are welcome!

Top comments (2)

Collapse
 
smartcodinghub profile image
Oscar

I saw multiple Azure Pipelines, including Sql Server and Redis. What's your configuration and why? I'm curious.

Collapse
 
marcelmichau profile image
Marcel Michau

Hi Oscar,

Thanks for checking it out! There are three environments the application is deployed to: Integration, Test & Production. For the Test/Production environments the application uses Azure SQL Server as well as Azure Redis Cache. For the Integration environment the application uses SQL Server & Redis deployed as containers in Azure Kubernetes Service, just to check that all the components are wired up correctly.

So the SQL Server & Redis Azure Pipelines are there to package the SQL Server & Redis Helm charts and deploy them to the Integration environment.

Hope that clarifies things a bit.