SlideShare une entreprise Scribd logo
1  sur  7
Télécharger pour lire hors ligne
CMPE 275
Project 2 Report
RESTful social collaboration through Pinterest re-enactment
Team:
Bhushan Deo (009269403)
Deven Pawar (009275994)
Dhruv Gogna (005067284)
Gaurav Bhardwaj (009297431)
Vinay Bhore (009290931)
Introduction
The main goal of Project 2 is to explore the design and challenges in developing RESTful web services for
a social media service such as Pinterest. Sharing content is an important pattern found in all social media
services. Providing robust and well documented web services is very important in such products as there
are several external clients which use them to access and manipulate stored user data. In this report, we
provide a detailed explanation of our team’s design and implementation.
High Level Architecture
The team’s configuration consists of the following components:
1. Web Services:
We expose our functionality to the client using RESTful web services written in Python using the
Bottle micro-framework.
2. Database:
CouchDB NoSQL database is used to persist user data. It provides data storage as JSON
documents and thus naturally maps to the requirements. Also, when client hits our web service
and some data is changed, we can verify changes in the database through the web interface
(Futon), that comes with CouchDB.
3. couchdb-python library:
This library provides interface to interact with CouchDB from python code. In our experience,
this was a very well designed library with advanced features like high-level couchDB document
to python object mapping, intuitive interfaces and good documentation.
4. Client:
For testing, we are using curl to hit our web services and see the response. Curl provides many
advanced options to make testing via HTTP requests easy.
The following sections explain the functionalities implemented and the web service and database
component in detail. These include comments about what we learnt while working on each component.
Functionalities
This project also required cross team interaction to come up with a stable specification for the web
services. As per the specification agreed to by the class, following functionalities were implemented by
our team.
Here, we observed how the traditional Create, Read, Update and Delete operations in databases, map
exactly to HTTP methods POST, GET, PUT and DELETE respectively.
Functionality Endpoint (fields in angular brackets are generated on the
server)
CRUD? HTTP
Met-
hod
Request
Parameters (all
are string type
unless specified)
Sign up http://localhost:8080/users/signUp Create POST firstName
lastName
emailId
password
Login http://localhost:8080/users/login/ Create POST emailId
password
Create a
board
http://localhost:8080/users/<userId>/boards/ Create POST boardName
boardDesc
category
isPrivate(Boolean)
Get all
boards
http://localhost:8080/users/<userId>/boards/ Read GET None
Get details of
a single
board
http://localhost:8080/users/<userId>/boards/<boardId>/ Read GET None
Update
Board
http://localhost:8080/users/<userId>/boards/<boardId>/ Update PUT boardName
boardDesc
category
isPrivate(Boolean)
Delete Board http://localhost:8080/users/<userId>/boards/<boardId>/ Delete DELETE None
Create Pin http://localhost:8080/users/<userId>/boards/<boardId>/p
ins/
Create POST pinName
image
description
Get a single
pin from a
board
http://localhost:8080/users/<userId>/boards/<boardId>/p
ins/<pinId>/
Read GET None
Get all pins
from a board
http://localhost:8080/users/<userId>/boards/<boardId>/p
ins/
Read GET None
Update a pin http://localhost:8080/users/<userId>/boards/<boardId>/p
ins/<pinId>/
Update PUT pinName
image
description
Delete a pin http://localhost:8080/users/<userId>/boards/<boardId>/p
ins/<pinId>/
Delete DELETE None
Add a
comment to
a pin
http://localhost:8080/users/<userId>/boards/<boardId>/p
ins/<pinId>/comment/
Create POST description
View
comments
on a pin
http://localhost:8080/users/<userId>/boards/<boardId>/p
ins/<pinId>/comment/
Read GET None
The responses were returned in JSON format and contained relevant data and endpoint information for
subsequent operations as agreed to by the class.
Web Services
Why Web Services fit in this project?
Essentially, web services help de-couple the client and the server implementations. User performs
various CRUD operations on an external system by sending HTTP requests through the client. The web
service layer, intercepts these requests on the server, performs operations on the database and sends
back appropriate response to the client. This fits well with the sharing and collaboration required by
social media products. From real world examples such as Facebook, Twitter and Pinterest, it can be seen
that a robust and well documented RESTful API is a vital contributor to these products going viral.
Bottle:
Web services were written in Python using the Bottle micro-framework. We found Bottle to be very
intuitive for creating our web services. The framework is very lightweight and in order to use it, it only
requires us to include one bottle.py file in the project directory.
Server:
Bottle runs by default on a single threaded WSGI server, but has adapters to various multi-threaded
servers such as paste and Cherrypy which give better performance for applications that need to handle
large number of concurrent requests. For testing this project, we have used the default server.
Mapping requests to appropriate methods:
Various endpoints as mentioned in the functionalities section, map easily to corresponding methods
which process the requests at those endpoint, simply by placing a @route decorator above that method.
Retrieving data from request:
In REST, the URL path determines the data that will be accessed or manipulated and the HTTP method
determines the operation that will be performed on that data.
- To get information about data that will be accessed, we use wildcards in the URL:
@route(‘http://localhost:8080/users/<userId>/boards/<boardId>/’,method=’GET’)
def getBoard(userId, boardId):
# got userId and boardId from the URL, now perform GET(read) on database
- To retrieve data from the HTTP request, bottle provides convenient methods in the request object:
@route(‘http://localhost:8080/users/<userId>/boards/<boardId>/’,method=’PUT’)
def updateBoard(userId, boardId):
# got userId and boardId from the URL, now perform PUT(update)on database
# with the fields sent in the request by the client
boardName = request.forms.get('boardName')
boardDesc = request.forms.get('boardDesc')
Returning JSON response:
JSON was the decided as the format in which response will be sent back to the client. Even in this case,
Bottle made it easy to return back response with “application/json” content type. We simply had to
return a python dictionary object. Bottle returns the response in JSON and the appropriate field is set in
the HTTP header.
@route(‘http://localhost:8080/users/<userId>/boards/<boardId>/’,method=’PUT’)
def updateBoard(userId, boardId):
# perform appropriate operations
return dict(status='OK', message='sample message')
If other response types such as html or xml are expected by the client, we are aware that we would have
to check for the content types which the client accepts from the HTTP request header and accordingly
format the response before sending it back (content negotiation).
Handling trailing ‘/’ slash:
If some clients put a trailing slash at the end of the endpoint URL, then that is treated as a separate
route by Bottle and might not map to the appropriate method in our web service code. Given that we
would be testing across teams, this was highly probable. To handle this, Bottle documentation suggests
to simply map two routes to the same method, one with a trailing slash and one without a slash.
@route(‘http://localhost:8080/users/<userId>/boards/<boardId>/’,method=’PUT’)
#No trailing slash
@route(‘http://localhost:8080/users/<userId>/boards/<boardId>’,method=’PUT’)
def updateBoard(userId, boardId):
# perform appropriate operations
Database
In REST web services, we can think of the URL as a path that is traversed to get to the data that is to be
accessed or manipulated. Further, the HTTP method that is specified in the HTTP request gives us the
operation (create, read, update or delete) that is to be performed on the data. Accordingly the actions
that we take in code depend on the combination of the following factors:
1. Response format accepted by the client (json, xml, html, image, etc..)
2. Data that is to be accessed (URL traversal)
3. What kind of operation on the data (HTTP method type)
Thus, for every endpoint there are several combinations that need to be handled so that we process the
user request appropriately and so that we return desired response back to the user. In this context, it is
clear that we have to organize our data based on the endpoints that we expose to the user.
We observed that this is a notable difference compared to Project 1, where there was only one endpoint
for the client, and the server queue delegated the message to the appropriate resource to handle. In
Project 2, there are several endpoints for the client and each endpoint maps to one method on the server
side.
The flat schema that we have used to store data in CouchDB is as follows. The “_id” is the userId that is
generated server side when the user signs up. This is passed around in each URL and is used to identify
user in each subsequent request.
{
"_id": {
"firstName": "",
"lastName": "",
"emailId": "",
"password": "",
"isLoggedIn": false,
"boards": [
{
"boardId": "",
"boardName": "",
"boardDesc": "",
"category": "",
"isPrivate": "",
"pins": [
{
"pinId": "",
"pinName": "",
"image": "",
"description": "",
"comments": []
}
]
}
]
}
}
Drawback:
The limitation of this schema is that for any request, we get the entire complex document associated
with a userId from the database. Then, in case of long URLs we have to employ multiple nested loops to
get to the data that we require. For example, updating information about a pin needs three nested
loops through the document that is returned. This is shown in the figure above. This would be
problematic if a user had thousands of boards and pins.
A solution to this would be to create separate tables (“databases” in CouchDB) for each step in the
endpoint URL tree, i.e. separate tables for user, board and comments, each record containing reference
to the userId. However, the tradeoff here is that this would require more queries to the database per
user request.
Note on Aerospike:
Initially we decided on using Aerospike as our database. However, its Python client seems to be under
development and there was no support for list and map data structures. Further, there was no query
support in the Python client, only full table scan was supported. Hence we decided to go with CouchDB.
Nonetheless, it was interesting to understand Aerospike’s architecture and concepts such as location
awareness of client, peer relationship among nodes, use of binary wire protocol for communication and
cross data center replication.
Conclusion
For our team, following are the major learnings from this project:
1. Programming in Python
2. RESTful web services
3. Database design for RESTful web services
4. Micro-frameworks
5. Comparison of technologies used in Project 1 and 2
6. CouchDB and Aerospike
7. Collaboration in Small and Large Software Development Teams

Contenu connexe

Tendances

A presentation on WCF & REST
A presentation on WCF & RESTA presentation on WCF & REST
A presentation on WCF & RESTSanthu Rao
 
Ch06 edge transport
Ch06 edge transportCh06 edge transport
Ch06 edge transportShane Flooks
 
Integration and Batch Processing on Cloud Foundry
Integration and Batch Processing on Cloud FoundryIntegration and Batch Processing on Cloud Foundry
Integration and Batch Processing on Cloud FoundryJoshua Long
 
Ch05 high availability
Ch05 high availabilityCh05 high availability
Ch05 high availabilityShane Flooks
 
Splitters in mule
Splitters in muleSplitters in mule
Splitters in mulevasanthii9
 
Networking in java, Advanced programming
Networking in java, Advanced programmingNetworking in java, Advanced programming
Networking in java, Advanced programmingGera Paulos
 
Basic Networking in Java
Basic Networking in JavaBasic Networking in Java
Basic Networking in Javasuraj pandey
 
Azure Service Bus Performance Checklist
Azure Service Bus Performance ChecklistAzure Service Bus Performance Checklist
Azure Service Bus Performance ChecklistSalim M Bhonhariya
 
Mule splitters
Mule splittersMule splitters
Mule splittersGandham38
 
Đề thi lý thuyết DWSJ Aptech
Đề thi lý thuyết DWSJ AptechĐề thi lý thuyết DWSJ Aptech
Đề thi lý thuyết DWSJ AptechNhân Châu KP
 
Syer Monitoring Integration And Batch
Syer Monitoring Integration And BatchSyer Monitoring Integration And Batch
Syer Monitoring Integration And BatchDave Syer
 
3.java database connectivity
3.java database connectivity3.java database connectivity
3.java database connectivityweb360
 

Tendances (19)

A presentation on WCF & REST
A presentation on WCF & RESTA presentation on WCF & REST
A presentation on WCF & REST
 
Ch06 edge transport
Ch06 edge transportCh06 edge transport
Ch06 edge transport
 
Integration and Batch Processing on Cloud Foundry
Integration and Batch Processing on Cloud FoundryIntegration and Batch Processing on Cloud Foundry
Integration and Batch Processing on Cloud Foundry
 
Ch05 high availability
Ch05 high availabilityCh05 high availability
Ch05 high availability
 
Mule splitters
Mule splittersMule splitters
Mule splitters
 
Splitters in mule
Splitters in muleSplitters in mule
Splitters in mule
 
Networking in java, Advanced programming
Networking in java, Advanced programmingNetworking in java, Advanced programming
Networking in java, Advanced programming
 
PyNet
PyNetPyNet
PyNet
 
Remoting and serialization
Remoting and serializationRemoting and serialization
Remoting and serialization
 
Servlet basics
Servlet basicsServlet basics
Servlet basics
 
Concurrency and parallel in .net
Concurrency and parallel in .netConcurrency and parallel in .net
Concurrency and parallel in .net
 
Basic Networking in Java
Basic Networking in JavaBasic Networking in Java
Basic Networking in Java
 
Websocket
WebsocketWebsocket
Websocket
 
Azure Service Bus Performance Checklist
Azure Service Bus Performance ChecklistAzure Service Bus Performance Checklist
Azure Service Bus Performance Checklist
 
shieh06a
shieh06ashieh06a
shieh06a
 
Mule splitters
Mule splittersMule splitters
Mule splitters
 
Đề thi lý thuyết DWSJ Aptech
Đề thi lý thuyết DWSJ AptechĐề thi lý thuyết DWSJ Aptech
Đề thi lý thuyết DWSJ Aptech
 
Syer Monitoring Integration And Batch
Syer Monitoring Integration And BatchSyer Monitoring Integration And Batch
Syer Monitoring Integration And Batch
 
3.java database connectivity
3.java database connectivity3.java database connectivity
3.java database connectivity
 

Similaire à CMPE 275 Project 2 Report: RESTful social collaboration

E-Services TP2 ISI by Ettaieb Abdessattar
E-Services TP2 ISI by Ettaieb AbdessattarE-Services TP2 ISI by Ettaieb Abdessattar
E-Services TP2 ISI by Ettaieb AbdessattarAbdessattar Ettaieb
 
Bt0083 server side programing
Bt0083 server side programing Bt0083 server side programing
Bt0083 server side programing Techglyphs
 
Web Technologies Notes - TutorialsDuniya.pdf
Web Technologies Notes - TutorialsDuniya.pdfWeb Technologies Notes - TutorialsDuniya.pdf
Web Technologies Notes - TutorialsDuniya.pdfRaghunathan52
 
Web Technologies Notes - TutorialsDuniya.pdf
Web Technologies Notes - TutorialsDuniya.pdfWeb Technologies Notes - TutorialsDuniya.pdf
Web Technologies Notes - TutorialsDuniya.pdfRaghunathan52
 
IRJET- Rest API for E-Commerce Site
IRJET- Rest API for E-Commerce SiteIRJET- Rest API for E-Commerce Site
IRJET- Rest API for E-Commerce SiteIRJET Journal
 
session and cookies.ppt
session and cookies.pptsession and cookies.ppt
session and cookies.pptJayaprasanna4
 
Web2 0 Incredibles
Web2 0 IncrediblesWeb2 0 Incredibles
Web2 0 Incrediblesanjeshdubey
 
Updated SAKET MRINAL Resume
Updated SAKET MRINAL ResumeUpdated SAKET MRINAL Resume
Updated SAKET MRINAL ResumeSaket Mrinal
 
53 hui homework2
53 hui homework253 hui homework2
53 hui homework2huis89
 
rest-api-basics.pptx
rest-api-basics.pptxrest-api-basics.pptx
rest-api-basics.pptxFikiRieza2
 
21. Application Development and Administration in DBMS
21. Application Development and Administration in DBMS21. Application Development and Administration in DBMS
21. Application Development and Administration in DBMSkoolkampus
 
DN 2017 | Big Data / Microservice Versioning | Thomas Pötter | Compris Techno...
DN 2017 | Big Data / Microservice Versioning | Thomas Pötter | Compris Techno...DN 2017 | Big Data / Microservice Versioning | Thomas Pötter | Compris Techno...
DN 2017 | Big Data / Microservice Versioning | Thomas Pötter | Compris Techno...Dataconomy Media
 
ASP.NET Mvc 4 web api
ASP.NET Mvc 4 web apiASP.NET Mvc 4 web api
ASP.NET Mvc 4 web apiTiago Knoch
 
Introduction to the World Wide Web
Introduction to the World Wide WebIntroduction to the World Wide Web
Introduction to the World Wide WebAbdalla Mahmoud
 

Similaire à CMPE 275 Project 2 Report: RESTful social collaboration (20)

Switch to Backend 2023
Switch to Backend 2023Switch to Backend 2023
Switch to Backend 2023
 
Restful web services
Restful web servicesRestful web services
Restful web services
 
E-Services TP2 ISI by Ettaieb Abdessattar
E-Services TP2 ISI by Ettaieb AbdessattarE-Services TP2 ISI by Ettaieb Abdessattar
E-Services TP2 ISI by Ettaieb Abdessattar
 
Bt0083 server side programing
Bt0083 server side programing Bt0083 server side programing
Bt0083 server side programing
 
Web Technologies Notes - TutorialsDuniya.pdf
Web Technologies Notes - TutorialsDuniya.pdfWeb Technologies Notes - TutorialsDuniya.pdf
Web Technologies Notes - TutorialsDuniya.pdf
 
Web Technologies Notes - TutorialsDuniya.pdf
Web Technologies Notes - TutorialsDuniya.pdfWeb Technologies Notes - TutorialsDuniya.pdf
Web Technologies Notes - TutorialsDuniya.pdf
 
IRJET- Rest API for E-Commerce Site
IRJET- Rest API for E-Commerce SiteIRJET- Rest API for E-Commerce Site
IRJET- Rest API for E-Commerce Site
 
Http and REST APIs.
Http and REST APIs.Http and REST APIs.
Http and REST APIs.
 
session and cookies.ppt
session and cookies.pptsession and cookies.ppt
session and cookies.ppt
 
Web2 0 Incredibles
Web2 0 IncrediblesWeb2 0 Incredibles
Web2 0 Incredibles
 
Updated SAKET MRINAL Resume
Updated SAKET MRINAL ResumeUpdated SAKET MRINAL Resume
Updated SAKET MRINAL Resume
 
53 hui homework2
53 hui homework253 hui homework2
53 hui homework2
 
rest-api-basics.pptx
rest-api-basics.pptxrest-api-basics.pptx
rest-api-basics.pptx
 
21. Application Development and Administration in DBMS
21. Application Development and Administration in DBMS21. Application Development and Administration in DBMS
21. Application Development and Administration in DBMS
 
Introduction To REST
Introduction To RESTIntroduction To REST
Introduction To REST
 
DN 2017 | Big Data / Microservice Versioning | Thomas Pötter | Compris Techno...
DN 2017 | Big Data / Microservice Versioning | Thomas Pötter | Compris Techno...DN 2017 | Big Data / Microservice Versioning | Thomas Pötter | Compris Techno...
DN 2017 | Big Data / Microservice Versioning | Thomas Pötter | Compris Techno...
 
ASP.NET Mvc 4 web api
ASP.NET Mvc 4 web apiASP.NET Mvc 4 web api
ASP.NET Mvc 4 web api
 
Introduction to the World Wide Web
Introduction to the World Wide WebIntroduction to the World Wide Web
Introduction to the World Wide Web
 
WebApp #3 : API
WebApp #3 : APIWebApp #3 : API
WebApp #3 : API
 
Unit 02: Web Technologies (2/2)
Unit 02: Web Technologies (2/2)Unit 02: Web Technologies (2/2)
Unit 02: Web Technologies (2/2)
 

Dernier

An introduction to Semiconductor and its types.pptx
An introduction to Semiconductor and its types.pptxAn introduction to Semiconductor and its types.pptx
An introduction to Semiconductor and its types.pptxPurva Nikam
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxbritheesh05
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024hassan khalil
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AIabhishek36461
 
Heart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxHeart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxPoojaBan
 
Introduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxIntroduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxk795866
 
Arduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptArduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptSAURABHKUMAR892774
 
Concrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptxConcrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptxKartikeyaDwivedi3
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...VICTOR MAESTRE RAMIREZ
 
Introduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECHIntroduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECHC Sai Kiran
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girlsssuser7cb4ff
 
Correctly Loading Incremental Data at Scale
Correctly Loading Incremental Data at ScaleCorrectly Loading Incremental Data at Scale
Correctly Loading Incremental Data at ScaleAlluxio, Inc.
 
Comparative Analysis of Text Summarization Techniques
Comparative Analysis of Text Summarization TechniquesComparative Analysis of Text Summarization Techniques
Comparative Analysis of Text Summarization Techniquesugginaramesh
 
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsync
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsyncWhy does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsync
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsyncssuser2ae721
 
Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.eptoze12
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxJoão Esperancinha
 
computer application and construction management
computer application and construction managementcomputer application and construction management
computer application and construction managementMariconPadriquez1
 

Dernier (20)

An introduction to Semiconductor and its types.pptx
An introduction to Semiconductor and its types.pptxAn introduction to Semiconductor and its types.pptx
An introduction to Semiconductor and its types.pptx
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptx
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AI
 
Heart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxHeart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptx
 
Introduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxIntroduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptx
 
Arduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptArduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.ppt
 
Concrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptxConcrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptx
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...
 
Introduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECHIntroduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECH
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girls
 
Correctly Loading Incremental Data at Scale
Correctly Loading Incremental Data at ScaleCorrectly Loading Incremental Data at Scale
Correctly Loading Incremental Data at Scale
 
Comparative Analysis of Text Summarization Techniques
Comparative Analysis of Text Summarization TechniquesComparative Analysis of Text Summarization Techniques
Comparative Analysis of Text Summarization Techniques
 
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Serviceyoung call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
 
POWER SYSTEMS-1 Complete notes examples
POWER SYSTEMS-1 Complete notes  examplesPOWER SYSTEMS-1 Complete notes  examples
POWER SYSTEMS-1 Complete notes examples
 
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsync
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsyncWhy does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsync
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsync
 
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
 
Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
 
computer application and construction management
computer application and construction managementcomputer application and construction management
computer application and construction management
 

CMPE 275 Project 2 Report: RESTful social collaboration

  • 1. CMPE 275 Project 2 Report RESTful social collaboration through Pinterest re-enactment Team: Bhushan Deo (009269403) Deven Pawar (009275994) Dhruv Gogna (005067284) Gaurav Bhardwaj (009297431) Vinay Bhore (009290931)
  • 2. Introduction The main goal of Project 2 is to explore the design and challenges in developing RESTful web services for a social media service such as Pinterest. Sharing content is an important pattern found in all social media services. Providing robust and well documented web services is very important in such products as there are several external clients which use them to access and manipulate stored user data. In this report, we provide a detailed explanation of our team’s design and implementation. High Level Architecture The team’s configuration consists of the following components: 1. Web Services: We expose our functionality to the client using RESTful web services written in Python using the Bottle micro-framework. 2. Database: CouchDB NoSQL database is used to persist user data. It provides data storage as JSON documents and thus naturally maps to the requirements. Also, when client hits our web service and some data is changed, we can verify changes in the database through the web interface (Futon), that comes with CouchDB. 3. couchdb-python library: This library provides interface to interact with CouchDB from python code. In our experience, this was a very well designed library with advanced features like high-level couchDB document to python object mapping, intuitive interfaces and good documentation. 4. Client: For testing, we are using curl to hit our web services and see the response. Curl provides many advanced options to make testing via HTTP requests easy. The following sections explain the functionalities implemented and the web service and database component in detail. These include comments about what we learnt while working on each component.
  • 3. Functionalities This project also required cross team interaction to come up with a stable specification for the web services. As per the specification agreed to by the class, following functionalities were implemented by our team. Here, we observed how the traditional Create, Read, Update and Delete operations in databases, map exactly to HTTP methods POST, GET, PUT and DELETE respectively. Functionality Endpoint (fields in angular brackets are generated on the server) CRUD? HTTP Met- hod Request Parameters (all are string type unless specified) Sign up http://localhost:8080/users/signUp Create POST firstName lastName emailId password Login http://localhost:8080/users/login/ Create POST emailId password Create a board http://localhost:8080/users/<userId>/boards/ Create POST boardName boardDesc category isPrivate(Boolean) Get all boards http://localhost:8080/users/<userId>/boards/ Read GET None Get details of a single board http://localhost:8080/users/<userId>/boards/<boardId>/ Read GET None Update Board http://localhost:8080/users/<userId>/boards/<boardId>/ Update PUT boardName boardDesc category isPrivate(Boolean) Delete Board http://localhost:8080/users/<userId>/boards/<boardId>/ Delete DELETE None Create Pin http://localhost:8080/users/<userId>/boards/<boardId>/p ins/ Create POST pinName image description Get a single pin from a board http://localhost:8080/users/<userId>/boards/<boardId>/p ins/<pinId>/ Read GET None Get all pins from a board http://localhost:8080/users/<userId>/boards/<boardId>/p ins/ Read GET None Update a pin http://localhost:8080/users/<userId>/boards/<boardId>/p ins/<pinId>/ Update PUT pinName image description Delete a pin http://localhost:8080/users/<userId>/boards/<boardId>/p ins/<pinId>/ Delete DELETE None Add a comment to a pin http://localhost:8080/users/<userId>/boards/<boardId>/p ins/<pinId>/comment/ Create POST description View comments on a pin http://localhost:8080/users/<userId>/boards/<boardId>/p ins/<pinId>/comment/ Read GET None
  • 4. The responses were returned in JSON format and contained relevant data and endpoint information for subsequent operations as agreed to by the class. Web Services Why Web Services fit in this project? Essentially, web services help de-couple the client and the server implementations. User performs various CRUD operations on an external system by sending HTTP requests through the client. The web service layer, intercepts these requests on the server, performs operations on the database and sends back appropriate response to the client. This fits well with the sharing and collaboration required by social media products. From real world examples such as Facebook, Twitter and Pinterest, it can be seen that a robust and well documented RESTful API is a vital contributor to these products going viral. Bottle: Web services were written in Python using the Bottle micro-framework. We found Bottle to be very intuitive for creating our web services. The framework is very lightweight and in order to use it, it only requires us to include one bottle.py file in the project directory. Server: Bottle runs by default on a single threaded WSGI server, but has adapters to various multi-threaded servers such as paste and Cherrypy which give better performance for applications that need to handle large number of concurrent requests. For testing this project, we have used the default server. Mapping requests to appropriate methods: Various endpoints as mentioned in the functionalities section, map easily to corresponding methods which process the requests at those endpoint, simply by placing a @route decorator above that method. Retrieving data from request: In REST, the URL path determines the data that will be accessed or manipulated and the HTTP method determines the operation that will be performed on that data. - To get information about data that will be accessed, we use wildcards in the URL: @route(‘http://localhost:8080/users/<userId>/boards/<boardId>/’,method=’GET’) def getBoard(userId, boardId): # got userId and boardId from the URL, now perform GET(read) on database - To retrieve data from the HTTP request, bottle provides convenient methods in the request object: @route(‘http://localhost:8080/users/<userId>/boards/<boardId>/’,method=’PUT’) def updateBoard(userId, boardId): # got userId and boardId from the URL, now perform PUT(update)on database # with the fields sent in the request by the client boardName = request.forms.get('boardName') boardDesc = request.forms.get('boardDesc') Returning JSON response: JSON was the decided as the format in which response will be sent back to the client. Even in this case, Bottle made it easy to return back response with “application/json” content type. We simply had to
  • 5. return a python dictionary object. Bottle returns the response in JSON and the appropriate field is set in the HTTP header. @route(‘http://localhost:8080/users/<userId>/boards/<boardId>/’,method=’PUT’) def updateBoard(userId, boardId): # perform appropriate operations return dict(status='OK', message='sample message') If other response types such as html or xml are expected by the client, we are aware that we would have to check for the content types which the client accepts from the HTTP request header and accordingly format the response before sending it back (content negotiation). Handling trailing ‘/’ slash: If some clients put a trailing slash at the end of the endpoint URL, then that is treated as a separate route by Bottle and might not map to the appropriate method in our web service code. Given that we would be testing across teams, this was highly probable. To handle this, Bottle documentation suggests to simply map two routes to the same method, one with a trailing slash and one without a slash. @route(‘http://localhost:8080/users/<userId>/boards/<boardId>/’,method=’PUT’) #No trailing slash @route(‘http://localhost:8080/users/<userId>/boards/<boardId>’,method=’PUT’) def updateBoard(userId, boardId): # perform appropriate operations Database In REST web services, we can think of the URL as a path that is traversed to get to the data that is to be accessed or manipulated. Further, the HTTP method that is specified in the HTTP request gives us the operation (create, read, update or delete) that is to be performed on the data. Accordingly the actions that we take in code depend on the combination of the following factors: 1. Response format accepted by the client (json, xml, html, image, etc..) 2. Data that is to be accessed (URL traversal) 3. What kind of operation on the data (HTTP method type) Thus, for every endpoint there are several combinations that need to be handled so that we process the user request appropriately and so that we return desired response back to the user. In this context, it is clear that we have to organize our data based on the endpoints that we expose to the user. We observed that this is a notable difference compared to Project 1, where there was only one endpoint for the client, and the server queue delegated the message to the appropriate resource to handle. In Project 2, there are several endpoints for the client and each endpoint maps to one method on the server side. The flat schema that we have used to store data in CouchDB is as follows. The “_id” is the userId that is generated server side when the user signs up. This is passed around in each URL and is used to identify user in each subsequent request.
  • 6. { "_id": { "firstName": "", "lastName": "", "emailId": "", "password": "", "isLoggedIn": false, "boards": [ { "boardId": "", "boardName": "", "boardDesc": "", "category": "", "isPrivate": "", "pins": [ { "pinId": "", "pinName": "", "image": "", "description": "", "comments": [] } ] } ] } }
  • 7. Drawback: The limitation of this schema is that for any request, we get the entire complex document associated with a userId from the database. Then, in case of long URLs we have to employ multiple nested loops to get to the data that we require. For example, updating information about a pin needs three nested loops through the document that is returned. This is shown in the figure above. This would be problematic if a user had thousands of boards and pins. A solution to this would be to create separate tables (“databases” in CouchDB) for each step in the endpoint URL tree, i.e. separate tables for user, board and comments, each record containing reference to the userId. However, the tradeoff here is that this would require more queries to the database per user request. Note on Aerospike: Initially we decided on using Aerospike as our database. However, its Python client seems to be under development and there was no support for list and map data structures. Further, there was no query support in the Python client, only full table scan was supported. Hence we decided to go with CouchDB. Nonetheless, it was interesting to understand Aerospike’s architecture and concepts such as location awareness of client, peer relationship among nodes, use of binary wire protocol for communication and cross data center replication. Conclusion For our team, following are the major learnings from this project: 1. Programming in Python 2. RESTful web services 3. Database design for RESTful web services 4. Micro-frameworks 5. Comparison of technologies used in Project 1 and 2 6. CouchDB and Aerospike 7. Collaboration in Small and Large Software Development Teams