Permalink
Fetching contributors…
Cannot retrieve contributors at this time
133 lines (100 sloc) 4.29 KB
<br><br>
<h2 id="architecture-overview">Overview</h2>
<p>
The figure below shows the main components composing Lelylan.
</p>
<%= image_tag('architecture.png', class: 'img-thumbnail') %>
<hr>
<h2 id="architecture-life">Request Life Cycle</h2>
<p>
Follow the request life cycle describing what happens when a user applies an action (e.g. turns on a light, opens a car, unlocks a bike) from the mobile app.
</p>
<br><br>
<h3 id="architecture-flow-api">API Block</h3>
<p>
<p>
The API block takes the HTTP request and forwards it to the correct microservice.
</p>
<%= image_tag('architecture-1.png', class: 'img-thumbnail', style: 'max-width: 600px') %>
<br><br><br>
<ul>
<li>
1) The <span class="label-border">Web App</span> fires an HTTP request (API call).
</li>
<li>
2) The <span class="label-border">API proxy</span> receives the HTTP request.
</li>
<li>
3) The <span class="label-border">API proxy</span> forwards the request to the <span class="label-border">Devices API</span>.
</li>
<li>
4) The "device update" event is added to the <span class="label-border">Event Bus</span>.
</li>
</ul>
<p>
The device is now <a href="/support#faq-value-expected-pending">pending</a> (waiting for the physical world to apply the desired changes).
</p>
<br><br>
<h3 id="architecture-flow-physical">Physical Block</h3>
<p>
<p>
The Physical block takes the "device update" event and forwards it to the physical device.
</p>
<%= image_tag('architecture-2.png', class: 'img-thumbnail', style: 'max-width: 550px') %>
<br><br><br>
<ul>
<li>
5) The <span class="label-border">Physical Proxy</span> is notified about the "device update" event.
</li>
<li>
6) The <span class="label-border">Physical Proxy</span> forwards the request to the <span class="label-border">MQTT Node</span>.
</li>
<li>
7) The <span class="label-border">MQTT Node</span> sends a MQTT message to the physical device.
</li>
<li>
8) The <span class="label-border">physical device</span> apply the desired changes and sends back a confirmation message.
</li>
<li>
9) The <span class="label-border">MQTT node</span> add the "physical device update" event to the Event Bus.
</li>
</ul>
<p>
At this point the device is not <a href="/support#faq-value-expected-pending">pending</a> anymore and the request is satisfied (the light is on).
</p>
<div class="alert alert-info">
<p>
<span class="label label-lelylan">notice</span>
In this example we used MQTT as communication protocol, but any existing device (e.g. Nest, Lifx ) can talk with Lelylan by adding a specific <span class="label-border">Node</span>.
</p>
</div>
<br>
<h3 id="architecture-flow-realtime">Realtime Block</h3>
<p>
<p>
The realtime block notifies the web about the physical world changes.
</p>
<%= image_tag('architecture-3.png', class: 'img-thumbnail', style: 'max-width: 450px') %>
<br><br><br>
<ul>
<li>
10) The <span class="label-border">WebSockets</span> and <span class="label-border">WebHooks</span>microservices are notified in realtime about the "physical device update" event.
</li>
<li>
11) The <span class="label-border">Websocket</span> notifies the web app about the action being successfully applied.
</li>
<li>
12) The <span class="label-border">Webhooks</span> notifies third party services about the action being successfully applied.
</li>
</ul>
<p>
At this point the physical device changed its status and a notification is sent to the web app.
</p>
<hr>
<h2 id="architecture-microservices-why">Why Microservices</h2>
<p>
Successful Internet of Things applications grow more complex over time, and that complexity creates many challenges in development. A monolith application that becomes larger, a single code base that contains all of application logic, where all programmers are involved and where over time it’s difficult for larger team to operate.This approach is perhaps the most natural as a single codebase reduces distribution complexities, but in the long complexities raise up and decreasing software quality and making prices and time to market higher.
</p>
<p>
Microservices architecture is not a new style for building large scale enterprise applications. Companies like Netflix and Amazon have implemented microservices architecture to deliver successful products over the last few years. Lelylan brings these ideas into the Internet of Things.
</p>