Skip to content
Grzegorz Nowak edited this page Sep 17, 2018 · 2 revisions

Keywords:

  • design

    • data model
    • rest api
    • money transfers
    • accounts
    • simple
    • common sense
  • implementation

    • no spring
    • in-memory datastore
    • executable (jar / war)
    • tests
    • demo
    • high quality

Own requirements:

  • track time
  • save notes / docs
  • versioning
  • double booking
  • gnucash

API Data Model:

Account {
	String number
	String owner
	String currency
	BigDecimal balance
}
Transfer {
	String id
	Date createdAt (=now)
	String from
	String to
	BigDecimal amount
}

Object Store Data Model:

Account {
	UUID number
	String owner
	String currency
}
Transfer {
	UUID id
	Date createdAt
	List<Split> splits
}
Split {
	UUID account
	Money amount
}

REST API resources / URLs:

POST /accounts - create account
GET /accounts?owner=XYZ - view accounts of XYZ
GET /accounts/123 - view account basic info
GET /accounts/123?fields=balance - view info with balance
GET /accounts/123/transfers - view transfers from/to this account, 307 redirect
POST /transfers - enter a new transfer
GET /transfers - debug list of transfers
GET /transfers?account=XYZ - account transfers
GET /transfers/123 - get info about the transfer

User Stories:

  1. As a user I can create new accounts under my name
  2. As a user I can view my accounts with their balance
  3. As a user I can view my account history (incoming and outgoing transfers)
  4. As a user I can transfer money between accounts
  5. As a user I can view the status of the transfer

Technologies

  • Java 8 SE - base
  • JAX-RS & Jersey Client & Server
  • Jetty - embedded servlet container
  • simple own object store
  • assembly/shade plugins - executable jar
  • groovy & spock - unit and acceptance tests
  • maven - project tool
  • github - source control

Project structure

  • single project with tests

Possible improvements

  • json Message with details of error (to complement http status code)
  • bean validation for input objects
  • hateoas (very limited as part of 201 Created and Location header)
  • monitoring, tracing, etc
  • registration in service registry to allow discovery
  • api module for DTOs and interfaces to make it easy for consumers
  • Optional<> instead of nulls
  • validation of transfers against account store (see incode TODOs)

Time statistics:

What Time
Analysis and design 2h
Prototyping 7h
Impl. & testing 14h
Self review 1h
Total 24h