1-1 instant messaging project designed to demonstrate WebSockets in a load-balanced environment. Users can register, login/logout, see a friendslist, private message, and send/receive notifications. WebSocket usages include user presence monitoring, notifications, and chat messages.
- Backend: Java 8 with Spring Boot
- Frontend: Angular.js
- Message Broker: RabbitMQ (PubSub pattern for multi-server messaging)
- Database: MySQL
- ORM: Hibernate
- WebSocket messaging protocol: Stomp
- WebSocket handler: Sock.js (with cross-browser fallbacks)
- Session Management: Spring Session Redis (works cross-server)
- Security: Spring Security
- Spring Controllers couple REST as well as WebSocket traffic
- Fractal Design
- Install system dependencies: latest versions (at the time of this writing) of Java, MySQL, Redis, RabbitMQ, Node, NPM
- Install RabbitMQ Stomp plugin:
$ sudo rabbitmq-plugins enable rabbitmq_stomp - Update
src/main/resources/application.propertieswith your MySQL credentials and port - Execute
src/main/java/org/privatechat/shared/database/createDatabase.sqlto create the database - Execute
src/main/java/org/privatechat/shared/database/seedDatabase.sqlto seed the database with some users (passwords are bcrypted, but they are all "testtest") cdtosrc/main/resources/and run$ sudo npm install && gulpcdto root of the project and execute$ mvn spring-boot:runor ($ mvn spring-boot:run -Drun.jvmArguments='-Dserver.port={{your port here}}'if you wish to run a few servers)- Visit http://localhost:8080/
- Chat messages are persisted to the database, notifications are not. Will add that functionality later.
- Uncomment
devtoolsdependency inpom.xmlfor live reloading in development - Notifications must be subscribed to in unique per-user channels. Despite enabling the
/usermessage broker prefix, Spring'sconvertAndSendToUser(...)failed to update all nodes of a notification message transmission. Going to post a SO question soon! - Friendlist feature is just every user in the database other than the current user (simple feature for demo, not meant to be realistic)
- Chat messages are
LIMITed by 100
- Separate out
index.jsfile into smaller services/configs - Persist notifications
- Figure out how to have Spring Security return a custom UserDTO on
/login. Currently, after login, a call to/api/user/requesting/infois made and thePrincipalcontext drives the rest. Not elegant. - Refactor
usertableisPresent(boolean) to benumberOfConnections(int). - Implement notification emailer when recieving user is offline (batch up notifications in a time window)
- Implement auto-logout timer on frontend
- Implement smart pagination of messages on the frontend
- Implement a UUID for notifications topics subscription (currently using user id, which is unsecure)
- Wire up CSRF tokens with Spring Security
- ChatService.getExistingChatMessages(...) currently reverses the
List<ChatMessageDTOcollection because the query needs some attention. - Handle frontend exception when requested chat user doesn't exist on the frontend
- Clean up hacky notifications SCSS
- Improve the way global error handler intercepts HTTPs responses
- Switch all e.printStackTrace to use the logger
MIT