Git Product home page Git Product logo

case-project-teknasyon-websocket's Introduction

Start

Run docker-compose up to start project.

Once the initialization is complete, go to your browser:

  • Navigate to localhost:8080/index.html
  • Register by filling the fields.
  • Responses from the server are logged in to console. Please leave your console open.
  • Once you've successfully registered, you can go to Login page.
  • After you have logged in, you are automatically connected to Socket/Gateway.

Gateway Events

These are the events you can receive from the Gateway:

- "user-register" : user: UserDetailsDto
- "user-login" : user: UserDetailDto
- "user-logout" : email: userEmail

API Endpoints

// user module

- /user/me : Return detailed information about user.
- /user/active-users : Return list of users that has active socket connection with server.

// auth module

- /auth/register : Registration
- /auth/login : Authentication

Architecture

The project consists of the core app written in NestJS, haproxy as load balancer, postgresql as database and redis as a transport mechanism for events.

Haproxy configuration forces a client to be connected to same Nestapp instance over a long duration to preserve socket connection.

Example flow of the Events

  • When a user login to system, Auth module fires a local event, 'LOCAL-user-login'.
  • This event is then handled by Message module to propagate this event to Message Broker ( REDIS ), hence the other Nestapp instances.
  • Message module then handles the event received from REDIS and fires another local event, 'GLOBAL-user-login'.
  • 'LOCAL-* ' events are fired within the Nestapp instanced that actually performs the action ( the server user logged in ), whereas 'GLOBAL-* ' action is fired within all Nestapp instances. The flow of events ensure that the system acts as one instance for the client and horizontally scalable.

case-project-teknasyon-websocket's People

Contributors

mkadirtan avatar

Watchers

Muhittin Tan avatar  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.