Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Prerequisites:
- * Docker
- * Any Relational Database
- * Any Non-Relational Database
- * Docker Registry
- * Jenkins
- * Amazon Web Services
- * EC2
- * S3
- * Api Gateway
- * Lambda functions
- * Route 53
- * Serverless frameworks(eg. Serverless, ClaudiaJS)
- # Project Description
- * ## Application
- ### Overview
- Simple API which will allow user to save some post and retrieve it later.
- > 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
- > Use this userID to post some message which will create entries in non relational database
- > User can Query data using their userID which will give back posts fetched from database along with his profilepicture url
- > 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.
- * ## Devops
- ### Overview
- Continuous Integration and deployment is the main objective of this setup.
- Ideal Behaviour:
- > 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
- > inside ec2 instance, jenkins pulls latest image from docker-hub/docker-registry and deploys it.
- # NOTE
- > 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.
- > There is no restriction on programming language to be used for building API
- # Project Structure
- * ## Application Side :
- ## API
- ### Routes :
- * #### GET /users -> Serves all user data saved in SQL database.
- Ideal Response:
- ```javascript
- {
- 'data': [
- {
- 'userID1001': {
- 'email': 'user@gmail.com'
- }
- },
- {
- 'userID1002': {
- 'email': 'user-2@gmail.com'
- }
- }
- ],
- 'status': 'Success'
- }
- ```
- * #### POST /users -> Creates a new user in SQL database
- Ideal Response (Success)
- ```javascript
- {
- 'data':[{
- 'userID1003': {
- 'email': 'user-3@gmail.com'
- }
- }],
- 'status': 'Success'
- }
- ```
- Ideal Response (Failure)
- ```javascript
- {
- 'data':[{
- 'errorCode': 'EMAIL_ALREADY_EXISTS',
- 'errorDescription': 'Some relevant description'
- }
- ],
- 'status':'Failure'
- }
- ```
- * #### GET /users/userid -> Returns user data
- ```
- 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
- 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.
- ```
- Ideal Response (Success)
- ```javascript
- {
- 'data':[{
- 'userid1001': {
- 'email': 'user@gmail.com',
- 'isProfilePicturePresent': true,
- 'profilePictureURL': 'amazon-s3-object-url',
- 'posts':[{
- 'timestamp-1': 'data-1'
- },
- {
- 'timestamp-2': 'data-2'
- }]
- }
- }],
- 'status':'Success'
- }
- ```
- * #### POST /users/userid -> Accepts new Post messages from a user
- ```
- User sends the post as JSON object in request body
- ```
- Ideal response
- ```javascript
- {
- 'data': [{
- 'userid1001':{
- 'post':{
- 'timestamp': 'data'
- }
- }
- }],
- 'status':'Success'
- }
- ```
- ## Databases and Storage
- *Relational Database*
- ```
- 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.
- ```
- *Non Relational Database*
- ```
- Setup any non relational database of your choice. Use this DB to save posts, which user sends via API
- ```
- *Storage*
- ```
- Amazon-s3 will be used to save any files required in this project
- Access keys will be provided to use within application
- ```
- * ## Ideal Version control(Only API related codebase) :
- * Setup private bitbucket/github repo
- * maintain 2 branches (master and dev), where working code will be pushed
- Git Workflow you should follow :
- > Create a fresh repo and setup above mentioned 2 branch
- > When working on a particular feature of project
- > Create a new feature branch from master
- > Work on your feature branch
- > Merge it back to dev branch
- > Merge dev into master branch
- * ## Devops Instructions :
- * Docker
- > Setup API to run inside docker using Dockerfile
- > Use docker hub to save build images
- > Using docker while deploying databases is optional but recommended
- * Jenkins
- > CI tool you will use to automate deployment of docker containers inside EC2 using build pipelines
- > On each commit for dev or master branch, jenkins will build a new docker image with respective tag[master/dev]
- > Cron jobs to be configured in final stage of project for regular database backups
- > it is optional to stick with bash scripts or groovy script
- * AWS
- ```
- You will be provided with access credentials for programatic access to aws resources.
- Also, you will be given AWS UI Console access which you will use to setup infrastructure of this project.
- 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).
- Pick a region and stick with it.
- ```
- * EC2
- ```
- Launch instance which best fits your need.
- Dont misplace PEM key file generated while launching instance.
- ```
- > NOTE: You can deploy multiple instances as per your requirement. Use same PEM file for multiple EC2 instances
- * S3
- ```
- Create bucket name with your name in it.
- ```
- * API Gateway
- ```
- Once docker implementation is finished, deploy same API code in serverless environment using API gateway and lambda functions.
- ```
- * Route53
- ```
- Configure a subdomain to point to your API for each dev and master deployments.
- ```
- * Docker Registry:
- ```
- Setup Docker registry on fresh EC2 instance and replace docker hub with it in build pipeline.
- ```
Add Comment
Please, Sign In to add comment