How to build a real-time chat app
Create a real time chat application that utilises some of the most cutting edge front end technology available today.
Messaging Angular app source code
Messaging GraphQL api source code
What we're going to build
Follow this tutorial to build a real-time chat application. Once you download and install the Slack application to your PC, laptop and/or phone devices, allow anyone using the web-based chat app to instantly message you and get notified immediately through any of the downloaded Slack apps on your devices.
The best part is it's completely free. You don't have to make a purchase to complete this tutorial.
Contents
- Part 1: App setup
- Part 2: Setup GraphQL with Apollo Server
- Part 3: Retrieve a list of messages from Slack to build a GraphQL query
- Part 4: Display a list of messages with Angular
- Part 5: Use a GraphQL query to populate a list of messages in an Angular component
- Part 6: Create and POST a new message using a GraphQL Mutation
- Part 7: Create an Angular component to send a message to the GraphQL API
- Part 8: Create a GraphQL Subscription to send real-time message
- Part 9: Integrate GraphQL Subscriptions into Angular components to build a list of messages
- Part 10: Animate new incoming messages in an Angular component
Technology stack
- Angular 8 (Front end app framework)
- Apollo (State management)
- GraphQL (Data schema)
- Slack API & SDK (Third party services and installable applications)
Overview of concepts
A brief introduction to some core concepts. Feel free to skip ahead if you are familiar with some of the following concepts. If you aren't familiar with these, I highly recommend reading through each to understand the underlying strategies that the frameworks in this tutorial are based on. This will help in understanding the motivations behind each approach.
Read about Redux data flow architecture
Overview: GraphQL API schemas and the redux data store
State in applications can be managed via a Redux data store. GraphQL is concerned with defining the types of data that can be held in the Redux store. A GraphQL schema will define the shape of objects that need to be created and sent to the client (web-browser) from the server. Typically just one endpoint is needed for GraphQL to serve all types of data.
A customised request can be sent from the client to the GraphQL endpoint. This empowers applications to retrieve all data needed in one concise asynchronous request, which maps very well to user events. GraphQL will then analyse the request and attempt to start building a response that fulfills the description of data specified in the request. Data can be retrieved from a database, session, another service or multiple services to build a normalised response Graph for clients to consume. The great thing is that the shape of a response is purposefully designed to look very similar to the shape of the request it was responding to.
Things you'll need:
Prior knowledge
- Basic knowledge of HTML, CSS & CSS preprocessors
- A fair grasp of Javascript fundamentals. Further reading - Speaking Javascript by Dr. Axel Rauschmayer
- If you haven't written a web app using Angular before, I recommend following the "Tour of heroes" tutorial from the official Angular website first.
Software
- NodeJS version 10 or later
- A text editor such as Visual Studio Code, Sublime or Webstorm
- Slack messaging app(s) to test our work. Installed to your phone and/or laptop