Giter VIP home page Giter VIP logo

ddd-example-in-ruby-on-rails's Introduction

DDD example in Ruby on Rails

This is a PoC application for implementing elements of Domain-Driven Design inside of a plain Ruby on Rails application.

THIS IS NOT PRODUCTION-LEVEL CODE. Its purpose is to serve as a validation of ideas and a discussion starting point.

Identified Subdomains and implemented Bounded Contexts

DragonHunt

Our company organises raids on dragons. But we need to assemble the parties first

CooperationNegotiation

Before a party is assembled, its leader needs to negotiate a contract. The contract signature is the defining moment for the party to be assembled.

Implemented scenario, joining two contexts

It implements a simple scenario (using ubiquitous languages for each of the domains):

  • start negotiation by preparing a draft contract
  • modify text of the contract to satisfy the client and the company
  • the contract, in its final text form, needs to be signed by the client
  • the contract, in its final text form, needs to be signed by the company
  • when both sides sign the contract, it cannot be modified further
  • signed contracts can be listed, including the text of contract and the time it has been signed
  • when the contract is signed by both sides, a party is assembled in the DragonHunt context

Used DDD features

  • contexts defined as modules inside of app/modules/ folder
  • layers defined in each modules within application|domain|infrastructure folders
  • repositories put into infrastructure layer
  • persistance models put into infrastructure layer and translated into/out of domain models using repositories
  • application services for each possible action within cooperation_negotiation context
  • domain objects defined as POROs
  • domain events defined as POROs
  • domain events handled synchronously and used for cross-context communication
  • factory methods defined on domain objects
  • read models

Installation

rails db:create
rails db:migrate

rails db:seed

Reply all test scenarios with

rails db:seed:replant

Testing

The project uses Rspec as its testing framework. Run

rspec

to run all tests.

For continues testing during development you may use Guard with

guard

Future plans

  • I'm thinking about adding some controllers and frontend to show that it can operate as a normal application.

Enjoy

Please let me know if you see anything you like, don't like or think can be done better

ddd-example-in-ruby-on-rails's People

Contributors

pstrzalk avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.