Developing a Real-Time Taxi App with Django Channels and React

Learn how to develop and test a real-time ride-sharing app with Django Channels, React, and Cypress!

In this course, you'll learn how to create a ride-sharing application that incorporates a React frontend with a Django backend in a Docker container. The focus of this course is the real-time communication between client and server. We'll be using Django Channels and Redis to send and receive JSON messages over an open WebSockets connection.

Another important aspect of these chapters is Test-Driven Development (TDD). Each step of the way, we'll demonstrate how to test both the UI and the APIs.

Learning Objectives

By the end of this course, you will be able to:

Part 1

  1. Create a RESTful API with Django REST Framework.
  2. Implement token-based authentication with JSON Web Tokens (JWT).
  3. Use Django Channels to create and update data on the server.
  4. Send messages to the UI from the server via WebSockets.
  5. Test asyncio coroutines with pytest.

Part 2

  1. Create a React app from scratch using Create React App.
  2. Make functional React components that use React Hooks.
  3. Configure routing to navigate between different views in your app.
  4. Write unit and end-to-end tests with Cypress to confirm your code is working as expected.
  5. Mock AJAX requests with Cypress.
  6. Implement Bootstrap to polish the look-and-feel of your UI.
  7. Code forms that send data to the server asynchronously.
  8. Run the server and the client as Docker services.
  9. Employ authentication so end users can sign up, log in, and log out of the application.

Part 3

  1. Perform side effects in React functional components with the Effect Hook (useEffect).
  2. Use WebSockets in React.
  3. Add toast notification messages to React.
  4. Integrate the Google Maps API into a React application.

What will you build?

Django app: We'll configure user authentication and authorization with core Django, coordinate two-way messaging with Django Channels and Redis, and construct a RESTful API with Django REST Framework.

React app: We'll build an number of React components, using React Hooks, and control the flow with routing; communicate with the backend using WebSockets, React services, and reactive programming; and leverage third-party apps like Google Maps to bolster the user experience.



  • Current version: 2.0.1
  • Last updated: January 6th, 2021
  • AuthorJason Parent

What will you learn?

Part 1

In Part 1, you'll learn how to program the server code of the ride-sharing application. We'll start by developing a custom user authentication model and data profile. Then we'll create a data model to track the trips that the riders and drivers participate in along with the APIs that provide access to that data. Lastly, we'll leverage the asynchronous nature of Django Channels to send and receive messages via WebSockets. Throughout this part, we'll be testing every function to make sure that the code we write operates the way we expect it to.

Tools and Technologies: (Asynchronous) Python, Django, Django REST Framework, Django Channels, Redis, PostgreSQL, JSON Web Tokens (JWTs), pytest

Part 2

In Part 2, you'll take the first steps in setting up the user interface for the app. We'll start by creating a React frontend application. Using JSX, we'll write components and services to complement the authentication APIs that allow users to sign up, log in, and log out. Again, we'll make sure to test our application along the way, this time using the Cypress end-to-end testing framework. Before we end this part, you'll learn how to run both the frontend and backend in a single Docker container.

Tools and Technologies: React, Cypress, Docker, React Hooks

Part 3

In Part 3, you'll finish coding the frontend and stitch the UI together with the server APIs. Continuing where we left off in Part 2, we'll expand our UI to build two dashboards -- one for the rider and one for the driver. Here, we'll also create the JSX code necessary for establishing a WebSockets connection with the server and subscribing to it. Along with manual testing, we'll test the real-time nature of the app through automated tests. We'll also incorporate Google Maps so that users can visualize their current locations and the addresses they input.

Tools and Technologies: (Asynchronous) Python, Django, Django Channels, React, Cypress, WebSockets, Google Maps, Geolocation, React Hooks

Table of Contents

Table of contents from Developing a Real-Time Taxi App with Django Channels and React:

Part 1
Part 2
  • Introduction
  • React Setup
  • React Routing
  • Cypress Testing
  • React Bootstrap
  • React Forms
  • HTTP Requests - Log In and Out
  • HTTP Requests - Sign up
  • Docker
  • Cypress Refactor
  • Conclusion
Part 3
  • Introduction
  • The User
  • Loading Trips
  • Testing Loading Trips
  • Loading Trip Details
  • Ride Requests
  • Updating Trips
  • Pop-Up Alerts
  • Google Maps
  • Conclusion

Join our mailing list to be notified about course updates and new tutorials.