Overview
The FastAPI-React-MongoDB template is a minimal boilerplate project that provides a starting point for developing a web application with a Python FastAPI backend, React frontend, MongoDB database, and JWT user authentication. It includes a React frontend with the React-Bootstrap styling framework and React-Icons library, an authentication system for the FastAPI backend using JWT tokens, examples for creating protected routes and regular routes, and examples for creating MongoDB collection schemas. The template is inspired by other projects such as tiangolo’s FastAPI full stack project and Buuntu’s fastapi-react project.
Features
- FastAPI: FastAPI is used as the backend server for the web application.
- FastAPIUsers: FastAPIUsers is a Python package for backend user authentication using JWT tokens.
- React: React is used as the frontend library for building the user interface.
- React-Bootstrap: React-Bootstrap is used as the frontend styling framework.
- React-Icons: React-Icons is used as the frontend icons library.
- MongoDB: MongoDB is used as the database server for storing data.
- Motor: Motor is an async MongoDB connector for Python, used for interacting with the MongoDB database.
Installation
A. MongoDB Database
- Install MongoDB 4.4.0.
B. Python/FastAPI Backend
- Install Anaconda.
- Create a new Anaconda virtual environment using the
requirements.txtfile. - Activate the virtual environment.
- Navigate to the root directory where the
backend,database, andfrontenddirectories are located. - Install the Python packages to the virtual environment.
- Deactivate the virtual environment.
C. React Frontend
- Install Node Package Manager (npm).
- Navigate to the
/frontenddirectory where thepackage.jsonfile is located. - Install the React dependencies using npm.
Summary
The FastAPI-React-MongoDB template is a boilerplate project for getting started with a web application that combines a FastAPI backend, React frontend, MongoDB database, and JWT user authentication. It provides essential features such as authentication, protected routes, MongoDB collection schemas, and common frontend libraries like React-Bootstrap and React-Icons. The installation instructions guide users on setting up the MongoDB database, installing the necessary dependencies for the backend and frontend, and starting the servers for development.