# My first DDD project

## Motivation

When I decided I want to learn DDD, I needed a sample project to work on. I know that there are plenty of great DDD implementation examples available (i.e. \[[https://github.com/ddd-by-examples/library](https://github.com/ddd-by-examples/library)\], \[[https://github.com/kgrzybek/modular-monolith-with-ddd](https://github.com/kgrzybek/modular-monolith-with-ddd)\]) but none of those are in Python, and I felt that I need my own project. I wanted to create a web application that is simple, small, and easy to understand. On the other hand, I didn't want to build a trivial CRUD application. After some initial thoughts, I decided to build an online auctions system - something similar to eBay bidding system.

## Project vision

My goal is to create a web application that allows sellers to list items for sale, and buyers to bid on the items they are willing to purchase.

#### Selling

When you want to sell an item, the first step in getting your item in front of buyers is creating a `Listing`. For now we only focus on selling through auctions ([https://www.ebay.com/help/selling/listings/auction-format?id=4110](https://www.ebay.com/help/selling/listings/auction-format?id=4110)), but in the future we may consider selling with "Buy It Now" ([https://www.ebay.com/help/selling/listings/selling-buy-now?id=4109](https://www.ebay.com/help/selling/listings/selling-buy-now?id=4109)) or in some other ways. When presenting an `Listing` for sale (which we call `publishing` in the Catalog), seller must provide a `Listing` duration and initial price. Also it is also possible to schedule a `Listing` publication ([https://www.ebay.com/help/selling/listings/selecting-listing-duration?id=4652](https://www.ebay.com/help/selling/listings/selecting-listing-duration?id=4652)).

You can cancel your listing when bidding takes place, but only under certain circumstances: if time left in listing &lt; 12 hrs you can cancel your listing only if no bids were places (but we might change it in the future).

If you are a new seller (you never sold an item before), you can list only one `Item` in the `Catalog` at a time.

#### Buying

When `Listing` is selled through auction `Bidding` takes place. As a `Buyer`, you can place a bid, which must be greated than the current price + 1 USD and which sets the the highest price you are willing to pay for an item. System will let you know if someone outbids you and you can decide if you want to increase your maximum limit. Sometimes you can can be automatically outbidded (if some other buyer sets his maximum limit higher that yours) - see [https://www.ebay.com/help/buying/bidding/automatic-bidding?id=4014](https://www.ebay.com/help/buying/bidding/automatic-bidding?id=4014).

After a fixed time since the bidding was started a bidding ends and the `Winner` is announced.

## Final remarks

My intention is to use both strategic and tactical patterns that DDD has to offer. I expect to learn a lot from this exercise, and I thought it would be valuable to share my learnings with you as I go. In addition, [learning by teaching](https://en.wikipedia.org/wiki/Learning_by_teaching) is known for its effectiveness, so I hope to improve my learning by writing a series of blog posts. The source code for this exercise is available here:

[https://github.com/pgorecki/python-ddd](https://github.com/Ermlab/python-ddd)
