<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Shiv Odean on Medium]]></title>
        <description><![CDATA[Stories by Shiv Odean on Medium]]></description>
        <link>https://medium.com/@shivendraodean?source=rss-8cbb96b096c2------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*9Lwoeg2tdHLrOkXdP6Kusg.jpeg</url>
            <title>Stories by Shiv Odean on Medium</title>
            <link>https://medium.com/@shivendraodean?source=rss-8cbb96b096c2------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 10:54:10 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@shivendraodean/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[AI in production: Getting past the demo]]></title>
            <link>https://medium.com/@shivendraodean/ai-in-production-getting-past-the-demo-b9504a5a02b0?source=rss-8cbb96b096c2------2</link>
            <guid isPermaLink="false">https://medium.com/p/b9504a5a02b0</guid>
            <category><![CDATA[ai-in-production]]></category>
            <category><![CDATA[ai-agent]]></category>
            <category><![CDATA[ai-orchestration]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[practical-ai]]></category>
            <dc:creator><![CDATA[Shiv Odean]]></dc:creator>
            <pubDate>Mon, 01 Jun 2026 00:00:22 GMT</pubDate>
            <atom:updated>2026-06-27T02:32:00.236Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7HXDpjVlMTGz-zRXM2UhZQ.jpeg" /></figure><p>A working demo and a working system aren’t the same thing, and with AI it’s surprisingly easy to mistake one for the other. A prototype can look finished — fluent output, a clean run in front of the room — while still being a long way from doing that same job in production, day after day, on messy real data, inside systems that were never built with it in mind. Getting from the first to the second is most of the actual work, and it’s usually the part not correctly budgeted for.</p><p>Part of what makes it so easy to underestimate is that the impressive part is the bit you can see. When a model is already producing sharp, fluent answers, it feels like most of the job is done, when in fact that fluent output is the cheap part. The reliability, the integration, and the handling of everything that doesn’t go to plan are where the real cost sits, and almost none of that is visible while you’re watching a demo. It’s a wide enough gap that one <a href="https://fortune.com/2025/08/18/mit-report-95-percent-generative-ai-pilots-at-companies-failing-cfo/">widely cited MIT study</a> last year found around 95% of corporate AI pilots delivered no measurable return — a figure I’d treat with caution, but one that broadly matches what I have seen.</p><p>So where does that cost actually go? There’s no single answer, and I’d be wary of anyone who claims otherwise. Plenty of projects stall on a vague goal, an absent owner, a budget that runs out, or a team that doesn’t really want to work differently. But a few problems come up again and again, and they tend to have less to do with the model than people expect.</p><p>The first is data. A demo usually runs on a tidy sample that someone pulled together by hand, whereas the real data is spread across several systems, partly out of date, full of fields that don’t quite line up, and shifting all the time. The model hasn’t got any worse; the ground underneath it has just moved, and that’s often enough to throw the whole thing off.</p><p>The second is integration. Sitting a model next to a fifteen-year-old core system has very little to do with prompting and a lot to do with the unglamorous work around it: latency budgets, sensible retries when a call times out, doing something safe when an answer comes back malformed, and generally making all of it behave inside systems that expect fast, predictable, synchronous responses.</p><p>The third is the one often skipped, and the one I’d worry about most: agreeing on what “good” even means before anything gets built. In a demo you can eyeball ten outputs and form a view, but in production there are thousands of them, nobody is reading each one, and when the model is wrong it’s rarely wrong in an obvious way; it’s wrong while sounding completely sure of itself. Unless you’ve decided in advance what a good result looks like and built some way to measure it at scale, you can’t really know whether the thing is working, so it ends up half-trusted and slowly falling out of use.</p><p>None of this is the AI’s fault. Once the model becomes the easy part, the difficulty just moves somewhere else: into your data, your systems, and the decisions you make long before anyone writes a line of code.</p><p>The teams I’ve seen handle this well tend not to start with the model at all. They start with duller questions: where the data actually lives and whether it can be trusted, what the thing has to connect to and what that will really take, what a good outcome looks like and how anyone will know when they’ve got one. It’s a slower and far less impressive way to begin, but they’re usually the ones still running something a year later.</p><p>I don’t want to make this sound tidy, because it isn’t. The gap between a demo and production is only one piece of a much bigger picture, and plenty of projects come apart for reasons that sit well outside it. It’s just the piece I see underestimated most often, and one of the cheaper ones to get right, provided you look at it before a good demo sets expectations you’ll then struggle to meet.</p><p>If you’re about to start something, or you’ve got a prototype that won’t quite make the jump, it’s worth working out where the real difficulty is going to be before you commit to it, because it’s usually not where the demo made it look.</p><p><em>Trying to get something past the demo and into production? I’d be interested to hear where it’s getting stuck. Reach me on </em><a href="https://www.linkedin.com/in/shiv-odean"><em>LinkedIn here</em></a><em>.</em></p><p><em>Originally published at </em><a href="https://shivodean.com/ai-in-production-getting-past-the-demo/"><em>https://shivodean.com</em></a><em> on June 1, 2026.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b9504a5a02b0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The state of AI regulation in Australia — Q2 2026]]></title>
            <link>https://medium.com/@shivendraodean/the-state-of-ai-regulation-in-australia-q2-2026-6a58d18452c4?source=rss-8cbb96b096c2------2</link>
            <guid isPermaLink="false">https://medium.com/p/6a58d18452c4</guid>
            <category><![CDATA[australia]]></category>
            <category><![CDATA[regulation]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[regulatory-compliance]]></category>
            <dc:creator><![CDATA[Shiv Odean]]></dc:creator>
            <pubDate>Wed, 01 Apr 2026 00:00:50 GMT</pubDate>
            <atom:updated>2026-04-25T15:48:18.980Z</atom:updated>
            <content:encoded><![CDATA[<p>In September 2024, the Federal Government <a href="https://consult.industry.gov.au/ai-mandatory-guardrails">proposed ten mandatory AI rules</a> for high-risk settings. By December 2025, the proposal was reversed in favour of “technology-neutral” regulation.</p><p>Technology-neutral does not mean fewer rules. It means every existing law still applies to your AI system — one of them has a hard deadline.</p><p>On 10 December 2026, <a href="https://www.oaic.gov.au/privacy/privacy-legislation/the-privacy-act/the-privacy-and-other-legislation-amendment-act-2024">new transparency rules under the Privacy Act</a> commence. If you’re building or adopting AI in a regulated environment, this date is critical.</p><h3>The National AI Plan</h3><p>The <a href="https://www.industry.gov.au/publications/national-ai-plan">plan</a> is built around three goals — capturing the opportunities, spreading the benefits, keeping Australians safe — each supported by three pillars covering infrastructure, capability, public services, workforce, regulation, and international engagement.</p><p>The government has <a href="https://www.minister.industry.gov.au/ministers/charlton/media-releases/national-ai-plan-empowering-all-australians">committed A$29.9 million</a> to stand up the AI Safety Institute (AISI) in early 2026, with a brief to monitor, test, and share information on emerging AI capabilities, risks and harms. A new “AI Accelerator” round of the Cooperative Research Centres program is on the way. The government also released the <a href="https://www.industry.gov.au/publications/guidance-ai-adoption">Guidance for AI Adoption (GfAA)</a> — a voluntary framework — and signalled tighter expectations for data centres as critical national infrastructure, alongside multi-billion-dollar commitments from Microsoft, Amazon, and Firmus.</p><p>The plan itself contains no AI-specific legislation, no mandatory guardrails, and no timeline for either. It relies on existing laws, supplemented with targeted reforms where gaps emerge.</p><h3>Technology-Neutral in Practice</h3><p>Seven distinct regulatory layers already apply to your AI system, often at the same time. Here is what each layer is, and the one thing it may change about how you build.</p><h4>Privacy Act 1988</h4><p>Australia’s primary information privacy regime, enforced by the OAIC. It already covers personal information used by AI systems for collection, use, disclosure, and access. From 10 December 2026, new <a href="https://www.oaic.gov.au/privacy/privacy-legislation/the-privacy-act/the-privacy-and-other-legislation-amendment-act-2024">automated decision-making transparency obligations</a> sit on top of it.</p><h4>Australian Consumer Law</h4><p>The ACL prohibits misleading or deceptive conduct and unconscionable conduct. The law makes no distinction between a human agent, a chatbot, or a recommendation engine — if your AI output misleads a consumer, the entity that deployed it is on the hook.</p><p>Hallucinations are not a technical curiosity from a regulator’s perspective. They are a product representation, and the company supplying the product owns them.</p><h4>APRA CPS 230</h4><p><a href="https://www.apra.gov.au/operational-risk-management-0">In force since 1 July 2025</a> for all APRA-regulated entities (banks, insurers, super funds). CPS 230 treats AI as core operational risk, not an IT concern.</p><p>If your business is APRA-regulated and you rely on a third-party AI service, that vendor is now in scope of your CPS 230 service provider obligations. Standard SaaS due diligence is not enough.</p><h4>ASIC</h4><p>In October 2024, ASIC published <a href="https://www.asic.gov.au/regulatory-resources/find-a-document/reports/rep-798-beware-the-gap-governance-arrangements-in-the-face-of-ai-innovation/">REP 798 <em>Beware the gap</em></a>. The finding: Australian Financial Services (AFS) and credit licensees are using AI faster than they are governing it. Financial services must be delivered “efficiently, honestly and fairly,” and directors remain accountable for the outcome — model or no model.</p><p>An AI decision you can’t explain is a governance problem, not a tech one.</p><h4>Therapeutic Goods Administration (TGA)</h4><p>If your AI helps make a clinical decision, <a href="https://www.tga.gov.au/products/medical-devices/software-and-artificial-intelligence/manufacturing/artificial-intelligence-ai-and-medical-device-software">the TGA treats it as a medical device</a>. That includes diagnostic tools, AI scribes that suggest diagnoses, and image analysis. Updated guidance landed in February 2026, and the TGA is now actively chasing non-compliant products.</p><p>“We just plugged in an LLM” doesn’t get you out of medical device rules. If your AI influences clinical care, it has to be approved by the TGA before you can supply it in Australia.</p><h4>Online Safety Act</h4><p>The <a href="https://www.esafety.gov.au/industry/codes">eSafety Commissioner has registered industry codes</a> that already apply to generative AI, including obligations on developers and distributors to mitigate the risk of CSAM and pro-terror content.</p><p>If you ship a generative AI product to consumers, you have eSafety obligations today.</p><h4>Guidance for AI Adoption (GfAA)</h4><p><a href="https://www.industry.gov.au/publications/guidance-ai-adoption">Released October 2025</a>, replacing the Voluntary AI Safety Standards. Voluntary in name, increasingly mandatory in practice.</p><p>Federal government procurement teams and large enterprises are starting to require GfAA compliance in their vendor assessments — meaning if you want to sell to government or big corporates, you’ll need to demonstrate it.</p><h3>Changes on 10 December 2026</h3><p>The <a href="https://www.legislation.gov.au/C2024A00118/latest/text">Privacy and Other Legislation Amendment Act 2024</a> adds new clauses to Australian Privacy Principle 1.</p><p>From that date, your privacy policy must disclose two things: the kinds of personal information your AI systems use, and the kinds of decisions those systems make.</p><p>Two things to know. The rules apply to the decision, not the system — if your model was built three years ago and you make a decision with it on 11 December 2026, the rules apply. There is no grandfather clause. And the OAIC isn’t waiting — it started its first proactive compliance sweep in January 2026, targeting around 60 organisations.</p><p>To be ready, you need three things most companies don’t have today: a complete inventory of every system that makes or supports decisions about people, data flow traceability for each one, and an updated privacy policy before the deadline.</p><h3>Steps to take now</h3><p><strong>1. Build an AI inventory.</strong> Every system in your business that uses AI — internal tools, customer-facing features, third-party SaaS with AI baked in. One central inventory, with a single nominated owner. If you can’t list it, you can’t govern it.</p><p><strong>2. Run each one against the three-condition test.</strong> Does it make or support a decision? Could that decision significantly affect someone’s rights or interests? Does it use personal information? If yes to all three, that system is in scope for the December 2026 rules.</p><p><strong>3. Commission a privacy policy gap review.</strong> Get legal advice on your current policy. Most policies written before 2024 will not pass.</p><p><strong>4. If you’re in financial services, healthcare, or government, layer the sector overlay.</strong> Pull APRA CPS 230 (banks, insurers, super), ASIC REP 798 (AFS and credit licensees), or TGA guidance (anything clinical). Your obligations are heavier.</p><p><strong>5. Move AI governance from “future problem” to “current quarter.”</strong> It is not a 2027 issue. The OAIC compliance sweep already started in January 2026.</p><p>There is enough time if you start now.</p><p>—</p><p><em>This post is a technology practitioner’s read of Australia’s current AI regulatory landscape, not legal advice. The rules cited apply differently depending on your sector, scale, and specific use case. Before making compliance decisions, get advice from an Australian privacy or technology lawyer.</em> <em>Working through this in your own organisation? I’d be interested to hear what you’re finding. Reach me on </em><a href="https://www.linkedin.com/in/shiv-odean"><em>LinkedIn here</em></a><em>.</em></p><p><em>Originally published at </em><a href="https://shivodean.com/state-of-ai-regulations-australia/"><em>https://shivodean.com</em></a><em> on April 1, 2026.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6a58d18452c4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Software Architecture — The Onion Architecture]]></title>
            <link>https://medium.com/@shivendraodean/software-architecture-the-onion-architecture-1b235bec1dec?source=rss-8cbb96b096c2------2</link>
            <guid isPermaLink="false">https://medium.com/p/1b235bec1dec</guid>
            <category><![CDATA[design-patterns]]></category>
            <category><![CDATA[information-technology]]></category>
            <category><![CDATA[onionarchitecture]]></category>
            <category><![CDATA[software-architecture]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Shiv Odean]]></dc:creator>
            <pubDate>Tue, 17 Sep 2019 10:14:01 GMT</pubDate>
            <atom:updated>2019-09-30T19:42:51.971Z</atom:updated>
            <content:encoded><![CDATA[<h3>Software Architecture — The Onion Architecture</h3><p>The Onion Architecture is an Architectural <em>Pattern </em>that enables maintainable and evolutionary enterprise systems. It is intended for use at a Solution/System level.</p><h3>The Principles</h3><h4>Good Coupling</h4><p>The primary proposition of this architecture is good coupling. <br>What is coupling ? It is the level of dependency of one <em>thing </em>upon another<em>. </em>The higher the coupling, the lower the ability to change and evolve the system.</p><p>Dependencies should be inward and never outward. Code should depend only on the same layer or layers more central to itself.</p><h4>Behaviour Contracts</h4><p>Business Logic behaviour is declared as contracts with the use of interfaces in a Object-Oriented context.</p><h4>Separation of concerns</h4><p>Each layer bounds together concepts that will have a similar rate of change.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/961/1*n8PscqiwLSmJdeedqO1yyQ.png" /><figcaption>Figure 1 — Conceptual Onion Model</figcaption></figure><h3>The Layers</h3><h4>Domain Model</h4><p>The very centre of the Model, this layer can have dependencies only on itself. It represents the Entities of the Business and the Behaviour of these Entities.</p><h4>Domain Services</h4><p>This layer contains the implementation of the behaviour contracts defined in the Model layer.</p><h4>Application Services</h4><p>This layer is the bridge between external infrastructure and the domain layers. The domain layers often need information or functionality in order to complete business functionality, however they should not directly depend on these. Instead, the application layer needs to depend on the the contracts defined in the Domain Services layer.</p><h4>External Services</h4><p>Databases, Messaging systems, Notification systems, User Interface, etc.</p><h3>Things to Consider</h3><ul><li>This approach is biased towards Object Oriented Programming (OOP). However it’s principles can still be applied in a wider sense.<br>In the future I’d like to explore and write about similar architectures applied to other programming paradigms such as Functional Programming.</li><li>One of the primary objectives of this architecture is to increase maintainability. To achieve this level of maintainability, there is significant work involved in firstly setting up the structure, and secondly maintaining it along the life of the system. Implementation of features may be slower, because there are multiple layers to get through. That’s why Jeffery Palermo recommends it for Enterprise Systems, and not smaller systems non-complex systems.</li><li>I find this pattern to help greatly with Test Driven Development (TDD). I often find it easier to drive out business logic code through tests than I do integrated code. With the Onion Model, I can write my tests against my business domain models and domain services interfaces with ease as they all sit in one place with minimal dependencies and no outward dependencies.</li><li>Dependency Injection is a necessary evil with this architecture. It causes us to rely heavily on something quite external that binds the entire application together and allows it to function at run-time. That being said, it’s not a big deal and it does not outweigh the pros.</li><li>Interfaces define behaviour contracts and stand as foundations amongst the layers. They are the key ingredient in this recipe.</li></ul><h3>Practical Example</h3><p>I wanted to compliment this article with some code. In my implementation, I intend to demonstrate some of the key layers of this architecture and how they work together. See example repository <a href="https://github.com/shivendraodean/architecture-onion"><strong>here</strong></a>.<br><em>Note — </em>The following is my interpretation of this Architecture Pattern and may not be as intended by it’s publishers. In saying that, I have seen this version survive production systems in the wild proving it’s maintainability tenet.<br>Note, I have chosen to call the most centre layer “Core” rather than Domain Models — a personal preference.</p><p><strong>The Problem Domain</strong></p><p>We will use the business domain of a <em>Ride Sharing/Taxi Booking Application. </em>It’s quite straight-forward, just think of Uber or Lyft. There is a <em>Rider</em> — someone who needs to travel from point A to point B, and a <em>Driver</em> — the car driver who will pick-up and drop-off the rider in their vehicle.</p><p>One of the first flows includes a <em>Price</em> estimate. The rider selects their destination, then are presented with an estimated price for their trip. Trip estimation is a business use-case, and it’s the one I’ve selected for our implementation. Figure 2 below outlines the domain within the application structure.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/703/1*aO39ANrL4jyKH26qrhoPNQ.png" /><figcaption>Figure 2 — Practical Onion Model</figcaption></figure><p>Estimating the fare is a core business use case. The business would not functional well if it could not give it’s customers proper pricing. Hence this behaviour shall be declared in the most central layer in the interface <em>IRiderFareCalculator</em>.</p><p>Our fare calculation depends on external services such as routing information and fare models. Interfaces for these are defined in the Domain Services layer — <em>IFareRepostory</em> and <em>IRouteService</em>. <em>RiderFareCalculator</em> is implemented in this layer also, and it depends on the fare repository and route service interfaces declared in the same layer. Note that with this approach, we do not depend on the external service, rather the external service depends on our declared contracts.</p><p>In the Application layer, the <em>FareRepository</em> is able to retrieve data from external sources and transform it into meaningful Business Entities.</p><p>You will see the the Domain Model/Core layer is referenced across multiple layers, and that’s fine, to a certain degree. We are also able to write Unit Tests for our business logic whilst not coupling our tests to implementation either.</p><p>Have a look through the code. Once again here is the link <a href="https://github.com/shivendraodean/architecture-onion">https://github.com/shivendraodean/architecture-onion</a>.</p><p>Thanks for reading!</p><p>:)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1b235bec1dec" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[State Management with MobX]]></title>
            <link>https://levelup.gitconnected.com/state-management-with-mobx-db464399481d?source=rss-8cbb96b096c2------2</link>
            <guid isPermaLink="false">https://medium.com/p/db464399481d</guid>
            <category><![CDATA[mobx]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[ui]]></category>
            <dc:creator><![CDATA[Shiv Odean]]></dc:creator>
            <pubDate>Tue, 12 Feb 2019 10:10:38 GMT</pubDate>
            <atom:updated>2019-02-14T00:42:59.745Z</atom:updated>
            <content:encoded><![CDATA[<p>Here is my view of state management in modern JS applications using MobX.<br>MobX is not very opinionated and does not dictate much about the way you architect your app. I will show you how to setup a project, and use the features of MobX. I’ll also demonstrate some ways to structure your application.</p><p>We will start with a description of what app state is, but please feel free to skip ahead if you’d like to get straight into MobX.</p><p>It’s best if you follow along step-by-step. However, you can find the complimenting code here— <a href="https://github.com/shivendraodean/react-mobx-demo">https://github.com/shivendraodean/react-mobx-demo</a></p><h3><strong>Application State</strong></h3><p>One way of thinking about state is — all the data and metadata that the application stores and manipulates in-order to function correctly. This data could be in the form of variables and objects, both stored globally and locally, which are held in memory.</p><p>States can be split into different categories, and should be done to maintain a good separation of concern. Some of these categories are business/domain, application, and UI states.</p><p><strong>Domain <em>category examples</em> </strong>— <br>Let’s say you have a tax and income calculator on the front-end. The logic of calculating pay brackets, tax percentage, and tax and income calculations, etc are concerns that can live within a domain module.</p><p><strong>Application <em>category</em> example — <br></strong>You need to figure out wether the user should be directed to the authentication pages, or the home page on load. The functionality that determines that can be categorised as an application concern.</p><p><strong>UI <em>category</em> example — <br></strong>You want to disable the ‘Sign up’ button until the user enters a valid email address, and you want to track a ‘isValidEmail’ property.</p><h3>MobX</h3><h4>3 Primary Principles</h4><p><strong>State</strong> — Any data structure can be turned into MobX state, objects, arrays, classes, etc.</p><p><strong>Actions — </strong>Actions are the suggested way to <em>modify</em> state.</p><p><strong>Derivations</strong> — New data or actions can be derived based on changes to existing state.</p><p>Different parts of the UI app will have different domain contexts. In a large-scale application you may find multiple <strong>stores. </strong>A store is a logically grouped set of data structures, grouped around the domain area which that part of the UI focuses on. Typically, I create a class as a store where I put these stateful data structures. I also find it useful to put the actions in the same classes where their related state live.</p><h4>Project Setup</h4><p>Pre-requisites — I assume you already know Javascript and React. I am using <em>Create React App</em> to create a React app. See more information here- <a href="https://github.com/facebook/create-react-app#creating-an-app">https://github.com/facebook/create-react-app#creating-an-app</a></p><p>Run the following commands from a terminal.<br>1 — Create a project for us called react-mobx-demo. <br>2 — Change to app directory.<br>3 — Install mobx and mobx-react<br>4 — Run app.</p><pre>npx create-react-app react-mobx-demo<br>cd react-mobx-demo<br>npm install mobx-react<br>npm install mobx<br>npm start</pre><p>One last bit of setup, I promise. Add this to the babel section of your package.json file. This will enable us to use ESNext <strong><em>decorators</em></strong>.</p><pre>&quot;plugins&quot;: [<br>  [&quot;<a href="http://twitter.com/babel/plugin-proposal-decorator">@babel/plugin-proposal-decorator</a>s&quot;, { &quot;legacy&quot;: true }]<br>]</pre><blockquote>Context — We will be working on a very simple income calculator. It will allow you to enter your income, and calculate your income after tax.</blockquote><h4>Let’s start writing code..</h4><p><strong>App.js file-</strong> I’m going to remove some boiler plate code from lines 11–20. Let’s add an input box for our income, and a button. Replace the render function to return the following -</p><pre>&lt;div className=&quot;App&quot;&gt;<br>  &lt;header className=&quot;App-header&quot;&gt;<br>    &lt;input type=&quot;text&quot; placeholder=&quot;Income&quot; className=&quot;income-input&quot;/&gt;<br>    &lt;button type=&quot;button&quot; className=&quot;calculate-btn&quot;&gt;Calculate&lt;/button&gt;<br>    &lt;img src={logo} className=&quot;App-logo&quot; alt=&quot;logo&quot; /&gt;<br>  &lt;/header&gt;<br>&lt;/div&gt;</pre><p>Add some styling to App.css.</p><pre>.income-input {<br>  background-color: &#39;#ffffff&#39;;<br>  height: 20px;<br>}</pre><pre>.calculate-btn {<br>  width: 140px;<br>  margin-top: 10px;<br>}</pre><h4>The Domain Store</h4><p>Firstly, we’re going create a file to store the income and tax state. I will refer to this as a <strong>store. </strong>Create a file under the src directory called <strong>incomeDomainStore.js </strong>and add the following -</p><pre>import { action, computed, observable } from &quot;mobx&quot;</pre><pre>class IncomeDomainStore {<br>  <br>}</pre><pre>export default IncomeDomainStore</pre><p>Here, we have simply created a Javascript class and imported 3 mobx features. The <strong>observable</strong> allows us to turn any data structure into an observable state. The <strong>action </strong>allows us to turn a function into one that manipulates that state. The <strong>computed </strong>allows us to <em>derive </em>some value based on the state change.</p><h4>Provider</h4><p>Before we start adding observables, actions, and computed values to the store, we should first make the store accessible by our components. To do this, I will use something called the Provider. In <strong><em>index.js, </em></strong>add the following imports and replace the render function.</p><pre>import { Provider } from &#39;mobx-react&#39;<br>import IncomeDomainStore from &#39;./incomeDomainStore&#39;</pre><pre>ReactDOM.render(&lt;Provider incomeDomainStore={new IncomeDomainStore()}&gt;&lt;App /&gt;&lt;/Provider&gt;, document.getElementById(&#39;root&#39;))</pre><p>What we are doing is creating a new instance of that domain store, and providing it down the App, so the components can inject it as dependencies.</p><h4>Action and Observable</h4><p>Let’s take a look at observables and actions. Change the <strong><em>store</em></strong> class to this -</p><pre>class IncomeDomainStore {<br>  @observable incomeBeforeTax = 0</pre><pre>  @action setIncome (incomeAmount) {<br>    this.incomeBeforeTax = parseInt(incomeAmount)<br>  }<br>}</pre><p>The variable <em>incomeBeforeTax</em> is decorated as an observable. Any observer component that uses this observable in its render method will be re-rendered when this data changes.<br>The <em>action</em> is a function that will change the observable value.</p><p>It’s time to use this store. Change <strong><em>App.js</em></strong> appropriately with the code below.</p><pre>import React, { Component } from &#39;react&#39;;<br>import { observer, inject } from &#39;mobx-react&#39;<br>import logo from &#39;./logo.svg&#39;;<br>import &#39;./App.css&#39;;</pre><pre><a href="http://twitter.com/inject">@inject</a>(&#39;incomeDomainStore&#39;)<br><a href="http://twitter.com/observer">@observer</a><br>class App extends Component {<br>  render() {<br>    return (<br>      &lt;div className=&quot;App&quot;&gt;<br>        &lt;header className=&quot;App-header&quot;&gt;<br>          &lt;input type=&quot;text&quot; onChange={event =&gt; this.props.incomeDomainStore.setIncome(event.target.value)} placeholder=&quot;Income&quot; className=&quot;income-input&quot;/&gt;<br>          &lt;button type=&quot;button&quot; className=&quot;calculate-btn&quot;&gt;Calculate&lt;/button&gt;<br>          &lt;p&gt;Income: ${this.props.incomeDomainStore.incomeBeforeTax}.00&lt;/p&gt;<br>          &lt;img src={logo} className=&quot;App-logo&quot; alt=&quot;logo&quot; /&gt;<br>        &lt;/header&gt;<br>      &lt;/div&gt;<br>    );<br>  }<br>}</pre><pre>export default App;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/688/1*kXbfAXli19C7IFtNeBzksQ.png" /><figcaption>Figure 1</figcaption></figure><p>Save everything and Run the app. Now enter a number in the input box, and you will see the observable being rendered on the screen.</p><h4>Derivations with Computed</h4><p>Let’s say we live in country La La land where income below $20,000 is taxed at 10% and income above that at 20%. So based on the income that the user enters, we can derive the percentage of tax that will apply to them. To implement this logic, add the following <strong>computed</strong> getter to our store.</p><pre><a href="http://twitter.com/computed">@computed</a> get calculatedTaxPercentage () {<br> return this.incomeBeforeTax &lt; 20000 ? 10 : 20<br>}</pre><p>Then back in our <strong>App.js</strong> file, add the following label.</p><pre>&lt;p&gt;Tax percentage: {this.props.incomeDomainStore.calculatedTaxPercentage}%&lt;/p&gt;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/614/1*s-esYDmmcmzRqZqzDshYLw.png" /><figcaption>Figure 2</figcaption></figure><p>Now if you run the app and enter an amount bigger than $20000, you will see the tax amount derived and displayed.</p><h4>The UI Store</h4><p>Let’s move on to implementing the Calculate button. I want to now add logic to only show the calculated information when the user clicks calculate. This is View logic, and doesn’t really fit in with our domain store so we can create a new store with it’s View concerns. Add a new file called <strong>incomeUiStore.js. </strong>Add the code below. You know what to do!</p><pre>import { action, observable } from &quot;mobx&quot;</pre><pre>class IncomeUiStore {<br>  <a href="http://twitter.com/observable">@observable</a> shouldShowCalculations</pre><pre><a href="http://twitter.com/action">@action</a> showCalculation () {<br>    this.shouldShowCalculations = true<br>  }<br>}</pre><pre>export default IncomeUiStore</pre><p>Remember that we won’t be able to inject this store until we provide it to the App. So let’s do that by adding a new instance of this store to the index.js file.</p><pre>import IncomeUiStore from &#39;./incomeUiStore&#39;</pre><pre>ReactDOM.render(&lt;Provider incomeDomainStore={new IncomeDomainStore()} incomeUiStore={new IncomeUiStore()}&gt;&lt;App /&gt;&lt;/Provider&gt;, document.getElementById(&#39;root&#39;));</pre><p>Back in our<strong> App.js</strong> file, we can now inject the added store. Let’s also make a small change to decide the visibility of the labels.</p><pre>class App extends Component {<br>  render() {<br>    return (<br>      &lt;div className=&quot;App&quot;&gt;<br>        &lt;header className=&quot;App-header&quot;&gt;<br>          &lt;input type=&quot;text&quot; onChange={event =&gt; this.props.incomeDomainStore.setIncome(event.target.value)} placeholder=&quot;Income&quot; className=&quot;income-input&quot;/&gt;<br>          &lt;button type=&quot;button&quot; onClick={() =&gt; this.props.incomeUiStore.showCalculation()} className=&quot;calculate-btn&quot;&gt;Calculate&lt;/button&gt;<br>          {this.getCalculation()}<br>          &lt;img src={logo} className=&quot;App-logo&quot; alt=&quot;logo&quot; /&gt;<br>        &lt;/header&gt;<br>      &lt;/div&gt;<br>    );<br>  }</pre><pre>getCalculation () {<br>    if (!this.props.incomeUiStore.shouldShowCalculations) return null</pre><pre>return (<br>      &lt;div&gt;<br>        &lt;p&gt;Income: ${this.props.incomeDomainStore.incomeBeforeTax}.00&lt;/p&gt;<br>        &lt;p&gt;Tax percentage: {this.props.incomeDomainStore.calculatedTaxPercentage}%&lt;/p&gt;<br>      &lt;/div&gt;<br>    )<br>  }<br>}</pre><h4>Another Derivation</h4><p>Let’s add our final computed value, the income after tax value. Add the following code in the store and the Component respectively.</p><pre><a href="http://twitter.com/computed">@computed</a> get calculatedIncomeAfterTax () {<br>    if (this.incomeBeforeTax &lt; taxBracket) {<br>      return this.incomeBeforeTax * 0.9<br>    }</pre><pre>    return this.incomeBeforeTax * 0.8<br>  }</pre><pre>getCalculation () {<br>    if (!this.props.incomeUiStore.shouldShowCalculations) return null</pre><pre>return (<br>      &lt;div&gt;<br>        &lt;p&gt;Income before tax: ${this.props.incomeDomainStore.incomeBeforeTax}.00&lt;/p&gt;<br>        &lt;p&gt;Tax percentage: {this.props.incomeDomainStore.calculatedTaxPercentage}%&lt;/p&gt;<br>        &lt;p&gt;Income after tax: ${this.props.incomeDomainStore.calculatedIncomeAfterTax}&lt;/p&gt;<br>      &lt;/div&gt;<br>    )<br>  }</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/738/1*YDrV8sZroHlYNF0bHcQbCA.png" /><figcaption>Figure 3</figcaption></figure><h4>App Structure</h4><p>I’m not going to do a refactoring here, and I won’t be re-organise files into a folder structure. I can briefly discuss folder structure however.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/536/1*aBMukEtlTNhxL4kO3B5Szw.png" /></figure><p>One way to do it would be to keep the stores in a separate directory from the components.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/562/1*XZrNMf97BorihMsZ5cu27g.png" /></figure><p>Another approach — keep everything related to the income calculator domain in one place.</p><p>You can find all the code here — <a href="https://github.com/shivendraodean/react-mobx-demo">https://github.com/shivendraodean/react-mobx-demo</a></p><p>That’s it for now. Thanks for reading.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6H62wzR6IlIzccXfna_fcQ.jpeg" /></figure><figure><a href="https://levelup.gitconnected.com/"><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*E6CoI_MRyZ1JInNPsBSHtA.png" /></a></figure><p><a href="https://gitconnected.com/learn/react">Learn React - Best React Tutorials (2019) | gitconnected</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=db464399481d" width="1" height="1" alt=""><hr><p><a href="https://levelup.gitconnected.com/state-management-with-mobx-db464399481d">State Management with MobX</a> was originally published in <a href="https://levelup.gitconnected.com/">Level Up Coding</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[API Contract Testing with Postman]]></title>
            <link>https://levelup.gitconnected.com/api-contract-testing-with-postman-a8af93e79d5?source=rss-8cbb96b096c2------2</link>
            <guid isPermaLink="false">https://medium.com/p/a8af93e79d5</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[testing]]></category>
            <category><![CDATA[postman]]></category>
            <category><![CDATA[api]]></category>
            <category><![CDATA[nodejs]]></category>
            <dc:creator><![CDATA[Shiv Odean]]></dc:creator>
            <pubDate>Wed, 16 Jan 2019 08:47:36 GMT</pubDate>
            <atom:updated>2019-02-27T12:28:30.601Z</atom:updated>
            <content:encoded><![CDATA[<p>I’m going to show you a simple way of testing API contracts using Postman and Node.js. You can set this up very quickly.</p><p>I am building a mobile app for my current company. One of the challenges we face are the frequent changes to the API endpoints/contract. We also face communication challenges because we are collocated — developers working on this particular API reside in Barcelona, Spain whereas I am in New Zealand.</p><p>I needed a mechanism which provides early and consistent feedback on changes to those API contracts. Writing integration tests seemed too heavy, and I needed something that could be done much quicker.</p><h4>My solution to the problem</h4><p>Firstly we will be using a tool called <strong>Postman</strong>. Postman is a very useful tool that aids API development. It enables the creation of HTTP requests, saving and sharing collections of requests, writing tests against responses from these requests, and much more.</p><p>Secondly, we will write a Javascript file which will allow us to run these Postman requests and tests in an automated fashion.</p><p>I will try my best to describe each step. I apologize to the more experienced readers if it’s oversimplified, and to the lesser experienced technologists if I have not explained enough. You can find the code for this on Github here — <a href="https://github.com/shivendraodean/api-contract-testing">https://github.com/shivendraodean/api-contract-testing</a></p><p><strong><em>Let’s start!</em></strong> Please download the following tools -</p><ul><li>Postman — <a href="https://www.getpostman.com/">https://www.getpostman.com</a></li><li>Node.js — <a href="https://nodejs.org/en/">https://nodejs.org/en/</a></li><li>Newman — <a href="https://www.npmjs.com/package/newman">https://www.npmjs.com/package/newman</a></li></ul><h4>1 — Create a basic API Project</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/828/1*hi4KiBkfKplnx0yrOlXlRA.png" /><figcaption>Figure 1 — Project details</figcaption></figure><p>Copy and paste the below commands one line at a time into a terminal.</p><p><strong><em>npm init </em></strong>will prompt for more information, fill in according to figure 1.</p><pre>mkdir api-contract-testing<br>cd api-contract-testing<br>npm init<br>touch app.js<br>touch apiContractTest.js<br>npm install express newman</pre><p>Copy and paste the following into app.js. This is a basic express.js server application. Line 11 is basically the root <em>route </em>which will return us some data.</p><pre>const express = require(&#39;express&#39;)<br>const app = express()<br>const port = 3000</pre><pre>const testData = {<br>  firstName: &#39;Homer&#39;,<br>  lastName: &#39;Simpson&#39;<br>}</pre><pre>app.get(&#39;/&#39;, (req, res) =&gt; res.send(testData))</pre><pre>app.listen(port, () =&gt; console.log(`Server listening on port ${port}`))</pre><p>Save the file and execute the following command. Then open a web browser and navigate to <a href="http://localhost:3000/">http://localhost:3000</a></p><p>This result is what we will now test with postman.</p><pre>node app.js</pre><h4>2 — Create a Postman Collection</h4><p><strong>2.1 —</strong> Create a new get request</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ai0_ldkpmu9lNnr1K20T_g.png" /></figure><p><strong>2.2 —</strong> Click on the Tests tab to add a test to the request. The <strong><em>schema </em></strong>refers to a global variable, which we will define in the next step<em>. </em>Paste the following.</p><pre>pm.test(&quot;Homer&#39;s schema should be correct&quot;, function() {<br>    var response = pm.response.json();<br>    <br>    var result=tv4.validateResult(response, schema)</pre><pre>    pm.expect(result.valid).to.be.true;<br>});</pre><p>Next we define the schema. I generated the schema from this web app -<a href="https://jsonschema.net/#/">https://jsonschema.net/#/</a></p><p>It basically allows you to paste in any JSON on the left side, and infers the JSON schema on the right which you can then copy and use.</p><p>Click on Pre-request Script and paste the following —</p><pre>schema = {<br>  &quot;definitions&quot;: {},<br>  &quot;$schema&quot;: &quot;<a href="http://json-schema.org/draft-07/schema#">http://json-schema.org/draft-07/schema#</a>&quot;,<br>  &quot;$id&quot;: &quot;<a href="http://example.com/root.json">http://example.com/root.json</a>&quot;,<br>  &quot;type&quot;: &quot;object&quot;,<br>  &quot;title&quot;: &quot;The Root Schema&quot;,<br>  &quot;required&quot;: [<br>    &quot;firstName&quot;,<br>    &quot;lastName&quot;<br>  ],<br>  &quot;properties&quot;: {<br>    &quot;firstName&quot;: {<br>      &quot;$id&quot;: &quot;#/properties/firstName&quot;,<br>      &quot;type&quot;: &quot;string&quot;,<br>      &quot;title&quot;: &quot;The Firstname Schema&quot;,<br>      &quot;default&quot;: &quot;&quot;,<br>      &quot;examples&quot;: [<br>        &quot;Homer&quot;<br>      ],<br>      &quot;pattern&quot;: &quot;^(.*)$&quot;<br>    },<br>    &quot;lastName&quot;: {<br>      &quot;$id&quot;: &quot;#/properties/lastName&quot;,<br>      &quot;type&quot;: &quot;string&quot;,<br>      &quot;title&quot;: &quot;The Lastname Schema&quot;,<br>      &quot;default&quot;: &quot;&quot;,<br>      &quot;examples&quot;: [<br>        &quot;Simpson&quot;<br>      ],<br>      &quot;pattern&quot;: &quot;^(.*)$&quot;<br>    }<br>  }<br>}</pre><p>Now if you press ‘Send’, the request will be sent and the test will be run.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/968/1*KEyAtZhg920YhF9FUVp2QA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*umYXjBHEsZ_xMQBnv8J4rA.png" /></figure><p><strong>2.3 — </strong>Save request to collection. Now that you have a collection, you can open the <strong>Test Runner </strong>and run tests for the collection.</p><p><strong>2.4 — </strong>Export collection. Click on the ellipse next to the collection and select ‘export’. Specify the root of your JS as the download destination.</p><p><strong>3 — Programmatically run tests with Javascript</strong></p><p>Copy the following script into apiContractTest.js.</p><pre>const newman = require(&#39;newman&#39;)</pre><pre>newman.run({<br>  collection: require(&#39;./homer-simpson-api.postman_collection.json&#39;),<br>  reporters: &#39;cli&#39;,<br>})</pre><p>Copy the following into the scripts section of your package.json file.</p><pre>&quot;contractTests&quot;: &quot;node ./apiContractTest.js&quot;,</pre><p>Now execute this, ensuring the API server is running—</p><pre>npm run contractTests</pre><p>There you have it. I hope you find this useful.</p><p>You can find the code for this on Github here— <a href="https://github.com/shivendraodean/api-contract-testing">https://github.com/shivendraodean/api-contract-testing</a></p><p>Please like and share this if you found it helpful.</p><figure><a href="https://levelup.gitconnected.com/"><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*E6CoI_MRyZ1JInNPsBSHtA.png" /></a></figure><p><a href="https://gitconnected.com/learn/javascript">Learn JavaScript - Best JavaScript Tutorials (2019) | gitconnected</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AmS8XNM4YxY8AAm5gL1OgA.jpeg" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a8af93e79d5" width="1" height="1" alt=""><hr><p><a href="https://levelup.gitconnected.com/api-contract-testing-with-postman-a8af93e79d5">API Contract Testing with Postman</a> was originally published in <a href="https://levelup.gitconnected.com/">Level Up Coding</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Software Architecture — The Monolithic Approach]]></title>
            <link>https://medium.com/@shivendraodean/software-architecture-the-monolithic-approach-b948ded8c333?source=rss-8cbb96b096c2------2</link>
            <guid isPermaLink="false">https://medium.com/p/b948ded8c333</guid>
            <category><![CDATA[software-design-patterns]]></category>
            <category><![CDATA[monolithic]]></category>
            <category><![CDATA[software-principles]]></category>
            <category><![CDATA[software-design]]></category>
            <category><![CDATA[software-architecture]]></category>
            <dc:creator><![CDATA[Shiv Odean]]></dc:creator>
            <pubDate>Tue, 18 Sep 2018 10:37:25 GMT</pubDate>
            <atom:updated>2018-09-18T10:45:09.742Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2z5tlXflfIDWd8DXnX3IaQ.jpeg" /></figure><p>Welcome to part 1 of my series of articles in Software Architecture. In this series, I write about software architecture, architecture at different levels of abstraction, and common architectural patterns.</p><p>Why am I writing this? I have recently been focusing on educating myself in this area. This information enables me to think about Software Development from different angles and allows me to think about the Bigger picture when creating software. I want to share my learnings and experiences, and hopefully, it benefits you in some way.</p><p>Let’s start with <strong>Monolithic</strong> A<strong>rchitectures</strong>. This approach was the traditional way of designing a system. Typically, a monolithic software application consists of many different modules working together to deliver many different functionalities.</p><p>Some definitions of the term monolith are —</p><ul><li>A single block or piece of stone of considerable size, especially when used in architecture or sculpture.</li><li>Something having a uniform, massive, redoubtable, or inflexible quality or character.</li></ul><p>A common software program of this nature may contain code for the User-Interface, Business Logic, External Integrations, Database Access, etc. Along with holding these different functional capabilities, there is typically many or all of the different business domains present in one software application.</p><p>Layered architecture is a common pattern seen in monolithic applications. This may be due to the initial structure or lack-there-of it, and it’s suitability to the problem at hand. Frameworks have some blame for this. Many of the most common Frameworks in Dot-Net, Java, and Javascript come with default MVC templates. This leads developers to think less about how they should be architecting their solution to support the changing needs of their domain.</p><p>Let’s take a super simplified example of a Medical System’s Domain, <em>see figure 1 below</em>. In a nutshell, the domain is: Patients visit the Hospital through an appointment, and a Doctor typically diagnoses or treats the patient.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/651/1*atgS_sNP_F4oDjMEjNI4rw.png" /><figcaption>Figure 1 — Domain Elements of a Medical System.</figcaption></figure><p>In the above domain, the application has UI functionality for booking appointments, viewing patient information, recording diagnosis, viewing doctors information, and much more. To enable that UI, the ‘Back-End’ hosts this information and is responsible for processing requests through a means of data transport.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/591/1*wwjlQvhquH0hf23TEdFNQg.png" /><figcaption>Figure 2 — Monolithic Layered Architecture of a medical system.</figcaption></figure><p>This architecture allows for the technical capability to be changed fairly easily, especially if they are isolated to a particular layer. The use of interfaces for the purpose of isolating layer dependencies makes sense. It also makes sense when it comes to testing because small units are easily testable if confined to the boundaries of each layer. Changing the database technology for a different one is an example of a change in technical capability which implies changes to only one of the layers. We could also change the UI framework from one to another. Technical changes are only one side of the problem; a change in business requirement implies a change across all layers, and that means we have to coordinate those changes across each layer. Imagine there is a new business requirement —<em> A patient must be able to specify if they’d like to be sent a reminder when creating an appointment</em>. As we can see in figure 2, the <strong>Appointment</strong> domain object is represented across all the layers, so we must change all these layers even though only one part of the domain has changed.</p><p>There are some further notable points to consider when working with monolithic applications. It is inevitable that the codebase will grow to a large size. To deliver a change in one part of the domain such as <em>Appointments, </em>we must ensure that we do not affect other parts of the system. Our new functionality cannot be delivered without packaging the entire application, building all the code, and running all of the tests — this stuff can take a lot of time! Today agility and change is favoured and so constant change in business requirements must be supported by development. It’s no longer a big ask for iterative changes to be deployed and delivered to production within minutes. Monolithic applications could potentially slow you down in this sense. However, I would argue that because not all environments are like this, it makes sense NOT to optimise for super fast delivery unless it is needed.</p><p>When monolithic applications become unmaintainable, organisations see Micro-Services as a silver bullet. And that is a problem. Microservices have a certain set of benefits such as independent deployments and good cohesion (which I will discuss in a later stage of this series), however, if you do not need those features, then you don’t need Microservices!</p><p>I propose, that putting more thought into the inner architecture and design of a monolithic application would be of more value. There is usually one thing consistent in software, and that is Change. The architecture must enable change.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b948ded8c333" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[KeystoneJS, A Javascript CMS (Part 4— Accessing Data)]]></title>
            <link>https://medium.com/@shivendraodean/keystonejs-a-javascript-cms-part-4-accessing-data-c77806d4a8e4?source=rss-8cbb96b096c2------2</link>
            <guid isPermaLink="false">https://medium.com/p/c77806d4a8e4</guid>
            <category><![CDATA[keystonejs]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[cms]]></category>
            <category><![CDATA[nodejs]]></category>
            <dc:creator><![CDATA[Shiv Odean]]></dc:creator>
            <pubDate>Mon, 29 May 2017 13:13:42 GMT</pubDate>
            <atom:updated>2018-06-30T08:11:15.190Z</atom:updated>
            <content:encoded><![CDATA[<blockquote><a href="https://medium.com/p/ac0a754a5693/edit"><em>Part 1 — Getting Started</em></a><a href="https://medium.com/@shivendraodean/keystonejs-a-javascript-cms-part-2-code-structure-and-the-db-model-437a6f3e23fe"><em><br>Part 2 — Code Structure &amp; the DB Model</em></a><em><br></em><a href="https://medium.com/@shivendraodean/keystonejs-a-javascript-cms-part-3-routes-views-templates-cafb0d9c86db"><em>Part 3 — Routes, View, and Templates</em></a><em><br></em><a href="https://medium.com/@shivendraodean/keystonejs-a-javascript-cms-part-4-accessing-data-c77806d4a8e4"><em>Part 4 — Accessing Data</em></a></blockquote><p>In the last session, we created a route, a view, and a new template.<br>In this session, we will focus with a bit more depth on accessing our data.</p><p>By default, all routes are registered in routes/index.js. Let’s begin by adding some structure —</p><ol><li>Create a f<em>older called `api` in routes.</em></li><li>Create a f<em>older called `announcement` in routes/api.</em></li><li>Create a file<em> called `</em><em>index.js` in routes/api/announcement and add the following code :</em></li></ol><pre>var keystone = require(&#39;keystone&#39;);</pre><pre>var Announcement = keystone.list(&#39;Announcement&#39;).model;</pre><pre>var handlers = {<br>  getAnnouncements: function(req, res) {<br>    Announcement.find().exec(function(err, data) {<br>      if(err) {<br>        console.log(err);<br>        res.status(500).send(&#39;DB Error&#39;);<br>      }</pre><pre>res.status(200).send(data);<br>    });<br>  }<br>}</pre><pre>module.exports = handlers;</pre><p>The code above retrieves Announcement data stored on our database. <strong>keystone.list(‘Announcement’).model </strong>gives us the Mongoose model. Once we obtain a mongoose model, we can then query the Mongo database directly, i.e. With <em>Announcement.find().</em></p><p>The next step is to utilise the db function above. Replace the contents of file <strong><em>routes/index.js </em></strong>with :</p><pre>var keystone = require(&#39;keystone&#39;);<br>var middleware = require(&#39;./middleware&#39;);<br>var importRoutes = keystone.importer(__dirname);</pre><pre>var apiHandlers = require(&#39;./api/announcement&#39;);<br>var routes = {<br> views: importRoutes(&#39;./views&#39;),<br>};</pre><pre>keystone.pre(&#39;routes&#39;, middleware.initLocals);<br>keystone.pre(&#39;render&#39;, middleware.flashMessages);</pre><pre>exports = module.exports = function (app) {<br> // Views<br> app.get(&#39;/&#39;, routes.views.index);<br> app.get(&#39;/announcement&#39;, routes.views.announcement);</pre><pre>// API Routes<br> app.get(&#39;/api/announcement&#39;, apiHandlers.getAnnouncements);<br>};</pre><p>Here, we have imported the handler and used it in the <strong>ExpressJS </strong>route -<strong><em>app.get(‘/api/announcement’, apiHandlers.getAnnouncements);</em></strong><br>Basically when the server is asked for a resource at the endpoint <em>‘/api/announcement’</em>, it will call our handler function with the request and response object.</p><p>Save and Reload the app. (You may need to stop and restart it — node keystone.js). Go to <strong><em>localhost:3000/api/announcement </em></strong>into the browser and you should see an empty array returned. Empty because we haven’t added any data yet.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/758/1*JXLojAmlXf22587wObqF-w.png" /></figure><p>Let’s add some Announcement records using the admin UI. Browse to <a href="http://localhost:3000/keystone/signin"><strong><em>http://localhost:3000/keystone/</em></strong></a><strong><em> </em></strong>and create an announcement entry.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*S6bLv6D5gZ9Az9guKrEmyQ.png" /></figure><p>Calling <strong><em>localhost:3000/api/announcement </em></strong>will now return the new Announcement record/s.</p><pre>[{&quot;_id&quot;:&quot;592c0b126f3845652544bb36&quot;,&quot;description&quot;:&quot;Brand New Website Created for School.&quot;,&quot;title&quot;:&quot;My School&#39;s Website Launch!&quot;,&quot;__v&quot;:0,&quot;date&quot;:&quot;2017-04-01T10:50:33.000Z&quot;}]</pre><h3>Displaying Data In the UI</h3><p>We can very easily use the same code to access data and display it to the front-end. Open up <strong><em>routes/views/announcement.js </em></strong>and add the following-</p><pre>var Announcement = keystone.list(&#39;Announcement&#39;).model;<br> Announcement.find().exec(function(err, data) {<br>  locals.announcements = data;<br> });</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*r5JfdxYnw_MuiYsX-i9uTw.png" /></figure><p>Now Replace the code contents of templates/views/announcement.hbs with-</p><pre>&lt;div class=&quot;container&quot;&gt;<br> &lt;h2&gt;Announcements&lt;/h2&gt;</pre><pre>&lt;div class=&quot;list-group&quot;&gt;<br>  {{#each announcements}}<br>   &lt;a href=&quot;#&quot; class=&quot;list-group-item&quot;&gt;<br>    &lt;h4 class=&quot;list-group-item-heading&quot;&gt;{{title}}&lt;/h4&gt;<br>    &lt;p class=&quot;list-group-item-text&quot;&gt;{{description}}&lt;/p&gt;<br>    &lt;p&gt;{{date}}&lt;/p&gt;<br>   &lt;/a&gt;<br>  {{/each}}<br> &lt;/div&gt;</pre><pre>&lt;/div&gt;</pre><p>We should end up with a list of announcements displayed nicely on the Announcements page. We can go to the admin UI and add new announcement entries, and you will see those reflected on the page.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7xvH24m2xiw1Av0ta9XWtw.png" /></figure><p>Thanks for reading. Happy Coding!</p><blockquote>Need professional software development services ? <br>Visit <a href="http://www.biztek.co.nz/">http://www.biztek.co.nz/</a></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c77806d4a8e4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[KeystoneJS, A Javascript CMS (Part 3— Routes, Views & Templates)]]></title>
            <link>https://medium.com/@shivendraodean/keystonejs-a-javascript-cms-part-3-routes-views-templates-cafb0d9c86db?source=rss-8cbb96b096c2------2</link>
            <guid isPermaLink="false">https://medium.com/p/cafb0d9c86db</guid>
            <category><![CDATA[node]]></category>
            <category><![CDATA[keystonejs]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[cms]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Shiv Odean]]></dc:creator>
            <pubDate>Mon, 29 May 2017 13:10:11 GMT</pubDate>
            <atom:updated>2018-02-21T08:34:16.793Z</atom:updated>
            <content:encoded><![CDATA[<blockquote><a href="https://medium.com/p/ac0a754a5693/edit"><em>Part 1 — Getting Started</em></a><a href="https://medium.com/@shivendraodean/keystonejs-a-javascript-cms-part-2-code-structure-and-the-db-model-437a6f3e23fe"><em><br>Part 2 — Code Structure &amp; the DB Model</em></a><em><br></em><a href="https://medium.com/@shivendraodean/keystonejs-a-javascript-cms-part-3-routes-views-templates-cafb0d9c86db"><em>Part 3 — Routes, View, and Templates</em></a><em><br></em><a href="https://medium.com/@shivendraodean/keystonejs-a-javascript-cms-part-4-accessing-data-c77806d4a8e4"><em>Part 4 — Accessing Data</em></a></blockquote><p>In the last session, we created a new Database Model and saw the reflected change in the Admin UI. In this session we will create a new route, and a view to go with it.</p><h3>Creating a Route</h3><p>The following line creates an endpoint/route for our new page. Add it to <strong>routes/index.js</strong>. (Line 38)</p><pre>app.get(&#39;/announcement&#39;, routes.views.announcement);</pre><h3>Creating a View</h3><p>Create file <strong><em>announcement.js</em></strong><em> </em>in routes/views, and add this :</p><pre>var keystone = require(&#39;keystone&#39;);</pre><pre>exports = module.exports = function (req, res) {</pre><pre>var view = new keystone.View(req, res);<br>    var locals = res.locals;<br>    locals.section = &#39;announcement&#39;;<br>    view.render(&#39;announcement&#39;);<br>};</pre><p>The important bit here is <strong><em>view.render(‘announcement’)</em></strong>, which looks for the announcement template in the <em>templates/views </em>directory. This is specified in the <strong>views </strong>option of file keystone.js.</p><p>For the final piece in routing, we should add this line to our <strong><em>routes/middleware.js </em></strong>file. This will add our new route into the Navigation Bar of the app.</p><pre>{ label: &#39;Announcement&#39;, key: &#39;announcement&#39;, href:&#39;/announcement&#39; }</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FrMd7U4-q1S_iF1nr0Cwvw.png" /></figure><p>Browse to the homepage, and you will see an Announcement link in the Nav Bar. Click on it, but at this stage it will return a 500 Error. Let’s fix that below.</p><h3>Creating a Template</h3><p>Create a file <strong><em>announcement.hbs</em></strong> in <em>templates/views. <br></em>Paste the following as a placeholder <em>-</em></p><pre>&lt;div class=&quot;container&quot;&gt;<br> &lt;h2&gt;Announcements&lt;/h2&gt;<br> &lt;h3&gt;Hello, Welcome to the School&#39;s Announcement Page&lt;/h3&gt;<br>&lt;/div&gt;</pre><p>Now navigating to the Announcements page will work.</p><p>In the next session we will be working to access the data which keystone is storing for us in MongoDB.</p><p><a href="https://medium.com/@shivendraodean/keystonejs-a-javascript-cms-part-4-accessing-data-c77806d4a8e4">KeystoneJS, A Javascript CMS (Part 4— Accessing Data)</a></p><blockquote>Need professional software development services ? <br>Visit <a href="http://www.biztek.co.nz/">http://www.biztek.co.nz/</a></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cafb0d9c86db" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[KeystoneJS, A Javascript CMS (Part 2— Code Structure and the DB Model)]]></title>
            <link>https://medium.com/@shivendraodean/keystonejs-a-javascript-cms-part-2-code-structure-and-the-db-model-437a6f3e23fe?source=rss-8cbb96b096c2------2</link>
            <guid isPermaLink="false">https://medium.com/p/437a6f3e23fe</guid>
            <category><![CDATA[cms]]></category>
            <category><![CDATA[keystonejs]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[node]]></category>
            <dc:creator><![CDATA[Shiv Odean]]></dc:creator>
            <pubDate>Mon, 29 May 2017 13:05:11 GMT</pubDate>
            <atom:updated>2018-02-21T08:33:31.696Z</atom:updated>
            <content:encoded><![CDATA[<blockquote><a href="https://medium.com/p/ac0a754a5693/edit"><em>Part 1 — Getting Started</em></a><a href="https://medium.com/@shivendraodean/keystonejs-a-javascript-cms-part-2-code-structure-and-the-db-model-437a6f3e23fe"><em><br>Part 2 — Code Structure &amp; the DB Model</em></a><em><br></em><a href="https://medium.com/@shivendraodean/keystonejs-a-javascript-cms-part-3-routes-views-templates-cafb0d9c86db"><em>Part 3 — Routes, View, and Templates</em></a><em><br></em><a href="https://medium.com/@shivendraodean/keystonejs-a-javascript-cms-part-4-accessing-data-c77806d4a8e4"><em>Part 4 — Accessing Data</em></a></blockquote><p>In the last session, we performed our mandatory installations and generated our app called <em>myschool (</em>a very simple website for a school). We will now familiarise ourselves with the code structure, and create a database model.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/330/1*XnsDhhcuF1wR4llFrKlVKQ.png" /><figcaption>Code Structure</figcaption></figure><p><strong>models</strong> — Contains database models. We will discuss this later in further detail.</p><p><strong>public</strong> — Static resources publicly available to the app.</p><p><strong>routes</strong> — Javascript files, such as view controllers and api controllers.</p><p><strong>templates</strong> —Contains semantic view templates.</p><p><strong>Important Files</strong></p><p><strong>keystone.js- </strong>The main application file which configures and starts the app.<br><strong>routes/index.js</strong>- Route endpoints are registered here.<br><strong>templates/views/layouts/default.hbs- </strong>This is the main template file.</p><h3>Creating a Model</h3><p><strong>1. Create a new file inside the models folder called ‘Announcement.js’.</strong></p><pre>var keystone = require(&#39;keystone&#39;);<br>var Types = keystone.Field.Types;</pre><pre>var Announcement = new keystone.List(&#39;Announcement&#39;);</pre><pre>Announcement.add({<br> title: { type: Types.Text, initial: true, required: true },<br> description: { type: Types.Textarea, initial: true, required: true  <br> },<br> date: { type: Types.Datetime, default: Date.now, initial: true,   <br> required: true }<br>});<br>Announcement.register();</pre><p>The <strong><em>initial </em></strong>option above causes the field to be displayed in the <strong>Create Form </strong>of the Admin UI. The <strong>required </strong>option validates that the field has a value before an item can be saved (<em>also passed to mongoose and enforced using a database index</em>).</p><p>The <strong><em>Types module(</em></strong><a href="http://keystonejs.com/docs/database/#fieldtypes">http://keystonejs.com/docs/database/#fieldtypes</a>) is used to define the data type of each property inside the Mongo DB document.</p><p><strong>2. Run the app again </strong>(node keystone.js).<strong><br></strong>Then browse to <a href="http://localhost:3000/keystone/">http://localhost:3000/keystone/</a>. You should see the Announcement Model added to the Admin UI.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ks2MfmKMRouRYpyNHz8Z1g.png" /></figure><p>In the next tutorial we will create a new route, view, and a template.</p><p><a href="https://medium.com/@shivendraodean/keystonejs-a-javascript-cms-part-3-routes-views-templates-cafb0d9c86db">KeystoneJS, A Javascript CMS (Part 3— Routes, Views &amp; Templates)</a></p><blockquote><strong>Need professional software development services ? <br>Visit </strong><a href="http://www.biztek.co.nz/"><strong>http://www.biztek.co.nz/</strong></a></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=437a6f3e23fe" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[KeystoneJS, A Javascript CMS (Part 1 — Getting Started)]]></title>
            <link>https://medium.com/@shivendraodean/keystonejs-a-javascript-cms-part-1-getting-started-ac0a754a5693?source=rss-8cbb96b096c2------2</link>
            <guid isPermaLink="false">https://medium.com/p/ac0a754a5693</guid>
            <category><![CDATA[keystonejs]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[cms]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[nodejs]]></category>
            <dc:creator><![CDATA[Shiv Odean]]></dc:creator>
            <pubDate>Mon, 29 May 2017 12:56:00 GMT</pubDate>
            <atom:updated>2018-02-21T08:33:58.583Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>Welcome to Part One of KeystoneJS, A Javascript CMS — An Introduction to the KeystoneJS Platform.</blockquote><blockquote><a href="https://medium.com/p/ac0a754a5693/edit">Part 1 — Getting Started</a><a href="https://medium.com/@shivendraodean/keystonejs-a-javascript-cms-part-2-code-structure-and-the-db-model-437a6f3e23fe"><br>Part 2 — Code Structure &amp; the DB Model</a><br><a href="https://medium.com/@shivendraodean/keystonejs-a-javascript-cms-part-3-routes-views-templates-cafb0d9c86db">Part 3 — Routes, View, and Templates</a><br><a href="https://medium.com/@shivendraodean/keystonejs-a-javascript-cms-part-4-accessing-data-c77806d4a8e4">Part 4 — Accessing Data</a></blockquote><p><strong><em>KeystoneJS is a platform that I have very quickly fallen in love with. It has rapidly grown to become one of the most popular Open-Source Javascript based CMS platforms around.</em></strong></p><h3><strong>What is a CMS ?</strong></h3><p>A Content Management System(CMS) is an application (typically web-based), which allows for the creation, modification, and control of digital content, usually in a multi-user environment. Examples of Digital Content can be Blog Posts, Images, Store Products, Events, etc.</p><p>The term CMS can be used in different contexts, but we will assume the most common variation, described above.</p><h3><strong>What is KeystoneJS ?</strong></h3><p>KeystoneJS is an Open Source, NodeJS based CMS and Web Application Platform. Keystone applications are database driven. More specifically, the database is MongoDB — a NO-SQL Document store database, and the Node framework underneath is ExpressJS.<br><a href="https://expressjs.com/">https://expressjs.com/</a><br><a href="https://www.mongodb.com/what-is-mongodb">https://www.mongodb.com/what-is-mongodb</a></p><h3><strong>Getting Started</strong></h3><p><strong>Firstly, please download and install these two dependencies — </strong><br>MongoDB (<a href="https://nodejs.org/download/">https://nodejs.org/download/</a>)<br>NodeJS (<a href="https://docs.mongodb.com/manual/installation/">https://docs.mongodb.com/manual/installation/</a>).</p><ol><li><strong>Open your favourite <em>terminal.</em></strong></li></ol><p>Check the installation of Node.js (You should see a version number e.g. ‘v6.9.5’). Run -</p><pre>node -v</pre><p>Check MongoDB installation (You should see ‘waiting for connections on port 27017’). Run -</p><pre>mongod</pre><p><strong>2. Create a project directory, and navigate to it.</strong></p><pre>mkdir myschool<br>cd myschool</pre><p><strong>3. Install Yeoman and Keystone Generator</strong></p><pre>npm install -g yo<br>npm install -g generator-keystone<br></pre><p><strong>4. Run Generator</strong> — Follow the generator instructions when prompted.<br>This will generate a KeystoneJS application template for us. We will use this as our starting point. We will be using handlebars (<a href="http://handlebarsjs.com/">http://handlebarsjs.com/</a>) as our template engine.</p><pre>yo keystone</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-tiUwt4vCg_TUZkG96PfXg.png" /></figure><p><strong>5. Run MongoDB</strong></p><pre>mongod</pre><p><strong>6. Run Application<br></strong><em>NOTE</em> — The following error can be ignored <em>for now</em> (if relevant)-<br><em>Error: Cannot find module ‘../build/Release/bson’</em></p><pre>node keystone</pre><p>Open a browser and enter ‘<a href="http://localhost:3000/">http://localhost:3000/</a>’. You should see the following.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4ZiLJHNbwrAyBfXIJnz8bA.png" /></figure><p>This is the default generated webpage. Click on ‘Sign in’, or browse to <a href="http://localhost:3000/keystone/">http://localhost:3000/keystone/</a>. Now log in using the credentials you entered during setup. <br><strong><em>Incase you forgot — </em></strong>Your credentials can be found in the source file at updates/0.0.1-admins.js.</p><p>You should now see the console below. This is the Content Management User Interface provided by the Keystone system. A ‘User’ model is added by default when running the generator. It uses the same user to provide admin access to the content management console.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fBuDJBbnLzvOefLSDuDYgQ.png" /></figure><p><strong>7. Create a new user</strong><br>Click ‘User’<br>Click ‘Create User’</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ggBN6nWOAhjJ6nL9jnQdfA.png" /></figure><h4>An aside on User Management</h4><p>During the app generation, when prompted for ‘What would you like to call the User Model?’, we answered <strong>User.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/762/1*vMSnOj0yiHrGz8NOI4eQrA.png" /></figure><p>In the background, Keystone created a new <em>User.js</em> file under the models directory. It sets the <strong><em>user model </em></strong>option inside our keystone.js file to <strong><em>User, </em></strong>telling it to use this model to find users. It also sets the <strong><em>auth </em></strong>option to true, telling it to use the built-in authentication views. Furthermore, it sets session to true. Here is an interesting read on sessions if this topic is new to you — <a href="http://machinesaredigging.com/2013/10/29/how-does-a-web-session-work/">http://machinesaredigging.com/2013/10/29/how-does-a-web-session-work/</a>.</p><p>As you can see, we get a lot of functionality right out of the box, with a quick and easy setup.</p><p>In the next tutorial we will discuss the project structure and write some code.</p><p><a href="https://medium.com/@shivendraodean/keystonejs-a-javascript-cms-part-2-code-structure-and-the-db-model-437a6f3e23fe">KeystoneJS, A Javascript CMS (Part 2— Code Structure and the DB Model)</a></p><blockquote>Need professional software development services ? <br>Visit <a href="http://www.biztek.co.nz/">http://www.biztek.co.nz/</a></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7ZGzbuv7Hune3gJEOiEhEg.jpeg" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ac0a754a5693" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>