The goal of this project is to build microservice application with functionality that encapsulates:
- sending text messages
- sending files
- videocalls in group
- rights system for groups
- ability to add and delete members from group
- deleting messages from group
- muting audio and video tracks
Application is based on microservices and it is horizontally scallable.
This application consists of:
- user-service - REST service handling user profiles (profile pictures), registration, login, logout and password reset.
- email-service - gRPC service to which user-service connects. Is sends verification and reset password emails.
- token-service - gRPC service working with redis to store and handle tokens.
- group-service - REST service handling chat groups, invites to them and user rights in context of a group.
- message-service - REST service for obtaining and deleting messages, it also handles file uploads.
- ws-service - WS service working with websocket connections (uses REST to establish them).
- search-service - REST service working with elasticsearch to query user index to implement 3-gram analyzer for user search recommendations.
- webrtc-service - service responsible for videocalling functionality.
- webrtc-gateway-service - a dedicated service responsible for connecting user to instance of webrtc-service that handles room he requested. For performance reasons, one room is always assigned to one webrtc-service instance.
- frontend - React frontend for application
Application makes use of multiple database technologies like MySQL, ElasticSearch and Redis. It also uses DigitalOcean Spaces as a file storage and Apache Kafka as a message broker. Tech in use:
The whole backend structure of application presents itself like so:
For application to be horizontally scallable stateful parts of our system like ws-service instances had to overcome their scalability issues. To achieve synchronization across ws-service instances every instance becomes Kafka consumer (when other services use Kafka for updating their database, they form collective Consumer Group),
The same applies for webrtc-service, although in this case to make application more effective, other approach was used. New service called WebRTC-Gateway-Service was build to enable
### File uploading with presigned urls To protect application from sending files too many times it is send straight forward from React application with use of so called pre-signed URLs. They are generated by backend appliaction and sent on user demand for the exact file that user specified (user has to provide file name and size when generating URL). when message is sent through websocket it only contains identifiers of files that are already uploaded to Spaces. ![Sending files](./images/file_upload)