GithubHelp home page GithubHelp logo

invoice's Introduction

Summary

Console app that create invoice based on event feed

Overview of design

  1. 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"
    }
  }
}
  1. Using Serilog instead of Microsoft for ease of switching between 3rd party logging without code change.
  2. Automatically fallback to user input for new feed-url if the existing one failing to response for 3 consecutive calls.
  3. Run without options will prompt user input.
  4. Directory and url validation before start pooling.
  5. Using singleton DI services to main program.
  6. Including a minimal xunit unit test project
  7. Implemented event based notification to invoice generation
  8. Tested with a mockaroo API! https://my.api.mockaroo.com/events.json?key=fda01bf0

Assumptions:

  1. Server has dotnet 5.0 SDK installed.The zip file doesn't include exe or binary. Just build and run on your favourite env ~
  2. Invoice-dir is a network drive that has auto replication for backup and redundancy.
  3. Event Id is always increment by 1. Treat this number as time sequence for event creation.
  4. No need to manage docs versioning, storage has versioning capability / can always recreate from event API.
  5. Invoice_update always contains full detail, so no need to check for delta, directly replace current version.
  6. 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.
  7. Logs are safe to store locally as it has same network drive capability as invoice-dir.

Shortcuts:

  1. Use 3rd party libraries such as PdfShareCore, Serilog to speed up development process.
  2. Build unit test project structure but have not fully covered test cases.

To improve

  1. Store afterEventId on a network storage, so a crash won’t means restarting from 0.
  2. Configure CI/CD to automatically test and deploy.
  3. Support more types of invoice-dir such as s3, ftp.
  4. Redesign to process simultaneously across multiple instances without double processing to support horizontal scaling
  5. Improve test scenarios and code coverage.
  6. Allow more command line options to override appsettings.json.
  7. Improve PDF formatting.
  8. Create a mock server API instead of using mockaroo.
  9. Benchmark the efficiency.
  10. Try hook up with cloud services such as SQS and SNS.
  11. Logging to cloudwatch and add x-ray for each processing step.
  12. Revisit PDF library.
  13. Hook up with monitoring tools.
  14. Improve security handshake with API.
  15. Encapsulate it further by creating service that will verify configuration and start pooling, that will make Program.cs much cleaner.

To test

This apps will take two parameters at startup:

  • --feed-url
  • --invoice-dir
  1. unzip EventFeed.zip
  2. cd EventFeed
  3. dotnet run --feed-url=https://my.api.mockaroo.com/events.json?key=fda01bf0 --invoice-dir=C:\Users\abc

invoice's People

Contributors

pcchannz avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.