A reddit/digg clone (hence the portmanteau name) for Carousell Coding Exercise. A topic aggregator application -- users can submit topics and upvote/downvote topics. The homepage shows the top 20 topics sorted by score.
Try it out at https://reddigg-pykbbjxyfr.now.sh
Proudly written using vim.
Make sure you have Node.js and yarn/npm installed.
Clone the repository, then run these commands: (you can substitute yarn
with npm
)
yarn install
yarn build
yarn start
For deployment to Zeit Now, simply run yarn global add now
or npm install -g now
to install the Now CLI, then run now
on the repository.
You can implement your own front-end too utilising the back-end API!
Backend API server responds in JSON -- to check whether your request succeeded you can either check for key success to be true, or the HTTP status code (200 for success, 400 for failure)
GET /all
POST /new
key | type |
---|---|
title | string |
PUT /upvote/:id
PUT /downvote/:id
- Next.js framework (a minimalistic framework for server-rendered React application)
- Bootstrap for styling and FontAwesome
This is my first time developing a web application using a JavaScript/React web framework, so I researched and considered either create-react-app
or Next.js
. I eventually went with Next.js
because it is minimalistic, more opinionated (convention-over-configuration which makes rapid development easier for me), and comes with an easy integration with Zeit Now for deployment.
- Node.js
I wrote a simple model for Topic and TopicManager.
The data structure used is JavaScript Array. The reasoning is that JavaScript is an interpreted language, so internal implementation of Array differs for different JavaScript engines. However, Array is a commonly used data structure, and so it is usually highly optimised by the JavaScript engine. Moreover, many standard libraries to deal with Array also allows more rapid development, and allows my application to benefit from future improvements to the functions in the standard library.
In any case, my assumption is that the dataset is small, so using standard library is a good enough trade-off for performance vs development speed (to prevent over-engineering -- premature optimisation is the root of all evil).
- Jest
- Enzyme
- Sinon
- jest-fetch-mock
- ESLint for Linting, using Airbnb style guide
- TravisCI for Continuous Integration
- Coveralls for Code Coverage monitoring
- Codacy for automated code review