Connect your app to your
backend
Presented by Nacef LABIDI
March 2014
Connect your app to your backend
Nacef LABIDI
Who I am ?
System Level Developer @ STMicroelectronics
Co-founder and Technical Manager @ Oceanys
Project Manager @ Evatys
Technical Consultant @ Hewlett-Packard
IT Manager @ US Peace Corps
Global Helpdesk Manager @ Vistaprint
Who I really am ? ;)
Computer engineer, geek and music addict.
Open Source enthusiast, supporter and
contributor.
Android apps developer (when I find some time)
Python fan and supporter.
Speak many programming languages.
Audience
Beginners in Android development
People wanting to build mobile apps around
dynamic content
Building multi-platform mobile apps
Storing your data inside vs. outside of
your app
Pros
Decoupling between the app and the data
Keeping the logic on the server side
Makes your apps lighter
Makes your logic consistent and reusable
Evolution of your service relies more on the
data than the app itself.
Publish your data to multiple medias : Website,
all kind of mobile devices, share your data with
affiliates
Storing your data inside vs. outside of
your app
Cons
Need to be connected to access the data
This can be improved by caching some of the
data locally
Delays in treatment depending on the volume
of data and the quality of the connection
May expose your data to some security risks
Again this can be addressed
How would I proceed ?
If you dont have a backend, start by building
one
This will help you define the structure of the
data that you want to expose in your app
Designing the data will also help you design the
layout of your app
Build a webservice API that will be used to
access the data
Secure your webservice
Building your backend
Choose the right tools : modern frameworks
Define your data structures
Use migrations to evolve your data structures
without messing with your data
Use RESTful capabilities of your framework to
publish your data to your app
Choose the exchange format that suits you
most (XML, JSON)
Use security capabilities to protect your data
Secure your backend
Different security methods :
HTTP Basic Authentication
Login and password sent with the HTTP request
ApiKey Authentication
Passing an ApiKey generated on the server side
in each HTTP request
OAuth Authentication
Through a third party authentication service
(Google, Facebook, Yahoo, OpenID )
Create your custom authentication system
Public/Private RSA keys
My personal choices
Python language
http://www.python.org
Django framework https://
www.djangoproject.com
Provides Model classes
Supports many DB backends (Relational &
NoSQL)
Migrations: through South module http://
south.aeracode.org
RESTful API: through Tastypie module http://
tastypieapi.org
Build your app
Use Apache HTTP Client classes
Use Google Gson to map API responses to
your local objects
https://code.google.com/p/google-gson
Use AsyncTask to keep your app responsive
while retrieving your data from the server
Goodies : You should try RoboGuice to have a
nicely architected app
https://github.com/roboguice/roboguice
Retrospective
Tunibus : An android app allowing users to find
their way through the Tunis public
transportation (Bus, Metro, Train )
Neo4j Graph database representing stations
and edges representing transportation lines
connecting the stations. http://www.neo4j.org
RESTful webservice that returns the possible
paths between two points
Android app that connects through the API to
the Graph DB
Crowdsourcing web app to enhance the data
quality
Retrospective
RESTful
API
Thank you !
Questions ?