The repository includes a docker-compose.yml with the following pre-configured services:
- test-task: the main service you will implement. It contains a
Dockerfileand a starterRustapplication usingactix-web. - nginx: reverse proxy.
- mongodb
- redis
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.
Implement an HTTP service with the following features:
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 Createdwith the full comment (including timestamp).
Endpoint:
GET /comments/{topic_id}
Behavior:
- Returns all comments for the specified topic.
- JSON array format, ordered by timestamp ascending.
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.
{
"topic_id": "uuid",
"sender": "string",
"text": "string",
"timestamp": "RFC3339 datetime"
}- Comments must be stored persistently in database.
- Only the list of recent topics should be kept in memory.
- No authentication.
- Fully async using
tokioandactix-web. - Use
uuidfor topic IDs. - Use
chronofor timestamps.
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