Portreto is a distributed image-oriented web application which is implemented in multitier architecture.
One of the most important goals of this project is to build a distributed application which does not have a single point of failure. In order to do this, we had to design stateless microservices runing in docker containers. Μicroservices are written in python 3.7 using django framework. Moreover, we use docker swarm to replicate and load balance most of them.
The actual distinctly microservices we used are:
- Web service (presentation layer)
- Authentication service (provides valid authentication tokens in order to work stateless)
- Application service (logic tier)
- Storage service (holds users’ photos)
- Database (users’ information exist here. E.g. usernames, emails, etc..)
- Zookeeper
Portreto's web interface is built using bootstap framework. Web service's job is to receive requests from clients, communicate using RESTful APIs with authentication and/or application services and finally render responses to send back to clients. As we already mentioned above, web service is a collection of replicated containers (we have used three of them). Last but not least, web service creates and retrieves cookies in client-side, where we store authentication tokens.
Authentication service communicates with web service in order to provide authentication tokens to clients. We use JWT standard to have a secure and trust communication between clients and portreto. Authentication service is also a collection of three containers.
Application service is the brain of portreto. Each client request is computed here. Web service sends requests to application service using RESTful API based on clients input. Then, the services job is to receive these requests, check the provided authentication token that exists on each request header for user identification and authorization, communicate with database to retrieve needed information, communicate with zookeeper to find out available storage services for requested photos and provide response information back to web. Application service is also a collection of three containers.
Storage service is one of the most important parts of this application. Each user has photos, each photo is stored in two different storage services when it is uploaded by the user. Clients could access photos directly using url that application service has provide to them. We use six different containers for storage service.
A modified version of django-statsy is used to view get/post/delete metrics on the storage services
A distributed replicaset of MongoDB has been used in this project in order store users informations.
This is login's sequence diagram
The system has been succesfully tested in docker-swarm mode for correct replication of microservices and lack of a single-point failiure