/dynamodb-instagram

Primary LanguageTypeScriptMIT LicenseMIT

DynamoDB Instagram

This project was built for a DynamoDB demo on Marcia Villalba's YouTube channel. For this demo, we saw how + why to use DynamoDB, then displayed some common DynamoDB patterns by building a simple Instagram clone.

Table of Contents

You may also refer to the following artifacts to understand this project:

Usage

To deploy this project, run the following commands in your terminal:

git clone git@github.com:alexdebrie/dynamodb-instagram.git && cd dynamodb-instagram
npm i
sls deploy

You should see output indicating the service was deployed and your endpoints are live:

Service Information
service: dynamodb-instagram
stage: dev
region: us-east-1
stack: dynamodb-instagram-dev
resources: 69
api keys:
  None
endpoints:
  POST - https://*********.execute-api.us-east-1.amazonaws.com/dev/users
  GET - https://*********.execute-api.us-east-1.amazonaws.com/dev/users/{username}
  POST - https://*********.execute-api.us-east-1.amazonaws.com/dev/users/{username}/photos
  GET - https://*********.execute-api.us-east-1.amazonaws.com/dev/users/{username}/photos/{photoId}
  POST - https://*********.execute-api.us-east-1.amazonaws.com/dev/users/{username}/photos/{photoId}/likes
  GET - https://*********.execute-api.us-east-1.amazonaws.com/dev/users/{username}/photos/{photoId}/likes
  POST - https://*********.execute-api.us-east-1.amazonaws.com/dev/users/{username}/photos/{photoId}/comments
  GET - https://*********.execute-api.us-east-1.amazonaws.com/dev/users/{username}/photos/{photoId}/comments
  POST - https://*********.execute-api.us-east-1.amazonaws.com/dev/users/{username}/followers
  GET - https://*********.execute-api.us-east-1.amazonaws.com/dev/users/{username}/followers
  GET - https://*********.execute-api.us-east-1.amazonaws.com/dev/users/{username}/following
functions:
  createUser: dynamodb-instagram-dev-createUser
  getUser: dynamodb-instagram-dev-getUser
  createPhoto: dynamodb-instagram-dev-createPhoto
  ...

Terms and Concepts

We are building an Instagram clone where users can post photos. Other users may like a photo or comment on a photo. Finally, a user may choose to 'follow' another user in order to see their recent activity.

Each entity is discussed further below. Clicking on the entity link will take you to the code definition for the entity.

  • A User represents a person that has signed up for our application. They will be uniquely identified by a username.

  • A Photo represents an image uploaded by a particular User. You can browse all Photos for a particular User in reverse-chronological order. Each Photo can be Liked or Commented on (see below).

  • A Like represents a specific User 'liking' a specific Photo. A specific Photo may only be liked once by a specific User. When showing a Photo, we will show the total number of Likes for that Photo.

  • A Comment represents a User commenting on a particular Photo. There is no limit to the number of Comments on a Photo by a given User. When showing a Photo, we will show the total number of Comments for that Photo.

  • A Follow represents one User choosing to follow another User. By following another User, you will receive updates from that User in your timeline (not implemented in this demo). A Follow is a one-way relationship -- a User can follow another User without the second User following in return. For a particular User, we want to show the number of other Users following them and the number of Users they're following, as well as the ability to show the lists of Followers and Followees.

DynamoDB patterns

Below are a few patterns demonstrated in this repository that can be useful for using DynamoDB in your application: