• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Architecting large Node.js applications
 

Architecting large Node.js applications

on

  • 11,316 views

Sergi Mansilla introduces one of the main components to hold Cloud9's architecture together: Architect.

Sergi Mansilla introduces one of the main components to hold Cloud9's architecture together: Architect.

Statistics

Views

Total Views
11,316
Views on SlideShare
11,259
Embed Views
57

Actions

Likes
18
Downloads
110
Comments
1

4 Embeds 57

http://localhost 40
https://twitter.com 14
http://nodeslide.herokuapp.com 2
http://pinterest.com 1

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel

11 of 1 previous next

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
  • Hi Sergi,

    I just came across your presentation and thought it is a very interesting approach to organize NodeJs applications.

    I am evaluating the Architect module to use on a project and have a question about how (if possible) to share the Architect plugins with applications that don't use Architect. I don't think it is possible without some work to clean the plugins to make it useable in other applications.

    Also, how would we package these plugins in npm to distribute them?

    Thanks a lot in advance for taking the time to answer my question Sergi.

    Quan
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Architecting large Node.js applications Architecting large Node.js applications Presentation Transcript

    • large Architecting node.js applicationsMonday, October 22, 12
    • @sergimansillaMonday, October 22, 12
    • P ro g ra m ☐ C l o u d9 ID E? ☐ Grow in g pai n s ☐ I n t ro du c i n g Arc hitec t ☐ Le ss on s le arn e dMonday, October 22, 12
    • Normal developersMonday, October 22, 12
    • JavaScript DeveloperMonday, October 22, 12
    • Cloud9 IDE - http://c9.ioMonday, October 22, 12
    • Real debuggingMonday, October 22, 12
    • (Smart!) Code completionMonday, October 22, 12
    • Static analysisMonday, October 22, 12
    • Free LinuxMonday, October 22, 12 VM
    • Bring your own machineMonday, October 22, 12
    • Real terminalMonday, October 22, 12
    • CollaborationMonday, October 22, 12
    • See each other type Debug together Productivity++Monday, October 22, 12
    • Create Deploy Run/Debug Share TestMonday, October 22, 12
    • P ro g ra m ☑ C l o u d9 ID E? ☐ Grow in g pai n s ☐ I n t ro du c i n g Arc hitec t ☐ Le ss on s le arn e dMonday, October 22, 12
    • 10,000s LOC of JavaScriptMonday, October 22, 12
    • dynamic, weakly typed languageMonday, October 22, 12
    • one singleMonday, October 22, 12 thread
    • Openshift Cloud9 datacenter Remote VM IDE server Remote VM Remote VMMonday, October 22, 12
    • Pure madnessMonday, October 22, 12
    • ModularizationMonday, October 22, 12
    • Black box codingMonday, October 22, 12
    • Monday, October 22, 12
    • Java/.NET import(s) Node.js requireMonday, October 22, 12
    • Great for re requi abstractingMonday, October 22, 12 away
    • re requi Not Great for application modularityMonday, October 22, 12
    • re requi Relies on FS duplicated modules maps to folder names Hard to configure moduleMonday, October 22, 12
    • Dependency error handling coding time compile time run time ! OM - BO KA - Server crash - Unhappy customers - Developer gets firedMonday, October 22, 12
    • How to fix it? Static dependency list Resolve at startup Named services No FS required Easy configuration Pass an objectMonday, October 22, 12
    • P ro g ra m ☑ C l o u d9 ID E? ☑ G row i n g pai n s ☐ I n t ro du c i n g Arc hitec t ☐ Le ss on s le arn e dMonday, October 22, 12
    • Architect github.com/c9/architectMonday, October 22, 12
    • Architect Everything is a plugin Plugins can consume plugins An application is just a set of pluginsMonday, October 22, 12
    • Dependency model require runtime Architect compile timeMonday, October 22, 12
    • Dependency error handling Architect coding time compile time run time - Happy customers - Fails before release - Developer keeps jobMonday, October 22, 12
    • Monday, October 22, 12
    • Declare entity ‘presenter’ with behavior Use ‘presenter’ to do a presentationMonday, October 22, 12
    • Dependency model Presenter PresentationMonday, October 22, 12
    • Express our model package.json Builds dependency tree without executing codeMonday, October 22, 12
    • Monday, October 22, 12
    • What’s next? Wrap in Architect plugin code Extract the code Make two pluginsMonday, October 22, 12
    • Function signature Call when doneMonday, October 22, 12
    • Architect plugin codeModule.exports Options - we’ll get to that Imports - everything you ‘consume’ Register - invoke when doneMonday, October 22, 12
    • Monday, October 22, 12
    • Monday, October 22, 12
    • Easy to test Mock dependenciesMonday, October 22, 12
    • Assert ‘dance’ is called 11 timesMonday, October 22, 12
    • No black magic Specify dependency model Feed architect a config file Call ‘createApp’Monday, October 22, 12
    • Monday, October 22, 12
    • Monday, October 22, 12
    • Configuration Per-plugin options No global options object Specify in config fileMonday, October 22, 12
    • Monday, October 22, 12
    • Monday, October 22, 12
    • Options Automatically passed in at startup Options are also dependencies Fail if options aren’t presentMonday, October 22, 12
    • Monday, October 22, 12
    • Monday, October 22, 12
    • Architect makes you think of your app as chunks of functionality rather than sets of classesMonday, October 22, 12
    • Think ‘chunks of functionality’ Implicit type constraints Keep implementation private Swap features instead of interfacesMonday, October 22, 12
    • How does Cloud9 use it? Open source version Local version (OS + sync) Hosted version Normal FTP SSHMonday, October 22, 12
    • Monday, October 22, 12
    • Swap feature per implementation On Open source: talk local filesystem On FTP: talk FTP library On SSH: talk via a SSH bridgeMonday, October 22, 12
    • Here is something your DI framework can’t doMonday, October 22, 12
    • Single node.js process IDE instance IDE instance (FTP) (SSH) Other code (dashboard etc.) IDE instance IDE instance (Normal) (Normal)Monday, October 22, 12
    • Monday, October 22, 12
    • Architect can do Multiple instances of same plugin Run independently But in the same processMonday, October 22, 12
    • Monday, October 22, 12
    • Monday, October 22, 12
    • HERE’S SOMETHING COOLMonday, October 22, 12
    • Centralized eventbus Loose coupling between plugins No hard dependencies! Can also do inter-context communicationMonday, October 22, 12
    • React on event Other plugin Event bus Emit event PluginMonday, October 22, 12
    • Monday, October 22, 12
    • Monday, October 22, 12
    • And now scale up Need something inter-server Swap it with i.e. Redis PubSub Plugins will never notice Modular awesomeness!Monday, October 22, 12
    • P ro g ra m ☑ C l o u d9 ID E? ☑ G row i n g pai n s ☑ I n t ro du c i n g Arc hitec t ☐ Le sson s learn edMonday, October 22, 12
    • Modularize in feature blocks Don’t over engineer Don’t create too small blocks They aren’t interfaces!Monday, October 22, 12
    • Use dependency injection Architect (JavaScript) StructureMap (.NET) Spring (Java)Monday, October 22, 12
    • Avoid context switching Less code! Less errors! Less boilerplate!Monday, October 22, 12
    • Loose coupling Use an event bus Smaller dependency graphMonday, October 22, 12
    • github.com/c9/architectMonday, October 22, 12
    • Happy coding!Monday, October 22, 12
    • http://c9.io Sergi Mansilla @sergimansilla github.com/sergiMonday, October 22, 12