venomnert
Context:
I have completed chapter 3 (data), chapter 4 (functions) and chapter 5 (testing) of Designing Elixir Systems with OTP. And i’m currently building an e-commerce platform with the following functionalities:
Usercan create an account- The authenticated
usercan addproductsto theircart - The
usercan checkout theirproductsfrom thecart - The
userreceives anorderconfirmation
Questions:
Here is a quote from the book explaining a bank as a data
It’s an initial balance plus a set of transactions at a point in time. These transactions are functions.
-
In the context of an ecommerce application what are the initial “balance” and “set of transactions at a point in time” do I need to keep a track off for:
users,productsandorders? -
In the context of an ecommerce CMS application what are the initial “balance” and “set of transactions at a point in time” do I need to keep a track off for:
users,productsandorders?
Trending in Questions
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
Hello,
I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
Documentation
While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
So my question is quite simple and i have found no conclusive answer on forum, google or AI.
Should we use :erlang.float for Integer to ...
New
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
If a change or preparation module uses Ash.Changeset.get_argument/2 or Ash.Query.get_argument/2 (or any of the other get_argument functio...
New
Other Trending Topics
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
Hi there! We created Gust: A task orchestrator inspired by Airflow.
For those who have never heard about Aiflow, it’s a Python-based wor...
New
Hi everyone!
The first release candidate for the Expert language server project is now available!
We’ve published a press release detai...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixirconf-us
- #ai
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #hex
- #security











Showing Posts 1 to 10- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
JEG2
I feel like e-commerce makes for a great example of what we were describing in the book, because common ways to build the models can easily become problematic.
Can you still show accurate historical orders when a product is removed or goes up in price? Find data structures that can represent change over time and you’ll be in a much better place.
venomnert
First off I want to thank Bruce and you for writing the book!
This is what I am having trouble understanding, because the data structure would be an ecto struct. As a result, all the changes will take place within a controller and a new state will get saved to the DB. For example, the admin changes the price for product A. The controller, will make an updated to product A and save it to the DB.
My question is, how do we work with DB as the structure and still capture the set of transaction?
JEG2
For me, it often helps to put the database aside for a moment and figure out what data structures I really need. Once I have that, then I can ask myself how I would save it to a database.
Does that help get the ideas flowing?
chouzar
As @JEG2 mentions you need to figure out what data structures you need in your application (maybe you don’t know them all at first hand, but will arise according to your needs). Its ok if your DB struct differs from your transactions.
I’m not following the book but until very recently I have been looking into “event driven design” and this talk about the commanded library plus following the github guide helped me a lot into better understanding this mental model.
Note: You don’t need to fully buy into commanded’s mental model; you can discern your system’s primitives without it, but I hope it can give you another angle to view your problem from.
venomnert
This make sense! And that’s exactly what I did during my data discovery process. However, I’m unclear about the
userdata structure. The question that I’m trying to answer is, what type of transactions do I need to record for auserdata or is this even necessary?I also noticed that in the book
userdata wasn’t captured. Was it left out because its data wasn’t significant for the quiz application?venomnert
@chouzar thank you for mentioning CQRS/ES. After having read this article and watching a couple of conference talks, I believe I am able to answer my question
For the content management aspect of the ecommerce application, I don’t need to record any events for
userdata, a simple CRUD is sufficient enough.JEG2
We didn’t include users because the example is already complex enough and everyone shows users. We figured readers could tie that into their own designs.
I agree that simple CRUD is probably fine for your user models. I think the real trick is in getting products right.
venomnert
I agree, I was also thinking of using CRUD for products as well. Since, features like
isn’t required for my application.
chouzar
Thanks for sharing the article! One of the things that really worries me into going all in into a cqrs design is the feeling feeling that I have to get my entities “right” the first time.
A change that affects one of my “immutable” stores sounds like maintanability hell. Althought you could have a case that its easier to progressivelly enhance your architecture
venomnert
I had the exact thought as well. I don’t want to introduce complexity until it’s really necessary.