Skip to content

mamosk/social_networking_kata

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Social Networking Kata

This is a complex implementation of the social networking kata proposed by Xpeppers team.

A simple implementation can be found here.

This kata is implemented using:


Get started

This kata runs in two modes:

  • mono is the quick as a snake, quiet as a shadow way:
    • a single script does everything
    • data is managed directly on the file system
  • full is the calm like a giant tree in a storm way:

When the CLI is ready you can type help to display available commands. Enjoy!

Mono mode

To execute the script in mono mode:

  1. clone the repo — follow this guide
  2. run the kataq command (adding demo to run a non-interactive session):
    • on Windows: %SYSTEMDRIVE%:\path\to\the\repo\kataq.cmd [demo]
    • on Linux: /path/to/the/repo/kataq.sh [demo]

Full mode

To spin up the services in full mode:

  1. make sure you have Docker 1.12.0 or higher
  2. clone the repo — follow this guide
  3. run the kata command (adding demo to run a non-interactive session):
    • on Windows: %SYSTEMDRIVE%:\path\to\the\repo\kata.cmd [demo]
    • on Linux: /path/to/the/repo/kata.sh [demo]

The first run may take a few minutes... meanwhile you can have a look at:


Architecture

                        Timelines API ---- Timelines DB ---- Timelines DB admin
                       /              \                    /
                      /                \                  /
CLI ---- API gateway <                  >---- Web UI ----<
                      \                /                  \
                       \              /                    \
                        Followers API ---- Followers DB ---- Timelines DB admin

Frontend

Frontend user interfaces include:

CLI

The command line interface is implemented in Bash using curl and jq to interact with the API gateway when running in full mode.

If you type help in the CLI you'll see this:

kata commands:
  <user name> -> <message>           -> post message to user timeline
  <user name>                        -> read messages from user timeline
  <user name> follows <another user> -> subscribe user to another user timeline
  <user name> wall                   -> read messages from user timeline and subscriptions

utility commands:
  exit -> exit the cli
  help -> read this help
  kata -> read full readme of kata requirements
  mode -> tell if running in:
          - 'full' mode: attached to an API server which handles user data
          - 'mono' mode: handling user data using the file system

kata readme: https://github.com/xpeppers/social_networking_kata

This is the output of a demo run:

> Alice -> I love the weather today
> Bob -> Damn! We lost!
> Bob -> Good game though.
> Alice
> Alice - I love the weather today (5 seconds ago)
> Bob
> Bob - Good game though. (4 seconds ago)
> Bob - Damn! We lost! (6 seconds ago)
> Charlie -> I'm in New York today! Anyone wants to have a coffee?
> Charlie follows Alice
> Charlie wall
> Charlie - I'm in New York today! Anyone wants to have a coffee? (4 seconds ago)
> Alice - I love the weather today (14 seconds ago)
> Charlie follows Bob
> Charlie wall
> Charlie - I'm in New York today! Anyone wants to have a coffee? (7 seconds ago)
> Bob - Good game though. (14 seconds ago)
> Bob - Damn! We lost! (16 seconds ago)
> Alice - I love the weather today (17 seconds ago)

Web UI

The web user interface is implemented in HTML, CSS and JavaScript using React.

When the CLI is ready you can open the web UI here to inspect services.


Backend

Once the backend services are up and running, you can [inspect] them.

You can find the credentials in the /backend/.env file.

API gateway

The API gateway exposes the 4 kata requirements using Node-RED with JSONata:

Timelines

Timelines API

Users timelines are written (posting kata) and read (reading and wall kata) using Node-RED with JSONata.

Exposed endpoints are:

Timelines DB

Users posts are stored into a time serie using InfluxDB, with infinite retention policy and 1s precision.

Timelines DB admin

The time series database server is managed using Chronograf. You can query the timelines here.

All different timelines are stored into the same timeline measurement, indexed by the user tag.

Followers

Followers API

The information about "who-follows-who" is written (following kata) and read (wall kata) using a Spring Boot application with Lombok and JPA.

Exposed endpoints are (more than necessary, for test purposes):

Followers DB

The information about "who-follows-who" is stored into a PostgreSQL database.

The user entity "follows" other user entities in an unidirectional many-to-many relationship.

Followers DB admin

The database is managed using pgAdmin.

To view DB tables open Servers > pgkata > Databases > kata > Schemas > public > Tables


Tests

  • Take a look at these examples of simple unit tests.
  • Import this collection in Postman to run functional and integration tests.
  • Run npm test command in frontend/react directory to run a minimal ui test.

Made with ❤️ by Fabio Michelini