Skip to content

die-kreatur/interview-task

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Live Coding Task: Anonymous Comment Board

Services in docker-compose

The repository includes a docker-compose.yml with the following pre-configured services:

  • test-task: the main service you will implement. It contains a Dockerfile and a starter Rust application using actix-web.
  • nginx: reverse proxy.
  • mongodb
  • redis

Goal

Build a REST-based service that allows posting and reading anonymous comments grouped by topic. Each topic is identified by a UUID. The service stores comments and maintains an in-memory list of the most recently updated topics.


Task Description

Implement an HTTP service with the following features:

1. Post a comment

Endpoint:

POST /comments

Input:

{
  "topic_id": "uuid-string",
  "sender": "anon123",
  "text": "hello world"
}

Behavior:

  • Adds the comment under the specified topic.
  • Sets a server-side timestamp (DateTime<Utc>).
  • Updates an in-memory list of 10 most recently updated topics (most recent first).
  • Logs the sender and topic ID.
  • Returns 201 Created with the full comment (including timestamp).

2. Get comments for a topic

Endpoint:

GET /comments/{topic_id}

Behavior:

  • Returns all comments for the specified topic.
  • JSON array format, ordered by timestamp ascending.

3. Get recently updated topics

Endpoint:

GET /topics/recent

Behavior:

  • Returns up to 10 most recently updated topic UUIDs.
  • This list is stored and updated in memory only, not in the database.

Data model

{
  "topic_id": "uuid",
  "sender": "string",
  "text": "string",
  "timestamp": "RFC3339 datetime"
}

Constraints

  • Comments must be stored persistently in database.
  • Only the list of recent topics should be kept in memory.
  • No authentication.
  • Fully async using tokio and actix-web.
  • Use uuid for topic IDs.
  • Use chrono for timestamps.

Building and Running the Project

To build the Docker image:

./build-image.sh

To start the project with all services:

docker compose up

The test-task service will be accessible at:

http://0.0.0.0:8080/test-task/

To rebuild the image and apply changes:

./build-image.sh && docker compose up -d

To shut everything down and remove volumes:

docker compose down -v

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors