Guest User

Untitled

a guest
Jan 4th, 2019
341
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.49 KB | None | 0 0
  1. # Prerequisites:
  2. * Docker
  3. * Any Relational Database
  4. * Any Non-Relational Database
  5. * Docker Registry
  6. * Jenkins
  7. * Amazon Web Services
  8. * EC2
  9. * S3
  10. * Api Gateway
  11. * Lambda functions
  12. * Route 53
  13. * Serverless frameworks(eg. Serverless, ClaudiaJS)
  14.  
  15. # Project Description
  16.  
  17. * ## Application
  18. ### Overview
  19. Simple API which will allow user to save some post and retrieve it later.
  20.  
  21. > User sends a post request to create a new user which creates a new entry in relational database table and sends back newly generated userID
  22.  
  23. > Use this userID to post some message which will create entries in non relational database
  24.  
  25. > User can Query data using their userID which will give back posts fetched from database along with his profilepicture url
  26.  
  27. > NOTE : Profile picture is manually uploaded inside amazon S3 bucket with a predefined naming convention mentioned later. We are not implementing any logic on API to upload an image on s3 or receive any image data in API request.
  28.  
  29. * ## Devops
  30. ### Overview
  31.  
  32. Continuous Integration and deployment is the main objective of this setup.
  33.  
  34. Ideal Behaviour:
  35.  
  36. > on each push for a particular git branch stored on github/bitbucket, jenkins job is triggered which builds a docker image with respective tag and pushes it to docker-hub/docker-registry
  37.  
  38. > inside ec2 instance, jenkins pulls latest image from docker-hub/docker-registry and deploys it.
  39.  
  40. # NOTE
  41. > This Project has a expected deadline of 7 days. Therefore it is not mandatory for any intern to submit it in full. Evaluation will be done based on maximum working components of this project, Git workflow and optimal solution.
  42.  
  43. > There is no restriction on programming language to be used for building API
  44.  
  45. # Project Structure
  46.  
  47. * ## Application Side :
  48.  
  49. ## API
  50.  
  51. ### Routes :
  52. * #### GET /users -> Serves all user data saved in SQL database.
  53.  
  54. Ideal Response:
  55.  
  56. ```javascript
  57. {
  58. 'data': [
  59. {
  60. 'userID1001': {
  61. 'email': 'user@gmail.com'
  62. }
  63. },
  64. {
  65. 'userID1002': {
  66. 'email': 'user-2@gmail.com'
  67. }
  68. }
  69. ],
  70. 'status': 'Success'
  71. }
  72. ```
  73. * #### POST /users -> Creates a new user in SQL database
  74.  
  75. Ideal Response (Success)
  76.  
  77. ```javascript
  78. {
  79. 'data':[{
  80. 'userID1003': {
  81. 'email': 'user-3@gmail.com'
  82. }
  83. }],
  84. 'status': 'Success'
  85. }
  86. ```
  87. Ideal Response (Failure)
  88.  
  89. ```javascript
  90. {
  91. 'data':[{
  92. 'errorCode': 'EMAIL_ALREADY_EXISTS',
  93. 'errorDescription': 'Some relevant description'
  94. }
  95. ],
  96. 'status':'Failure'
  97. }
  98. ```
  99. * #### GET /users/userid -> Returns user data
  100.  
  101. ```
  102. Profile Picture : Create a unique bucket on amazon s3 from your account. Every user will have profile picture saved as {user-ID_profile_picture}.jpeg/png/etc. If its present, return appropriate data. Use access keys to get objects from amazon s3 bucket
  103.  
  104.  
  105. Posts : Every user can post a message(API route defined later) through API, which will be saved in No-SQL database. use unique user-ID values while storing posts to identify user.
  106.  
  107. ```
  108.  
  109. Ideal Response (Success)
  110.  
  111. ```javascript
  112. {
  113. 'data':[{
  114. 'userid1001': {
  115. 'email': 'user@gmail.com',
  116. 'isProfilePicturePresent': true,
  117. 'profilePictureURL': 'amazon-s3-object-url',
  118. 'posts':[{
  119. 'timestamp-1': 'data-1'
  120. },
  121. {
  122. 'timestamp-2': 'data-2'
  123. }]
  124. }
  125. }],
  126. 'status':'Success'
  127. }
  128. ```
  129. * #### POST /users/userid -> Accepts new Post messages from a user
  130.  
  131. ```
  132. User sends the post as JSON object in request body
  133. ```
  134.  
  135. Ideal response
  136. ```javascript
  137. {
  138. 'data': [{
  139. 'userid1001':{
  140. 'post':{
  141. 'timestamp': 'data'
  142. }
  143. }
  144. }],
  145. 'status':'Success'
  146. }
  147. ```
  148. ## Databases and Storage
  149.  
  150. *Relational Database*
  151. ```
  152. Setup any relational database of your choice. Use this database to save user's email ID and userID(Generated for each new user) which would act as unique identifier.
  153.  
  154. ```
  155.  
  156. *Non Relational Database*
  157. ```
  158. Setup any non relational database of your choice. Use this DB to save posts, which user sends via API
  159. ```
  160.  
  161. *Storage*
  162. ```
  163. Amazon-s3 will be used to save any files required in this project
  164. Access keys will be provided to use within application
  165. ```
  166.  
  167. * ## Ideal Version control(Only API related codebase) :
  168.  
  169. * Setup private bitbucket/github repo
  170. * maintain 2 branches (master and dev), where working code will be pushed
  171.  
  172. Git Workflow you should follow :
  173. > Create a fresh repo and setup above mentioned 2 branch
  174.  
  175. > When working on a particular feature of project
  176.  
  177. > Create a new feature branch from master
  178.  
  179. > Work on your feature branch
  180.  
  181. > Merge it back to dev branch
  182.  
  183. > Merge dev into master branch
  184.  
  185. * ## Devops Instructions :
  186.  
  187. * Docker
  188.  
  189. > Setup API to run inside docker using Dockerfile
  190.  
  191. > Use docker hub to save build images
  192.  
  193. > Using docker while deploying databases is optional but recommended
  194.  
  195. * Jenkins
  196.  
  197. > CI tool you will use to automate deployment of docker containers inside EC2 using build pipelines
  198.  
  199. > On each commit for dev or master branch, jenkins will build a new docker image with respective tag[master/dev]
  200.  
  201. > Cron jobs to be configured in final stage of project for regular database backups
  202.  
  203. > it is optional to stick with bash scripts or groovy script
  204.  
  205. * AWS
  206. ```
  207. You will be provided with access credentials for programatic access to aws resources.
  208. Also, you will be given AWS UI Console access which you will use to setup infrastructure of this project.
  209.  
  210. For each resource you use, stick with common naming convention for their tag or name. eg. intern_name_ec2_instance(as ec2 instance name) or intern_name_key_file.pem(as key file name).
  211.  
  212. Pick a region and stick with it.
  213. ```
  214.  
  215. * EC2
  216. ```
  217. Launch instance which best fits your need.
  218. Dont misplace PEM key file generated while launching instance.
  219. ```
  220. > NOTE: You can deploy multiple instances as per your requirement. Use same PEM file for multiple EC2 instances
  221.  
  222. * S3
  223. ```
  224. Create bucket name with your name in it.
  225. ```
  226. * API Gateway
  227. ```
  228. Once docker implementation is finished, deploy same API code in serverless environment using API gateway and lambda functions.
  229. ```
  230. * Route53
  231. ```
  232. Configure a subdomain to point to your API for each dev and master deployments.
  233. ```
  234.  
  235. * Docker Registry:
  236. ```
  237. Setup Docker registry on fresh EC2 instance and replace docker hub with it in build pipeline.
  238. ```
Add Comment
Please, Sign In to add comment