ADR | Architecture Decision Record - mjoniec/Proj1_GoldCharts GitHub Wiki
ADR - Architecture Decision Record
No document structure or versioning by date for decisions history. Just a flat list to ctrl+f search through.
-
3 APIs and 3 projects, 1 for metal data, 1 for currency data, 1 for meshing metal and currency data together to match request
-
Fallback Resilience Policy used in Metal API for httpClient calling external data provider. Polly - library used to add fallback behavior to http request pipeline. No other policies like timeout, circut-breaker or retry were used in solution so far. If a request fails, static json attached to project is used as a source. Both providers (api and fallback) implement the same interface.
-
Fallback Currency API - If a request to a database fails, fallback service provides data from generator class.
-
Code First approach used in creating Database.
-
CQRS - APIs provide read-only features. DB tables for Currency populated by a CurrencyDatabaseGenerator project, separate to main business flow, common classes in a separate lib project. No write for Metal data. So read is for end user, write only for admins if present at all.
-
Layer architecture within currency project. Controller - Service - Repository. Service needed for determining if data is to be obtained from repository or fallback.
-
Pipes and Filters architecture within Gldcharts API. Metal and Curency data needs to be processed and meshed together to match request. For example silver prices are provided by metal api only in USD and user requested EUR, moreover both metal and currency sources have no common timeline. Each operation type on data is performed by a specialized filter, each implementing the same interface and returning the same model. Filters execution order is determined by the pipe.
-
IServiceProvider injected in constructors in various controllers and services. Used to retrieve what implementation of data provider/repository (actual or fallback) is to be instantiated (from ones registered in IServiceCollection). Services names in appsetting.json. No more advanced solution like IEnumerable with implementation types needed here.
-
Database used by 2 projects: Generator and Currency API. Common logic extracted to separate project CurrencyDatabaseCommon.
-
Common Model - library referenced by multiple projects - apis, database setup, read model. It contains enums and base models used throughout application. Considering packing and referencing as a Nuget
-
Read Model - library used only by project for getting data through apis.
-
Standard appsettings.json for common config with override for dev and prod environments used in APIs.
-
Options Pattern and hierarchical configuration used for goldcharts and metal APIs. Not applied in Currencies API - options Class would have to be in Database Common Library, separated from appsettings.json in api.
-
Database generator and read repository have each own sql connection string typed in. (TODO: dev prod switch for db generator command line project). Not in any config, as for now db read/write logic split between 2 runnable projects and one libranry.
-
Fallback files paths not in any config as used in one place only.
-
Guandl json deserializer internal rules enclosed within related model folder in Metal API.
-
BuildServiceProvider used to discover http fallback implementation. Refactor to DI services parameter in Configure.
-
Scoped lifetime for requests used throughout application.
-
MetalCurrencyCombined model created to pass as input output in each filter in goldcharts pipe.
-
SOA vs Micro SOA. Solution is partially Micro SOA. Each API is separately deployable and versionable. Fallbacks existrs for metal and currency APIs. However there is no fallback main GoldCharts API. If one of dependent APIs is down no resilience policy will get triggered while processing request in pipe.
-
Interfaces used for each service, repository and any other component type. Provides testability, follows SOLID, and derives the same life scope as request. Requires injecting service provider (or equivalent solution) in constructors, as multiple implementations not supported natively.
-
UI template used: https://xieziyu.github.io/ngx-echarts/
-
Data source for metals prices: https://www.quandl.com/api/v3/datasets/LBMA/SILVER.json