jesa7955 / ghost-code-challenge

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Comments webapp

What is this repo about

This is full stack web application purely in Javascript. It demostratesa simple comments system used in blog, which supports functionalities such as upvote, reply to comments. The app is powered by Kubernetes, which makes it easy to setup environment locally and deploy to any Kubernetes cloud vendor.

Project Structure

  • migration: Database setup with knex.
  • backend: The API talks to database and returns data in json.
    • get_comments: GET endpoint to get the a list of comments
    • post_comment: POST Endpoint to add a new comment. user id and content of the comment are required.
    • update_vote: PUT method to update the upvote count after the Upvote button of a comment is clicked. A server-sent event will be fired to notify clients about the update after the DB insertion succeeds.
    • subscribe_vote_update: GET method for clients to listen on the vote update events.
    • get_user: GET method to get a randomized user info, including a user id, a user name, and a icon url. Powered by the list of unicode smileys emoji and noto-emoji.
  • frontend: Support realtime upvote display, nested comments with React
    • V1: JQuery + Bootstrap V5.2
    • V2: Migrate Javascript parts to React
      • Tree structures to support nested comments are built in the frontend.
      • axios is used to interact with backend.
  • k8s: Kubernetes manifests to simplify the develpment (database setup, cleanup, ...) and deployment.

Local development setup

  • Prepare a k8s cluster (minikube, Docker Desktop, microk8s, ...) and install skaffold.
    • Docker Desktop with WSL tested.
  • Run start-local.sh to install required cusstom k8s operator.
  • Run skaffold dev and wait for the migration job (check the log output).
  • Go to http://comment.localdev.me:8080/ to check the UI.

About


Languages

Language:JavaScript 58.1%Language:TypeScript 27.4%Language:HTML 6.6%Language:Dockerfile 3.2%Language:SCSS 2.4%Language:Shell 2.3%