This book is a complete zero-to-hero guide to the FARM stack. The author took the time to break down React hooks, FastAPI routes and file structure, and MongoDB to the point that someone from a non-programming background can understand it and get up and running.
Eleke Great, Technical Reviewer
Probably the best way to start using a new technology, or a new stack - a blend of technologies - is by using it. I have written this book with a particular reader in mind: myself.
While this is by no means a comprehensive guide to MongoDB or React - two mainstream technologies that have been around for some time, the book has another protagonist - fastAPI, a relatively young, but already mature and battle tested Python-based asynchronous framework for building applications.
The book takes a practical approach and tries to introduce the parts of the stack in a simple and straightforward way, while gradually presenting features - MongoDB queries, drivers, simple React Hooks, the FastAPI way of performing standard and not-so-standard web development tasks.
The book is aimed at giving the readers a basic, yet thorough understanding of the FARM stack components and of the possibilities offered by the framework.
Here is a brief rundown of the chapters.
We try to make a case for this partticular type of stack - comparing the FARM stack and its components to other, more popular, alternatives. And it makes sense!
A rather thourough look at MongoDB - what it is, why it is almost perfect for some types of solutions and why it might not be the best fit for others.
It is time to meet FastAPI - the coolest and brightest Python framework of our time! FastAPI shouldn't be intimidating after this one!
React is a the UI library - we go over what React achieves, the basic syntax, JSX and the creation of components and how to set up a new project, we talk a bit about two of the most popular and arguably most important Hooks - the useState and the useEffect.
We begin building a very simple but full-fledged API: we start by setting up MongoDB, we create an instance of FastAPI and then we create our routes. Finally we deploy our app.
Now that we have a backend, it is time to connect it to a frontend. A React application featuring Tailwind CSS (our CSS framework of choice) and the latest version of the React Router - version 6.
JWT tokens are a very popular solution and although we develop a rather simple variation of a JWT-based authentication system the chapter should give you enough information so that in the future you can dive into JWT systems in other frameworks.
Here we tackle different real-life web development problems in a fun way!
This is probably my favourite chapter, and certainly the one I've had the most fun writing.
You will get to know SWR - a better way of fetching data, Chart.js, an excellent charting library that hits a sweet spot between ease of use and customizability. We also get to send some emails, create documents and other fun stuff!
It's time to deploy our analytics app on an Ubuntu Server - Uvicorn, Nginx, Netlify, Redis.
To close things off, the chapter includes some creative ideas for you (and me!) to test your FARM stack knowledge and creativity.
The GitHub repo for the book is located at this link and it should be updated with some additional info. Please do not hesitate to let me know if you find errors, small ones, big ones or ways to make the code more illustrative or concise.
Writing really boils down to two things: what to write about and what to omit. This book is pretty opinionated and doesn't include some topics that you would maybe expect to find in a FastAPI book, so I think that it is only fair to mention what is not covered:
I have tried to use modern and up to date technologies that enable developers and alike to quickly get up and running. FastAPI is an excellent newcomer into the React / MongoDB stacks (MERN, MEAN, PERN) and I really believe that developers could benefit from the inclusion of the Python ecosystem through an async communication.
Where possible, I have tried to include simple and free or at least very cheap solutions, since I am a firm believer in the try-before-you-buy philosophy. I have intentionally ommited complex deployment solutions based on Docker containers and the "big" platforms (Azure, Google App Engine), since in most cases, especially if you are working with some smaller, in-house, application, you will want to deploy early and quickly, hopefully with minimal payment requirements. Unfortunately, in the brief weeks between the writing of the book and the publishing, Heroku seems to have ceased to provide its free service, but that should not be a game-changer or prevent you from diving into the stack.
Hello! My name is Marko Aleksendrić and I am the author of this book. I am a graduate of the University of Belgrade, Serbia, with a PhD and also a Master’s degree in Control Engineering. I am a self-taught full-stack developer and former scientist and I work as an analyst in a trade promotion agency.
I started my programming journey with Visual Basic and Fortran 77 for numeric simulations. Upon discovering Python (version 2.3), I started using it for all kinds of automation tasks: building reporting pipelines and exporting measurement data from instruments into Excel or similar user friendly or unfriendly reporting tools. Nowadays, I split my time between consulting and analytics, full-stack web development, and data visualization.
My interests include web development, data science, JAM stack technologies and data visualization and I have more than 20 years of experience with Python and the WWW.