How ccoenraets/cordova-tutorial works
Project Type & Purpose
• This is an Apache Cordova (hybrid) mobile-app tutorial that teaches how to build an Employee Directory SPA (Single Page Application) using HTML/CSS/JS.
• The project also includes a small Node.js/Express server exposing a REST endpoint (/employees) to serve JSON employee data.
• Multiple “solutions” folders (part05→part11, directory-backbone) show progressive enhancements; the “starter-www” folder is the base client.
File Structure & Architectural Patterns
Top-level directories:
• server/ – Node.js/Express REST API
– server.js (app entry), routes/employees.js
• starter-www/ – Base Cordova client (HTML, CSS, JS, libs)
• solutions/ – Versioned client implementations (parts 05–11, directory-backbone)
Patterns & layers in each client folder:
• index.html – single page shell
• lib/ – third-party libs (jQuery, Handlebars, FastClick, Pageslider, Backbone in some solutions)
• js/ – application code:
– app.js – bootstrap & Cordova “deviceready” handler
– router.js – in-app navigation (pushState/pageslider)
– services/ – data-access adapters (json, localstorage, memory, websql)
– views/ & models.js or EmployeeView.js, EmployeeListView.js – UI MVC/MV* components
• Service abstraction layer lets you switch storage backends.
a. Main Components
1. Cordova Container / WebView (hosted on device)
2. UI Layer
• Templates & Views (Handlebars)
• Router & Navigation (pageslider.js, custom router)
3. Service Layer (data-access)
• JSONService → HTTP calls to Server API
• LocalStorageService → browser localStorage
• WebSQLService → HTML5 WebSQL DB
• MemoryService → in‐memory cache
4. Server (Node.js/Express)
• /employees API endpoint
5. Third-party Libraries
• jQuery, FastClick, Pageslider, Handlebars, Ratchet/Topcoat, Backbone (in directory-backbone solution)
b. Relationships & Data Flows
• User taps in UI → Router updates View
• View calls Service Layer → selects appropriate EmployeeService implementation
• JSONService sends AJAX → Node.js server → responds with JSON
• LocalStorage/WebSQL services read/write on device
• Data returned to View → Handlebars templates → rendered UI
c. Architectural Patterns & Principles
• Single-Page Architecture (SPA) – no page reloads
• MV* structure (in Backbone solutions) or light MVC with views/models
• Service‐oriented abstraction for pluggable storage backends
• Cordova plugin/event model (deviceready event)
d. Key Technologies & Frameworks
• Apache Cordova (WebView container)
• Node.js + Express (server)
• jQuery, Handlebars, FastClick, Pageslider, Ratchet/Topcoat, Backbone.js
• HTML5 WebSQL, localStorage
Capturing Essential Architectural Elements
• Be sure to include the Cordova WebView boundary.
• Service abstraction with pluggable backends.
• Cordova’s deviceready event bootstrapping the app.
• REST API boundary and the ability to swap to local/offline storage.
• Don’t overload with every file; group by logical layers (assets, libs, js modules).