Design - adrianvit/dcda GitHub Wiki

Specifications and use cases

The system models an online store with emphasis on the routing and tracking of packages.

There are multiple stores, arranged in a p2p network, with one supernode (central server).

The central server would add/remove other nodes, and also place them in the network (selecting the list of neighbours). Also, this server would handle customer registration, to ensure uniqueness across the network.

The main use case is described below: A client wants to order something from the store. If the product is found on the local server, the delivery process begins. If it’s not found, the local server starts a search, asking each of his neighbours if it has that product, and so on, until it is found, or all nodes have been queried. If a product is found, the owning server determines the shortest route to the origin server, and starts the delivery process. During the delivery, each intermediate server could notify the client of the current package status.

The mobile application allows the client to:

  • Get updates on the package (using google cloud messaging)
  • Order products and manage his account.
  • Visualize the package on the map (using google maps api).
  • Ability to rate the store.

The web interface : -Administration (node management (add/remove), add products to certain nodes)

Use cases are described below:

  1. Login - the system provides a login facility to the user

  2. Register - a user must be able to create an account in the system

  3. Product Search - the user submits a query to one of the local servers; If this server cannot complete the query, it in turn submits it to the neighbour servers.

  4. Place an order - after finding a product, the user can place an order

  5. Account administration - the user is able to edit his profile on the system

  6. Technology stack

JavaScript is a lightweight, interpreted, object-oriented language with first-class functions, most known as the scripting language for Web pages, but also used in many non-browser environments. JavaScript uses functions as first class, which all also considered objects and being able to be used like objects. They have methods and properties and the interactions between them is similar to Java syntax. For classes JavaScript uses prototypes.

PostgreSQL is a powerful open source database which fully supports the ACID standard and is compatible with all of the most popular operating systems. Even if it’s free, PostgreSQL provides all the functionalities expected from a professional database. Moreover, the developer has access at a community built around this tool which will provide help when needed. PostgreSQL is fully compatible with SQL and offers a high performance and data security.

Glassfish is one of the most popular server used for JEE applications. Designed with a modular kernel, Glassfish has an OSGi architecture and works with Apache Felix. The OSGi standard allows components to be installed, uninstalled, started and stopped without needing a restart of the server. The controlling of the server is quite simple and allows controlling them from distance. This can be done from the admin console or from the command line.

Android is a platform used for developing mobile applications which gathers an operation system, a middleware and also some main features. The main components offered by Android for developing applications are services and activities. The current activity of an application can be defined as being represented by the current application interface viewed by the user. Thus instead of moving from one “window” to another, the user is actually moving from one activity to another. When it comes to services, they are not related at all to the interface of the application. They run in the back and can be alive long after the application is not running anymore.

JAX-RS is the Java Api used for REST web services. Because JAX-RS is part of Java EE6, no special configurations are needed for using it. Jax-RS gives a series of annotations which will be added in front of Java objects, thus mapping a resource class (a POJO) as a web resource. These annotations are used for links made to URI or HTTP methods, for injecting parameters from HTTP request.

EJBs are server-side components that encapsulate the business logic of an application. In other words EJBs are java objects(POJO) which benefit from some annotations and will be compiled within a container. These components were added with the purpose of improving the performance, lowering the complexity and aiming to reusability. The brain beside EJBs are the containers. They are the ones responsible for all the services running. There are 3 EJB categories: session, message and entity bean, but the last one is deprecated. Session beans can be stateful, stateless or singleton and they all support asynchronous execution.

JPA is a reinterpretation of JDBC which offers the developer the liberty of decoupling its project from the programming language used by the database. Now it can be used a persistence model in which persisted objects are used in the same way like any other object. A persisted object is called an entity whose entire state will be stored in a table which is part of a relational database. An entity is stored in a single row from a table and can have relationships with other entities.

JAXB does the mapping of Java objects to XML. Depending on the implementation used some forms of JSON are accepted. Using JAXB objects, XML files can be marshaled and unmarshaled. The special annotation used by JAXB is “@XmlRootElement”. Also if some fields or methods are not needed to be marshaled or just renamed, annotations can be used here too.

  1. High level system overview The central server is used for user management. It handles registration and login. It also manages the local servers, adding or removing them from the network. It’s database would contain customer data and information about the other servers. The web interface is for administration purposes. It allows the system administrator to manage the local nodes. Estimated complexity is medium-high.

A local server holds information about certain products, and allows the customer to order said products. It joins the network by way of the central server. This in turn gives the local server a list of neighbours. The local server is the one that communicates with the android application. All the local servers communicate with the central one (links in the diagram were omitted for illustration purposes), however they only communicate with other specific local servers (not all of them). Estimated complexity is high.

The android application allows users to log in to the system, place orders and manage their account. It also keeps the users updated on their package status. Estimated complexity is medium.