Code Monkey home page Code Monkey logo

dotnet-real-time-chat's Introduction

⭐ Real Time Chat ⭐

💬 A real time chat application using C# dotnet, SignalR, RabbitMQ, Identity and some other technologies and patterns. This is a coding challenge 👨‍💻

Code Challenge

Assignment

📌 The goal of this exercise is to create a simple browser-based chat application using .NET. This application should allow several users to talk in a chatroom and also to get stock quotes from an API using a specific command.

Mandatory Features
  • ✔ Allow registered users to log in and talk with other users in a chatroom.
  • ✔ Allow users to post messages as commands into the chatroom with the following format /stock=stock_code
  • ✔ Create a decoupled bot that will call an API using the stock_code as a parameter (https://stooq.com/q/l/?s=aapl.us&f=sd2t2ohlcv&h&e=csv, here aapl.us is the stock_code).
  • ✔ The bot should parse the received CSV file and then it should send a message back into the chatroom using a message broker like RabbitMQ. The message will be a stock quote using the following format: “APPL.US quote is $93.42 per share”. The post owner will be the bot.
  • ✔ Have the chat messages ordered by their timestamps and show only the last 50 messages.
  • ✔ Unit test the functionality you prefer.
Bonus (optional)
  • ✔ Have more than one chatroom.
  • ✔ Use .NET identity for users authentication.
  • ✔ Handle messages that are not understood or any exceptions raised within the bot.
  • ⚠️ Build an installer. => I used docker-compose to build and run the application, i'm not sure if that counts
Considerations
  • ✔ We will open 2 browser windows and log in with 2 different users to test the functionalities.
  • ✔ The stock command won’t be saved on the database as a post.
  • ✔ The project is totally focused on the backend; please have the frontend as simple as you can.
  • ✔ Keep confidential information secure.
  • ✔ Pay attention if your chat is consuming too many resources.
  • ✔ Keep your code versioned with Git locally.
  • ✔ Feel free to use small helper libraries.

Demonstrations

Images showing how the application works:

Login Page

Login Page

Register Page

Register Page

Two different users logged and chatting

Chat Page

Stock Command

Chat Page

Technologies and Patterns

🛠 These are all the technologies and patterns used to develop this application

BackEnd

Patterns and Techniques:

  • TDD (Test Driven Development)
  • DDD (Domain Driven Design)
  • CQRS (Command Query Responsibility Segregation)
  • Middlewares: Error, Request and Response
  • Dependency Injection
  • Repository Pattern
  • Unit of Work Pattern
  • Domain Notification
  • Domain Message
FrontEnd

Architecture

The project solution was based on DDD (Domain Driven Design) concept. DDD

Below is the workflow diagram of the solution used: Workflow Diagram Explaining: The users connect to the web application, which will interact to the web API. A channel will be opened with the client using SignalR, and the Web API will use SQLServer as database. A decoupled bot worker was created to communicate with the Stock API, and send messages to the rabbitMQ queue.

Requirements

I recommend following the option 01, so you wont need to install and run all the other tools needed for the project to work.

Option 01: Run in Containers To run the local application in containers, you will need to download and install the following:

Option 02: Outside Containers If you want to run the project outside containers, you must also have the following:

Executing the Project

To execute the project, follow the steps below:

Important Notes

  1. When executing the page for two or more users, you need to open the browser as incognito mode, because the token session is stored on local storage of your browser.
  2. If for any reason you receive error sending message to RabbitMQ, it is because the port couldnt be opened or is in use. To solve the problem go on docker-compose on 'rabbitmq-service', change port number and run the commands again.

Option 01: Run in Containers

  1. Run Docker Desktop.
  2. Open the command prompt (cmd), navigate inside the project "\src" folder, and type: "docker-compose build" to build the containers (this is only necessary the first time).
  3. Type "docker-compose up -d" to start the application containers.
  4. Now you can view the application:
    1. To run the Web Application, navigate to http://localhost:8080
    2. To view the Web Api Swagger documentation, navigate to http://localhost:8082/swagger

to stop the execution of the containers, type "docker-compose down"

Option 02: Outside Containers

  1. Run SQLServer(port 1435) and RabbitMQ (port 15673).
  2. Open the command prompt (cmd), navigate inside the project "\src" folder, and type: "run.bat"
  3. This script will run the projects and open the browsers.

dotnet-real-time-chat's People

Contributors

dependabot[bot] avatar pablochristian avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.