javascript – Clean Architecture in NodeJS – How to approach the next step (use-cases) after entities?

I’ve been trying to learn about software architecture and after watching multiple talks of Robert C. Martin I fell in love with his concepts and Test Driven Development.

For a couple days now I’ve been trying to follow the Clean Architecture principles while building a chat-application server that used to be one big monolith mess. But I have the gut feeling I’m not understanding it at all and have no clue how to approach the next step after entities: Use Cases.

So far I’ve come up with 4 entities:
message, room, user & uuid.

A user should be able to create a room and add a message to the room. A user should also be able to join an existing room and add a message in this existing room.

An example of the room entity:

./entities/room/room.spec.js

"use strict";
const chai = require("chai");
chai.use(require("chai-uuid"));
const expect = chai.expect;

const makeMessage = require('./index.js');

describe('message', function() {

    const message = makeMessage({
        content: "Hello World!",
        sender: "#9119BBXX1212"
    });

    it('must contain a non-empty string', function() {
        expect(message.getContent()).to.be.a('string').and.not.be.empty;
    });

    it('must contain a valid UUID', function() {
        expect(message.getId()).to.be.a.uuid();
    })

    it('must contain a sender', function() {
        expect(message.getSender()).to.be.a('string');
    })

    it('must contain a created at date', function() {
        expect(message.getCreatedAt()).to.be.a('date');
    })

});

./entities/room/makeRoom.js

module.exports = function buildMakeRoom({uuid}) {

    return function makeRoom({messages = (), createdAt = new Date(), theUuid = uuid.generate()} = {}) {

        return Object.freeze({
            getId: () => theUuid,
            getCreatedAt: () => createdAt,
            getMessages: () => messages,
            addMessage: function(message) {
                messages.push(message);
            }
        })

    }

}

./entities/room/index.js

const buildMakeRoom = require('./makeRoom.js');
const uuid = require('../uuid/index.js');

const makeRoom = buildMakeRoom({uuid});
module.exports = makeRoom;

That’s what I think an entity in Node would look like. And it works great if I play with it a little. But what’s the next step? How do I make a Use Case based on this entity?

I’ve tried to play with the entities in the main file to get a feeling for what’s necessary. But I’m so confused:

const makeRoom = require('./entities/room/index.js');
const makeUser = require('./entities/user/index.js');
const makeMessage = require('./entities/message/index.js');

// #Repository - Store Rooms and Users
const rooms = {};
const users = {};

// #User - Create A User
const userOne = makeUser();
users(userOne.getId()) = userOne;

// #Room - Create A Room
const room = makeRoom();
rooms(room.getId()) = room;

// #User - Join A Room
userOne.setCurrentRoom(room.getId());
userOne.setJoinedRoom(true);

// #Message - Create a Message
const message = makeMessage({
    sender: userOne.getId(),
    content: "Hello World!"
})

// #Room - Add a Message
rooms(userOne.getCurrentRoom()).addMessage(message);

// #User - Create A User
const userTwo = makeUser();
users(userTwo.getId()) = userTwo;

// #User - Join A Room
userTwo.setCurrentRoom(room.getId());
userTwo.setJoinedRoom(true);

// #Message = Create A Message
const secondMessage = makeMessage({
    sender: userTwo.getId(),
    content: "Whatsupp World!"
})

// #Room - Add a Message
rooms(userTwo.getCurrentRoom()).addMessage(secondMessage)

// #Room - Display Messages
rooms(room.getId()).getMessages().forEach(message => {
    // Display the Messages to Console (This could be a UI as well. Like an web-interface)
    console.log(message.getCreatedAt(), message.getSender(), message.getContent());
})

I would appreciate it so much if you could help me out!

TL;DR: After writing your entities with TDD and Clean Architecture. What should be the next step to create a good Use Case?