A few weeks back I started developing the back end for an application I am working on as part of a project for a friend. A semi-formal engagement, this gave me the opportunity to experiment with the technology stack (something I find difficult at work).
In this post I'll outline the technologies I chose. I believe it's a good starting point for new developers looking to build back end services.
Language - C#
This was purely based on the fact that it's what I use most at work. Had this project been purely informal I would have been tempted to learn and use another language (possibly Go). If you choose C#, make sure you try from the very beginning to familiarize yourself with Async / Await.
Framework - .NET Core (Web API)
A logical progression of choice based on the language. Also, cross-platform development and deployment. It's been an absolute joy so far! Excellent documentation available. I would strongly urge developers to understand the basics of dependency injection. Using .NET Core is a great way of seeing it in action.
Database - Amazon DynamoDB
A choice made out of curiosity. The documentation for the .NET SDK is a little wanting. I will write a follow-up article to this detailing the use of the SDK in programming DynamoDB in .NET Core.
Logging - Serilog
I'd heard good things about Serilog - we use log4net at work. Serilog was easy to set up as a logging provider for .NET Core. My logging needs were simple and I am just logging to a file. Check out the .NET Core logging API. Also learn about structured logging.
Application Caching - Redis
Redis is an in-memory key-value store. It's is not a plain key-value store, it is actually a data structures server, supporting different kinds of values such as strings, hashes, lists, sets, sorted sets, etc. I'm using it with ASP.NET Core's built-in distributed cache implementation (IDistributedCache
). Redis is much more than a cache. Developers should add this to their toolbox. Also read up about in-app, HTTP and distributed caching.
API Authorization - Auth0
Auth0 is a service that abstracts how users authenticate to applications. We decided to go with Auth0 for authentication and authorization. The authentication will happen at the front end. In the API I use Microsoft.AspNetCore.Authentication.JwtBearer
configured with Auth0 to restrict access to my controller methods. I suggest going through JSON Web Tokens, OAuth2 Authorization Flows and OpenID Connect to get an understanding of how Auth0 works.
Documentation - Swagger (Swashbuckle)
Swagger is a framework for describing your API using a common language. The framework provides the OpenAPI Specification (formerly known as the Swagger specification) for creating RESTful API documentation formatted in JSON or YAML, a human-friendly superset of JSON. Swagger documents can be processed by various programming languages and can be checked into source control for version management during the software development cycle.
Swagger UI is a tool that takes Swagger specification files, presents them visually and allows you to execute operations and test the API.
Swashbuckle.AspNetCore
is an open source project for generating Swagger documents for Web APIs that are built with ASP.NET Core MVC.
Packaging - Docker
I strongly believe every developer should understand the basics of container technology. I chose Docker as it is the most widely adopted containerization platform available today.
Host - AWS EC2
I wanted to simply deploy and run my Docker container on a cloud VM without using any container orchestration services / tools. This is, of course, not ideal for production environments and large applications that require scaling. Since my application is in development, I'm alright with this for now. It's also a simple way to get started with deploying Docker.
This pretty much covers the stack I have used so far. I think it is fairly easy to get started with and covers a broad set of relevant technologies today for designing and developing a RESTful (or rather, JSON over HTTP) API.
All of the development was done on Visual Studio Code.