osteel's blog Web development resources

Building a PHP CLI tool using DDD and Event Sourcing. Introduction: why?

Been here before?

You can also subscribe to the RSS or Atom feed, or follow me on Twitter.

In this series

A transparent whiteboard

Photo by Kvalifik on Unsplash

Anyone following me on Twitter is well aware of my interest in crypto. I find it a fascinating topic with ramifications that I believe will change society in many ways.

But whether you share this view or not doesn't really matter here – this post isn't about crypto (feel free to head over here if you want my take on Bitcoin though!).

The field just happens to serve as a backdrop for this series, focussed on the building of a PHP console application that will help me track my crypto activity.

And there are a few reasons why I'm getting into this.

Taxes

The only two certainties in life are death and taxes.

– Benjamin Franklin

As I keep exploring the ever-expanding crypto sphere, I'm performing all sorts of actions, some of which Her Majesty's Revenue and Customs (HMRC) has an interest in. I live in the UK and, like in many other places, the government is grappling with this rapidly evolving field, adding new rules and amending existing ones on a regular basis to try and keep up with new practices.

While it's fairly easy to keep track of and compute a limited number of transactions, it becomes far more complicated when that number goes up (wait – isn't NGU supposed to be good?). There are lots of portfolio- and tax-tracking tools out there, but I couldn't find one that covers all my use cases or that reports numbers I can make sense of.

As I want to understand what's going on under the hood and as I need to know the rules to make informed decisions anyway, I figured I might as well build my own tool.

Technical exploration

The second reason for this series is that this project has some interesting technical aspects to it:

  1. It's a good candidate for a console application, a topic I've been looking into and covering lately;

  2. It's sufficiently complex that it could use some advanced features typically provided by a framework. Laravel Zero has been on my radar for a while and this feels like a good opportunity to use it;

  3. I've recently been exposed to Event Sourcing, an approach where an application's state is stored as a sequence of events instead of keeping the current state only. Storing my crypto activity this way could help me understand why the numbers are what they are while allowing me to process the data in ways I haven't thought of yet later on (e.g. through additional projections);

  4. Event Sourcing is considered a pattern of Domain-Driven Design (DDD), which involves talking to experts to come up with a model matching the business domain. I've got access to an accountant I can ask questions to and there's now plenty of literature available out there, which makes this approach suitable for this project.

Build in public

Finally, the third reason I'm writing this series is that I've been interested in building in public for a while. This approach is usually taken with an entrepreneurial mindset – advertise the product you're planning to build, document and share your progress, grow an audience and gather feedback along the way. The goal is to then convert part of that audience to buyers when the product is finally available.

The main difference here is I've got nothing to sell. The tool will be open-source and people will be free to use it if they want to, although if they do it will be their responsibility to ensure the numbers are correct (by running them by an accountant, for instance).

In short, people joining me on this journey should come for the process first and foremost, and not so much for the outcome.

I am not an expert in DDD any more than I am an Event Sourcing guru. My aim here is to learn as much as possible on these topics by building and to document my findings as I go. I hope to introduce others to these topics along the way, and to maybe gather useful feedback if people are kind enough to chip in. I'm also keen to explore how far PHP CLI applications can go.

Since I haven't done anything yet, I don't know how many parts this series will comprise. Feel free to subscribe to the newsletter further down so you don't miss the next posts, or to follow me on Twitter where I'll share them also.

For now, as DDD commands, let us start with the domain.

Enjoying the content?

You can also subscribe to the RSS or Atom feed, or follow me on Twitter.

Last updated by osteel on :: [ ddd crypto ]

Comments