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.

  1. 3 APIs and 3 projects, 1 for metal data, 1 for currency data, 1 for meshing metal and currency data together to match request

  2. 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.

  3. Fallback Currency API - If a request to a database fails, fallback service provides data from generator class.

  4. Code First approach used in creating Database.

  5. 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.

  6. Layer architecture within currency project. Controller - Service - Repository. Service needed for determining if data is to be obtained from repository or fallback.

  7. 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.

  8. 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.

  9. Database used by 2 projects: Generator and Currency API. Common logic extracted to separate project CurrencyDatabaseCommon.

  10. 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

  11. Read Model - library used only by project for getting data through apis.

  12. Standard appsettings.json for common config with override for dev and prod environments used in APIs.

  13. 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.

  14. 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.

  15. Fallback files paths not in any config as used in one place only.

  16. Guandl json deserializer internal rules enclosed within related model folder in Metal API.

  17. BuildServiceProvider used to discover http fallback implementation. Refactor to DI services parameter in Configure.

  18. Scoped lifetime for requests used throughout application.

  19. MetalCurrencyCombined model created to pass as input output in each filter in goldcharts pipe.

  20. 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.

  21. 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.

  22. UI template used: https://xieziyu.github.io/ngx-echarts/

  23. Data source for metals prices: https://www.quandl.com/api/v3/datasets/LBMA/SILVER.json