Console app that create invoice based on event feed
- Configurable via appsettings.json
{
"PageSize" : 10,
"AfterEventId" : 0,
"MaxPageSize": 500, //DO NOT CHANGE THIS UNLESS YOU KNOW THE API MAX PAGE SIZE
"PollingIntervalInSeconds": 5,
"Serilog": {
"Using": [ "Serilog.Sinks.Console", "Serilog.Sinks.File" ],
"MinimumLevel": "Information",
"WriteTo": [
{ "Name": "Console" },
{
"Name": "File",
"Args": { "path": "Logs/log.txt" }
}
],
"Properties": {
"Application": "EventFeed"
}
}
}
- Using Serilog instead of Microsoft for ease of switching between 3rd party logging without code change.
- Automatically fallback to user input for new feed-url if the existing one failing to response for 3 consecutive calls.
- Run without options will prompt user input.
- Directory and url validation before start pooling.
- Using singleton DI services to main program.
- Including a minimal xunit unit test project
- Implemented event based notification to invoice generation
- Tested with a mockaroo API! https://my.api.mockaroo.com/events.json?key=fda01bf0
- Server has dotnet 5.0 SDK installed.The zip file doesn't include exe or binary. Just build and run on your favourite env ~
- Invoice-dir is a network drive that has auto replication for backup and redundancy.
- Event Id is always increment by 1. Treat this number as time sequence for event creation.
- No need to manage docs versioning, storage has versioning capability / can always recreate from event API.
- Invoice_update always contains full detail, so no need to check for delta, directly replace current version.
- Invoice_create will be upsert. Assuming storage has versioning capability, no need to worry skip create if exists, replace and assume storage will do the versioning. May not be the right behaviour, otherwise put item into queue, eg: SQS, so we can re-process the failed record later.
- Logs are safe to store locally as it has same network drive capability as invoice-dir.
- Use 3rd party libraries such as PdfShareCore, Serilog to speed up development process.
- Build unit test project structure but have not fully covered test cases.
- Store afterEventId on a network storage, so a crash won’t means restarting from 0.
- Configure CI/CD to automatically test and deploy.
- Support more types of invoice-dir such as s3, ftp.
- Redesign to process simultaneously across multiple instances without double processing to support horizontal scaling
- Improve test scenarios and code coverage.
- Allow more command line options to override appsettings.json.
- Improve PDF formatting.
- Create a mock server API instead of using mockaroo.
- Benchmark the efficiency.
- Try hook up with cloud services such as SQS and SNS.
- Logging to cloudwatch and add x-ray for each processing step.
- Revisit PDF library.
- Hook up with monitoring tools.
- Improve security handshake with API.
- Encapsulate it further by creating service that will verify configuration and start pooling, that will make Program.cs much cleaner.
This apps will take two parameters at startup:
- --feed-url
- --invoice-dir
- unzip EventFeed.zip
- cd EventFeed
- dotnet run --feed-url=https://my.api.mockaroo.com/events.json?key=fda01bf0 --invoice-dir=C:\Users\abc