Giter Club home page Giter Club logo

markt's Introduction

Markt - Jobsity's coding test

This project was developed with the intention of being a code test for Jobsity, you can find more about the challenge at the original PDF file that was sent to me here.

The challenge consists of a simple browser-based chat application using NodeJS where several users can talk and send commands to the application to get stock quotes.

The project is live and published on DigitalOcean and Vercel and can be tested at the link below.

markt.hpiaia.dev

Table of Contents

Features

  • Multi room — users can create rooms at the home page
  • Real time — messages arrive in no time
  • Easy to implement new commands — just implement a new method in the service with the command name and the application will take care of the rest

Architecture

As the challenge itself suggested, the application was separated into three services:

  • API: This service is responsible for handling all the incoming HTTP requests from the user. (authentication, list rooms, create rooms, etc) and also has a WebSocket endpoint that handles the chat business-logic (join into a room, send a message, retrieve messages, etc).
  • BOT: This service is responsible for handling commands that are send for the application via chat. It runs asynchronously and communicates with the API service via RabbitMQ.
  • WEB: This is the frontend application that runs on the users browser, it contemplates the user interface and communicates with the API service via HTTP or WebSocket requests.

Below is a diagram of the architecture and communication between the services:

communication diagram

Technologies

This section describes every technology used in the project, divided by application.

  • API
    • Typescript
    • NestJS
    • Prisma ORM
    • PassportJS with JWT
    • RabbitMQ
    • SocketIO
    • Postgres
  • BOT
    • Typescript
    • NestJS
    • RabbitMQ
  • WEB
    • Typescript
    • React
    • NextJS
    • TailwindCSS
    • SocketIO

Running the project locally

Environment variables

First of all, we need to setup our environment variables, so the applications can communicate correctly with the Postgres and the RabbitMQ services.

You will need both of this services running somewhere, if you want to run them locally in your machine, you can easily do it with docker using the following commands.

docker run --name markt-postgres -e POSTGRES_PASSWORD=postgres -p 5432:5432 -d postgres
docker run --name markt-rabbit --hostname markt-rabbit -p 15672:15672 -p 5672:5672 rabbitmq:3-management

First, duplicate the .env.example to a file called .env in the /api folder, then edit the variables to point to your services.

  • PORT - The port that the API service will run
  • APP_SECRET - The encription key for the authentication tokens
  • DATABASE_URL - The Postgres connection string
  • RABBITMQ_URL - The RabbitMQ connection string

Then, do the same thing with the .env.example file in the /bot folder.

  • RABBITMQ_URL - The RabbitMQ connection string, make sure it is the same as the API uses

Lastly, do the same thing with the .env.example file in the /web folder.

  • NEXT_PUBLIC_API_URL - The full url of the API endpoint

Database migration

After your environment variables are all correct, you need to run the prisma migration for the database creation. To do that, simply run this command on the api folder.

cd /api && npx prisma migrate dev

You can find more about it at the official Prisma documentation, following this link.

Running the applications

If you want, you can run the applications with NodeJS and without docker, but first you need to make sure you have the RabbitMQ and Postgres services up and running.

To run the applications with Node, run the following commands in different terminal windows.

cd /api && npm install && npm run start:dev
cd /bot && npm install && npm run start:dev
cd /web && npm install && npm run dev

Thanks

I would like to thank Jobsity for the opportunity to show my work and for the consideration.

I hope you all go well.

markt's People

Contributors

hpiaia avatar

Watchers

 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.