Skip to content

weslleyfelix/python-ddd

 
 

Repository files navigation

Build Status codecov License: MIT

AUCTION APPLICATION

The goal is to implement an automatic bidding system, described here: https://www.ebay.co.uk/pages/help/buy/bidding-overview.html

TODO for near future:

User stories:

  • As a seller I can list a new item for sale. The item has the following fields: text, description, starting price

  • As a seller, I'm allowed to list up to 3 items at the same time

  • As a user I can view all the items for sale. For each item I will see: text, description, current price, minimum bidding price, a winner, all participants, auction end date

  • As a bidder, when placing a bid, I enter the maximum amount I am willing to pay for the item. The seller and other bidders don't know my maximum bid

  • As a bidder, when placing a bid, my bid must be higher than the actual price

  • Auction Store will automatically calculate the current price of an item based on the bids that were made

  • When auction ends, auction store will notify the seller by email. The email will contain the name of the winner and the sell price.

  • When auction ends, all losing participants will recieve an email with the information that they lost an auction.

  • When auction ends, the winning participant will reciewve an email with information the user has won and the price for an item.

pipenv install
pipenv shell

To run tests

pytest

To run tests in watch mode

ptw

To run the app as Falcon server

FRAMEWORK=falcon gunicorn --reload main

To run the app as Flask server

FRAMEWORK=flask gunicorn --reload main

To run application Shell:

python shell.py

Within the shell you can execute and queries and commands, i.e.:

(InteractiveConsole)
>>> c = AddItemCommand({'title': 'Fluffy bunny'})
>>> command_bus.execute(c)
<CommandResult>(ok) {}

Project structure:

context-1
  domain
    entities
    value_objects
    aggregates
    services
    repositories
    factories?
    interfaces
    events
  application
    services
  infrastructure
    ??
  tests??

context-2

context-3

di_setup
main - main entrypoint to the app

Domain artifacts

  • entities - mutable, identifiable, unaware of persistance

  • value objects - immutable, self-contained

  • aggregates - any transaction should modify only one aggegate at a time, 70-80% usually contain olny one entity, consistency boundary, hosts methods which will modify the aggregate

  • events - significant state transition, something which domain experts care about

  • factories - for entity construction, ubiquotous language verbs, hide construction details (Python function)

  • repositories - store aggregates, abstraction over persistence mehanism

  • context maps - mappings between concepts between bounded contexts

Installing Python 3.7 from source on Ubuntu 18.04: https://gist.github.com/jerblack/798718c1910ccdd4ede92481229043be

References:

About

Python DDD example

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%