-
Notifications
You must be signed in to change notification settings - Fork 0
Architecture
AaltoApps runs in Amazon EC2 cloud server instance running Ubuntu Linux 10.10. The server instance uses EBS data storage for the files. Usually an EC2 instance loses all it's data when shut down with no disk space. EBS storage costs a bit more but is required to secure the data (logs, application files, configurations) if the instance is shut down. The project is written using Ruby language and Ruby on Rails web framework. The Ubuntu instance is modified by installing a HTTP server (Nginx), Rails application server (Passenger), Ruby interpreter (ruby 1.9.2), Rails framework (Rails 3.0.1), a database server (PostgreSQL 8.4) and a set of required libraries. Database and application files are saved in a separate EBS file system for easier backup possibilities and to be able to run the database in a separate server in the future.
The login process and user data is handled by ASI service running outside the main application. AaltoApps uses REST (Representational State Transfer) calls to ASI service for authentication and saves only the ASI id in it's own database, so the software can link user to his/her projects, comments and ratings.
The overall high level architecture is described in the following image:
The server has a static IP address and it receives HTTP and HTTPS requests from the client. The server uses Nginx web server as a HTTP(S) server which translates the requests for Passenger application server. Passenger handles the Rails instances which can handle only one request at a time. If all the application stacks are busy Passenger launches more instances.
The Rails stack is almost a pure MVC (model-view-controller) application. The requests are captured by a router which breaks them for controllers. E.g. http://domain.com/products/delete/123 routes by default to a controller named "ProductsController" and to an action method named "Delete". The last number represents an id, so the call deletes a product with an id "123".
The controllers are backed up by models which are saved to a database storage. A model can be e.g. a user, a product or something more abstract like a platform or category. Ruby on Rails uses an ORM (object-relational mapper) called ActiveRecord and it transforms the database data and relations to objects to be used by the controllers and views. So the controllers gather and prepare the models as instance variables which are shown in the views.
The views are for representing the data. In AaltoApps the views are mainly HTML5 and CSS3, although they can be anything like JavaScript or HAML syntax. A view gets it's data variables from controllers and render it for the user.
So in summary, user gets an access to the controllers. Controllers get the data as models and display it in views.
The insides of an EC2 instance:
AaltoApps contains the following controllers:
Every other controller inherit the ApplicationController. Contains the getter and setter for current_user and authentication filters to be used in all controllers.
Lists, shows, creates, updates and deletes products added by users.
Actions:
- index (GET: http://{DOMAIN}/products?parameters) lists products.