Skip to content

Learning DDD with theory only is boring, let's do some exercises!

Notifications You must be signed in to change notification settings

hoangtuan151/todos-ddd-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Todos DDD Example

An example todos app with DDD approach

References

Domain Modeling Iteration

Round 1

User stories

  • User will be logged in by providing a username (no need password, no need to register)
  • User could manage one ore more todo task items
  • Each task's state could be as follow: new -> doing -> done
  • To stay focused, user could only have 3 doing tasks at a time. But if he has finished at least 3 tasks in his lifetime usage, he could have up to 5 concurrent doing tasks
  • User could delete/remove any task in the list
  • No need to manage task creation time

Domain model

SQLite repository

Round 2

REST endpoints with Flask

  1. Get all tasks of user
GET /tasks

Request
--------
Header::Authorization: Bearer <username>

Response
--------
[
    { "taskid": "abc...", "description": "...", "status": "..." },
    { "taskid": "xyz...", "description": "...", "status": "..." }
]

  1. Add task
POST /tasks

Request
-------
Header::Authorization: Bearer <username>
Header::Content-Type: application/json
Body: {
    "description": "new task"
}
  1. Update task status
PUT /tasks/<task_id>/status

Request
-------
Header::Authorization: Bearer <username>
Header::Content-Type: application/json
Body: {
    "status": 1  # 1: doing; 2: done
}

Round 3

New user stories

  • Now, we need to manage the emergency of a task (true or false)
  • To keep focused, each user could only have 3 doing tasks at a time, but if he has a really urgent task, he could add 1 and only 1 emergency task to having 4 concurrency doing tasks
  • If a user has finished at least 3 tasks in his lifetime usage, he could have up to 5 concurrent doing tasks

Next domain model

Mongo repository

Collection User {
    username: "joe",
    tasks: [
        {
            id: "...",
            desc: "...",
            state: "...",
            emergency: 1  # 1: yes; 0: no
        }, {
            ...
        }
    ]
}

About

Learning DDD with theory only is boring, let's do some exercises!

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages