/nyla-instant-messaging-app

Nyla is a centralized instant messaging application built with React.js front-end, Express.js back-end and MongoDB database. Real-time messaging is provided by Websockets as notification servers, coordinated using Redis message queue.

Primary LanguageJavaScriptMIT LicenseMIT

Nyla

Nyla is an example of an instant messaging application.



Requirements


Architecture

Nyla is a centralized instant messaging application built with React.js front-end, Express.js back-end and MongoDB database. Real-time messaging is provided by Websockets as notification servers, coordinated using Redis message queue. The chosen architecture and overall server design allows for horizontally scalability.


This repository contains the implementation of the web server (client folder), REST api server (server-api folder) and ws server (server-ws folder). MongoDB and Redis can be used simply by installing the relevant software; no other configuration (other than that provided in the folders listed above) is required.


Getting started (local development build)

To start with the local development build (each server in single instance), docker-compose can be used ( manual configuration is also described below).


Using docker-compose (recommended)

  1. Start Docker application

  2. Navigate to the project root folder (where docker-compose.yaml file is located) and just run all the services using docker-compose:

     	docker-compose up
    

Wait for container creations, once client development server is ready, connect to the app using your browser.


Manual Setup

Setup back-end (MongoDB, Redis, REST-API server and WS server) and front-end (React Client App) of the app by following the list below.

Configurations files are already set for local development build.

MongoDB

At first, the app will start with an empty database, generated with the first write (probably a user registration). For this reason database configuration only consist in starting the MongoDB process or service.

  1. Download and setup MongoDB (here).
  2. Start MongoDB as process or a service.

Redis

  1. Redis is used as message-queue for API server and WS server communication. Just download and configure Redis in the build environment (here).

  2. Start Redis server:

     % redis-server
    

REST-API Server (Express.js)

  1. In server-api .env file provide the basic configurations:

    • Provide database url and name:

         DATABASE_URL=mongodb://<database_host:database_port>
         DATABASE_NAME=<your_database>
      
    • Provide authentication random encryption key (better if its very long and complex) for password hashing:

         SECRET_OR_KEY=<your_secret_or_key>
      
    • Provide Redis MQ url and port:

         MQ_SERVER_URL=<redis_server_host:redis_server_port>
      
  2. From the server-api root folder, install all required modules, then run the server:

       server % npm install
       server % npm start
    

WS-Server (WS.js)

  1. In server-ws .env file provide the basic configurations:

    • Provide Redis MQ url and port configurations:

         MQ_SERVER_URL=<redis_server_host:redis_server_port>
      
    • Provide server-api url:

        API_SERVER_URL=<api_server_host:api_server_port>
      
  2. From the server-ws root folder, install all required modules, then run the server:

       server % npm install
       server % npm start
    

Static Web Server (React.js)

  1. In client .env file provide the basic configurations:

    • Provide url for react-proxy server (to server-api):

       REACT_APP_PROXY_URL=http://localhost:3001
      
    • Provide the url for ws-server:

       REACT_APP_WSS_URL=ws://<ws_server_host:ws_server_port>
      
  2. From the client root folder, install the packages, then run the client:

       client % npm install
       client % npm start
    



Open-API Swagger Documentation

The API documentation is generated using Swagger, and it provides a comprehensive overview of all available endpoints, their functionality, required parameters, and expected responses. You can access the Swagger documentation by visiting http://localhost:3001/api-docs after starting the API server.



Folder Structure

.
├── client
|   ├── public
|   └── src
|       ├── api
|       ├── components
|       |   ├── Alerts
|       |   ├── Common
|       |   ├── Icons
|       |   ├── Pages
|       |   |   ├── Account
|       |   |   ├── Chats
|       |   |   ├── Home
|       |   |   └── Users
|       |   ├── UI
|       |   |   ├── Footer
|       |   |   ├── Nav
|       |   |   └── Push
|       |   └── Ws
|       ├── styles
|       └── utils
|
├── images
|
├── server-api
|   ├── components
|   ├── controllers
|   ├── middleware
|   ├── schemas
|   |   └── abstract
|   └── services
|
└── server-ws
    └── services



Main Features (Images)

Create and track your personal chats

Create and track your personal chats and find new users.

Instant messaging with group and direct chats

Instant messaging with group and direct chats with intuitive settings.

Fast password-based registration/authentication

Registration/authentication using username and password.



Curiosity

Nyla is a short word inspired by Nyarlathotep, who is a fictional entity belonging to Howard Phillips Lovecraft's Cthulhu Cycle. Nyarlathotep acts according to the will of the Outer Gods and is their messenger.



Author



License

This project is licensed under the MIT License, which means you're free to use, modify, and distribute the code as long as you include the original license notice.