This chatting web app supporting following features:
The technologies used by creating this web app and corresponding usage as described below:
The front end user interface is build by leveraging React.js and Redux. Thanks to functional programming paradigm encouraging by React.js and Redux, the state management, propagation of change and data flow become so easily predictable and maintainable. The development and debug tremendously benefit from the concept of immutable state and pure function of functional programming. This enable me to write less error prone code and easy to test code. Redux embrace the idea of separating of presentational and container components:
In addition to functional programming, the development of this web app also benefit from another idea of one way data flow. During development and debugging, where are current data located and where will they flow to are clear visible and predictable.
The server build by Node.js, which intrinsically is good at handling intensive high volume of IO operations. Chatting app is an ideal use case. This app use Node.js and socket.io to asynchronously handel websocket connections.
Redis control the routing of messages by leveraging Redis PUB/SUB feature. Users subscribe its own user id when connecting to node server, friends publish their messages to this specific user id, this can guarantee the receiver can always successful receive messages send from friends by this simple mechanism. Redis also used as cache of chat records. The node server will push each message received to Redis no matter receiver online or offline. These cached messages will be popped when user login, so they can see their chatting history even when they offline.
MongoDB provides semi-structured data format to store user information like username, password and friends list. The JSON like semi-structured data format are easy to read and query compared to relational database that need a lot of table join operations. MongoDB support rich queries, no complex join and easy to scale. That’s why MongoDB is one of the most favorite NoSQL database especially in era of big data and distributed computing.
Embracing functional programming in front end development is amazing and excited way of problem solving, especially in the development of massive interaction between users and user interface. Functional programming is more expressive than object-oriented or imperative programming. I will leverage the idea of functional programming throughout my future programming tasks whenever possible on my initiative.