Incremental Noir A literary experiment with API-First development https://github.com/greendemiurge/incremental_noir
The Concept • Art within boundaries fuels creativity • You are asked to contribute to a story, but just one small part • You can only see part of what came before • You have to incorporate one of three preselected words in your submission
Some Specifics • Each story lasts a specific, semi-random number of lines • Based on how many submissions there are, it suggests the part of the story arc you should submit (Exposition, Rising action, Turning point, Falling action, Conclusion)
Some Specifics (continued) • For the sake of continuity, the names and descriptions of key people, places and things stay visible at all times • In order to make the story “feel” like the Noir genre the pre-selected words are gathered from public domain Noir books • If you want to add a person, place or thing, there is a spot to submit it, but only so many are allowed at a time
Demo: Incremental Noir App
API-First Development • Application Programming interface • Desktop websites > Mobile First > API-First • Decouples presentation of data from the business logic that drives it, making it more adaptable • Begins by agreeing on a common language (interface) for the data provider and the data visualizer to use to talk to each other • Allows front and back end developers to work in parallel
RESTful APIs: Mandatory Technical Jargon • REST: Representative State Transfer • State: Data that changes based on user interaction • HATEOAS – Hypermedia as the Engine of Application State (means we are using familiar HTTP commands to communicate state between the front and the back) • Really this ultimately comes down to JSON in JSON out
Metaphor: A RESTaurant • Wait staff are the front end • The kitchen is the back end • Wait staff give tickets to the kitchen • Kitchen sends out food • We agree in advance on the tickets that can go in and the dishes that can come out. • Benefit: In the future we can add a drivethrough or delivery without changing the system
Demo: The Transactions POST /api/v1/post-prompt {
RESPONSE
{
threadId: 1,
threadId: 1,
threadLocator: "5qmbg",
newLine: "I'd only heard of Fawn Knutsen by
lines: [ { authorName: null,
her reputation as a compulsive gambler, so
line: "I knew right away I should never have picked up
I went to Shakey's to see if I could shake
that phone." }, { authorName: "Amber Gris",
down a clue.",
line: "Even over the line I could smell the whisky on the
newElement: {
man's breath, and I could tell he was a violent drunk.”},
type: "place",
{ authorName: "Raymond Hammet", line: "He said, \"You have until 1 1 A.M. tomorrow morning
name: "Shakey's",
to find Fawn Knutsen or I’ll see to it you are sent up the
description: "A seedy bar in the old part
river in her place!\"" }, { authorName: "Hank Scorpio",
of town, known as a hangout for bookies.”
line: "I'd only heard of Fawn Knutsen by her reputation as a
},
compulsive gambler, so I went to Shakey's to see if I could
authorName: "Hank Scorpio",
shake down a clue."}, ],
expires: 2018-06-01T17:20:54+00:00 }
completed: false }
Underlying technology • Back End – REST API written in Symfony 4 • Object-oriented PHP 7 • MySQL DB with Doctrine ORM
• Front End – React.js • • • •
Built using create react app Javascript in the ES6 standard Transpiled into browser-friendly ES5 by Babel Packaged and minified by Webpack
What is next for API-First Development? • GraphQL • A new query language that improves upon and provides an alternative to REST • Still JSON in JSON out, more opinionated about the data structure
• Websockets • Replaces the formal request/response pattern with full duplex communication • The server can now “push” information to the app