This example implementation shows how to build a backend for nested comments like Reddit or Slack. To add and retrieve users’ comments, frontend requests are sent to the system through AWS API Gateway and comments are stored in DynamoDB.
Comments are managed using a dependency graph on AWS Lambda that is connected to DynamoDB for persistence. Using a graph structure (built using
networkx library) allows for an infinitely nested comments thread. In the DynamoDB table, parent and child comments are tracked using
threadId where a comment with
parentId as -1 is the root comment. The example is headless and can be plugged into any custom frontend. By using serverless architecture, it allows for easy maintenance and deployment and flexible usage based pricing.
Prerequisites Setup AWS Credentials
Make sure you have AWS access key and secrete keys setup locally, following this video here
npm install serverless
serverless create --template-url http://github.com/codeRecipe-dev/nested-comments-serverless --path nested-comments-serverless
cd nested-comments-serverless npm install serverless deploy --stage <your-stage-name>