vapor architecture
Clone or download
Latest commit 7e6fc03 Jan 15, 2019



Getting Started

Install dependencies.

yarn bootstrap

Start a server.

cd modules/server
yarn start

Start a client. Open Xcode project under modules/client/ios/ and Run

Showing numbers of sold drinks

Access http://localhost:3000/items


This is a 16th article for React Native Advent Calendar.

Followings are my thoughts of an architecture to build apps in multi-platform for now.

clean architecture

The "clean architecture" is proposed by Uncle Bob.

Primary merit is suited for development by team. This merit is leaded by separation of codes corresponding to its responsibilities.

In this repository, codes responds to each roles in clean architecture are following paths.

roles in clean architecture paths
Entities /modules/domain/src
Use Cases /modules/client/src/usecases
Interface Adaptors /modules/client/src/selectors, /modules/client/src/modules
Frameworks and Drivers /modules/client, /modules/server


"DDD" is a famous framework of thoughts proposed by Eric Evans.

In this repository, use only a Repository pattern: A pattern to input / output data to / from Entities.

Entity is also described in Eric Evans's DDD book, but those are discussions in context of object oriented. I wrote codes for Entities in context of function oriented, in order to get used to CQRS and event sourcing, there are some of differences between both.


CQRS: Command Query Responsibility Segregation reduces complexity of software systems.

Redux is a one of implementations of CQRS: Dispatching actions are Commands to store and props are Queries to store.

I use Redux actions to command to a server.

I think this design makes sense, because Entities are global in my all apps.

Event sourcing

Event Sourcing ensures that all changes to application state are stored as a sequence of events.

Event sourcing is effective to adopt CQRS. Redux actions and reducers are just a sample of event sourcing.

domain Entities modeling

I picked vending machine up as a theme to model. Coins, drinks, items and vending machine are modeled in this repo. Modeling vending machine is recommended by かとじゅん

View Model

Mappings from Entities to View Model is a one of Interface Adaptors. I use the reselect package to suite Entities for React components.


Frameworks and libraries are bovine rather than thoughts and ideas about design to develop apps. I'm delightful if you get somethings from this repo.