1. Introduction

This project is intended for practice and a showcase of a very simple microservices system. I have developed this project over the last year or so, as I learned new technologies and frameworks, and I tried to integrate them into the project.

This document briefly explains the project, its architecture, and how it has been developed. Also, the source code is available on GitHub.

1.1 Storyline: BloomSales Inc.

BloomSales Inc. is a fictive fairy large retail company. It has stores and warehouses all over Canada, and United States. The company’s management has decided to invest in its online services and move towards an online-only store within a few years.

BloomSales consists of the following major departments with each has its own internal software systems:

  • Sales and Marketing
  • Accounting
  • Supplies
  • Shipping

During the shift towards the company’s new direction, there is a need to see the company as whole, and therefore, design and integrate all the systems within the departments with respect to their domain.

2. System Architecture

Figure 1 shows the new architecture proposed for BloomSales Inc.

overall20system20architecture205bdraw-io5d
Figure 1 – Proposed architecture for BloomSales Inc. systems

This architecture consists of different layers. BloomsSales Service Layer consists of all new back-end services that provide the functionalities needed by department-specific Web and/or desktop applications. These services would reside in company’s internal domain and private data center. On the other hand, REST API services would expose a subset of Service Layer functionalities to the outside world.

2.1 Project Boundary

As mentioned before, the only purpose of this project is to develop a microservices sample application, and integrating different technologies that could be used in such application. Therefore, this project is only limited to BloomSales Online Store, and the back-end services it needs to operate.

2.2 Back-end Services

All the back-end services are written in C# using Windows Communication Foundation (WCF). They are all cache-aware services. Having said that, for simplicity they are currently using only in-memory cache, and not any external caching system such as a Redis cache.

Each service provides a certain set of functionality mostly based on what was needed by the Online Store. Moreover, the services are loosely coupled. Each one has its own database, and they only communicate through the service interface. The business entities, however, are common among them in order to keep both the implementation and design simple. Figure 2 show how these services collaborate.

service20calls205bdraw-io5d
Figure 2 – Collaboration between back-end services

All services use Entity Framework to connect and work with their data stores, which are in this case SQL Server databases. Obviously, the data stores can be replaced wtih other DBMSs such as MySQL with not much work,  because of using Entity Framework. The services also employ the Repository Pattern within their Data Access Layer in order improve testability, readability and maintainability of the code in that layer.

2.3 BloomSales Online Store

Online Store is the only application implemented within BloomSales Web/Desktop Application Layer (see figure 1).

The application is written in C# using ASP.NET MVC 5. On the front-end, it uses a little bit of javascript and jQuery. Also, it uses Bootstrap for styling the fron-end. On its back-end (controllers), it uses the back-end services explained earlier and mainly orchestrates how the flow goes through those services.
Furthermore, the application uses ASP.NET Identity for authentication; therefore,it uses SQL Server as its data store.

It is worth mentioning that in some pages of the Online Store, Ajax has been used in order to improve the user experience.

3. Source Code

Since this is a one-man project, all codes for services and other projects are put together in one repository, in order to simplify the development flow and reduce the overhead of managing the code base. However, if it was a team or ideally a collection of teams responsible for development of the services and applications, it would be a better practice to dedicate separate repositories to each service or application.

In order to run the project, at least .NET Framework 4.5 is needed.

3.1 Project Structure

The project consists of the following main parts:

  • BloomSales Services
    This solution contains all the project related to the back-end microservices. The code resides in /Services  of the project repository.

    • Business Entities
      This project implements all the business entities used in all the serviecs. The source code resides in /Services/Source/BloomSales.Data.Entities.
    • Data Access Layer
      The project includes all the code for Data Access Layer of the services, including the Repository classes. The source code resides in /Services/Source/BloomSales.Data.
    • Service Contracts
      This project includes all the service interfaces defined for the back-end services. These services are defined in a separate project to make the deployment to the service clients easier. The source code resides in /Services/Source/BloomSales.Services.Contracts.
    • Service Proxies
      This project includes the proxy classes used by a service client in order to communicate with the related service. The source code resides in /Services/Source/BloomSales.Proxies.
    • Services
      The project includes the actual implementation of all the back-end services. The source code resides in /Services/Source/BloomSales.Services.
  • BloomSales Service Hosts
    This solution contains the following projects which are hosts for the services. The code for those hosts reside in /Service Hosts of project directory.

    • Console Service Host
      This is a very simple command line hosting application for the back-end services. The source code resides in /Service Hosts/BloomSales.Hosts.Console.
    • Desktop Service Host
      This is a very simple desktop hosting application written using WPF for the back-end services. The source code resides in /Service Hosts/BloomSales.Hosts.Windows.
  • BloomSales Online Store
    This solution contains all the code for the Online Store application. As mentioned earlier, it is written in C# and ASP.NET MVC 5. The source code resides in /Web/Source/BloomSales.Web.Store.

3.2 Compiling the Code

For instructions regarding how to compile and run the source code, see README.md file in the root directory of the project, or visit the project homepage at GitHub.

4. Tests

4.1 Unit Tests

Both Repository classes, and service implementations have their own unit tests that can be found in the following paths:

  • Repository classes unit tests: /Services/UnitTests/BloomSales.Data.Tests
  • Services unit tests: /Services/UnitTests/BloomSales.Services.Tests

All the unit tests are written using MSTest. Also, in some tests where it was needed, Moq framework has been used as an isolation framework.

4.2 Integration Tests

There are various integration tests written for the back-end services that can be found in /Services/IntegrationTests/BloomSales.Services.IntegrationTests.

4.3 Running the Tests

For information about running either unit tests or integration tests, please consult the project README.md file, or visit the project homepage at GitHub.

 

 

 

Leave a comment