Skip to content

Instantly share code, notes, and snippets.

@MQuy
Last active August 2, 2017 22:36
Show Gist options
  • Save MQuy/263b67c464bb1f7d1a197a9b8deb5878 to your computer and use it in GitHub Desktop.
Save MQuy/263b67c464bb1f7d1a197a9b8deb5878 to your computer and use it in GitHub Desktop.

Bokio

Test the project

How to setup the project

Open a new console

  • run cd frontend
  • run bower install && npm install
  • run gulp serve and it will open the new tab

Run tests

  • run rspec spec

API Format

  • Server: JSON Format
    • Import: POST /user_transactions/bulk_import with { data: xxxx }
    • All: GET /user_transactions

How about the project

Structure

├── app                               # Application source code
│   ├── controllers                   # The place to receive parameters which are sent from client
│   └── domains                       # Divide and handle business model
│       └── transaction               # Transaction is responsible for features like importing ....
│           └── page_impport          # Page Report contains three components: check data, parse data, store transactions.
│               ├── parser            # Receive data which is sent from client and parse it. After that returing results which are all the transaction rows
│               └── store             # Store transactions into database after receiving parser's output
├── frontend                          # Folder for frontend
├── spec                              # Test files

Domain Flow

Bokio

Walkthrough

The reason I chose railway oriented programming is that it not only helps me to focus on "the happy path" but also provide a clean way to handle error.

There are 3 subdomains inside Transaction/PageImport

  1. Check the data:
  • Their role is checking whether the input data is correct or not.
  • If input data is correct, the data will be passed to Parser subdomain
  1. Parser: the current implementation is without knowledge about colum names which can be specified from user.
  • It will read line by line from the data above and get only the transaction rows with conditions
    • Row has to contain one column with date format and one column with number format
  • After filter all tranasction rows, it will build "plain old objects" for those transactions and pass it to Store subdomain
  1. Store:
  • It will persist those transactions into database, if there is any error, store will give error message for the Output

I hope with these, it will help you to have a big picture about my code.

Best regards

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment