When you need that fresh cup of joe in the morning...
Build an auto-updating twitter-like feed.
I want to run an auto-updating twitter-like feed. Here is a rough mockup of the expected UI.
- The app should show the latest tweets after the first request
- The list of tweets should update automatically every two seconds
- The older tweets must be pushed down in the page
- The newer tweets should come at the top
- There should be no duplicate tweets on the page
- There should be no skipped or missed tweets on the page
- In case of any failure conditions, the tweet updates can pause or stop but should resume as soon as possible and no error messages should be shown to the user
- The app should stop refreshing as soon as the user scrolls down
- The app should resume refreshing as soon as the user is back at the top
- The app should fetch older tweets when the user reaches the bottom
- The API returns a JSON response and supports CORS
- The JSON response contains the username, id, timestamp, image and text
- The API is designed to fail randomly with HTTP 50X errors (e.g. 500, 503 etc.) and you must handle this in your code. If it fails just try to fetch the updates again.
/api/tweets
Returns all tweets.
/api/reset
Regenerates all fake tweets.
- You don’t need to focus on the UI too much, a barebones version will do just fine
- You can choose any technology stack you are comfortable with
- Please don’t make any additional efforts on writing tests etc
- We will be reviewing your code on the following criteria:
- Architecture decisions made
- Readability of your code
- Handling of edge cases, performance issues, including request efficiency and stability of the web app
# Build
docker compose build
# Start
docker compose up -d
# Shut down
docker compose down -v
The app will be available at http://localhost:3001 or http://localhost:1234 if you're updating the frontend.