Sign inSign up

milkyware/utrngenerator-api

By milkyware

•Updated about 4 years ago

Image
0

2.4K

milkyware/utrngenerator-api repository overview

⁠UtrnGenerator

⁠Overview

This is small project designed to be a central place to generate transaction numbers, as well as keep track of their progression. This allows multiple transactional services to share a single reference number format for the ease of customers as well as link related transactions together.

⁠Getting Started

⁠Configuration

The injection of the dependencies for the UtrnGenerator are grouped together under the ServiceCollectionExtensions in UtrnGenerator.Core. Below is a table of available configuration.

NameMandatoryTypeDescription
UTRN__DBPROVIDERNEnumAvailable values: MySql, Sqlite, SqlServer. Defaults to Sqlite.
UTRN__DBCONNECTIONSTRINGNStringConnection string for the DB. Defaults to a SQLite connection string: DataSource=UtrnGenerator.db
UTRN__PAGINGDEFAULTSIZENIntDefault page size for returning lists of entities. Defaults to 25
UTRN__PAGINGMAXSIZENIntSets a max size for a page of results. Defaults to 200
UTRN__UTRNPREFIXNstringConfigures the prefix when generating transaction reference.
⁠Sample Development AppSettings
{
    "Logging": {
        "LogLevel": {
            "Default": "Information",
            "Microsoft.AspNetCore": "Warning"
        }
    },
    "Utrn": {
        "DbProvider": "Sqlite",
        "DbConnectionString": "DataSource=UtrnGenerator.db",
        "PagingDefaultSize": 50,
        "PagingMaxSize": 200
    }
}

⁠Tools & Packages

⁠Detail

⁠DB Design

The database is designed to be simple to manage and work with, whilst also providing the ability to report on activity and track the progress of transactions:

  • Transactions - Represents the lifetime of a request from a customer which has the reference number returned to customer recorded against it. Transactions can also be related to one another to form a chain
  • Requests - Used to store snapshots of data relating to a transaction. Can be used to restore a request
  • Statuses - Defines available statuses to relate to a transaction. The name is an alternate key
  • Tags - This includes TagTransaction table. Creates a many-to-many relationship between Tags and Transactions. Name is an alternate key. Allows for creating a dynamic list of categories for a transaction
⁠Database Providers

A number of database providers are supported:

  • MySql
  • SQLite
  • SQL Server

On startup, EFCore will evaluate if there are and pending migrations for the configured database and perform a migration if needed. Each database provider has it's own UtrnGenerator.Data project which references UtrnGenerator.Data. This allows for the model to be shared across all providers.

To help with defining migrations in the future, a simple AddMigration.ps1⁠ PowerShell script has been added which will handle creating a migration in each provider. This will run the dotnet ef migrations add command using local connection strings where possible.

MySql requires a connection string to be provided as a parameter. An easy way of getting a running instance is using Docker:

docker run -it --rm -e MYSQL_ROOT_PASSWORD=root -e MYSQL_DATABASE=utrngenerator -e MYSQL_USER=utrngenerator -e MYSQL_PASSWORD=password -p 3306:3306 --name mariadb mariadb:10.8

With the instance running, it can then be used to develop against or for adding migrations to the UtrnGenerator.Data.MySql project. An example of using the AddMigrations.ps1 script can be found below:

.\scripts\AddMigration.ps1 -Name Test -MySqlConnectionString "Server=localhost;Database=utrngenerator;Uid=utrngenerator;Pwd=password;" -InformationAction Continue

⁠References

Tag summary

Content type

Image

Digest

sha256:1b738e8a6…

Size

61 MB

Last updated

about 4 years ago

docker pull milkyware/utrngenerator-api