This FastAPI Cookiecutter template provides a predefined project structure based on the company's perspective. It is designed to kickstart FastAPI projects with a well-organized layout and includes common functionality that aligns with the company's development practices. This template requires Python >=3.11 and installed cookiecutter package to streamline the project setup process.
Before using this template, make sure you have the following requirements met:
-
Python 3.11: Ensure that you have Python 3.11 installed on your development machine. You can download the latest version from the official Python website: python.org
-
Cookiecutter: Install Cookiecutter globally on your system. Cookiecutter is a command-line utility that creates projects from project templates. To install Cookiecutter, run the following command:
pip install cookiecutter
To generate a new FastAPI project using this Cookiecutter template, follow these steps:
-
Open a terminal or command prompt.
-
Change to the directory where you want to create your project.
-
Run the following command, replacing
project-name
with the desired name of your project:cookiecutter https://github.com/MentorMate/mentormate-fast-api-cookiecutter-template.git
This command will initiate the project generation process.
-
You will be prompted to enter some details such as project name, author name, and other relevant information. Fill in the required information as prompted.
-
Once you've provided all the required information, Cookiecutter will create the project structure based on the template and generate the necessary files.
-
Navigate to the newly created project directory:
cd project-name
Note: Cookiecutter has automatically created a virtual environment for your project and installed the necessary dependencies. You don't need to create a separate virtual environment or install dependencies manually.
You can choose to run the project using either Docker Compose or a web server application from the terminal.
-
To start the project with Docker Compose, ensure that Docker is installed on your machine. Then, run the following command:
docker-compose up
This will build the Docker containers and start the project.
-
Alternatively, if you prefer to run the project as an application from the terminal, use the following command:
python hypercorn src.main:app --reload --bind 0.0.0.0:8000
This command will start the project's development server, and you can access the application by visiting http://localhost:8000/ in your web browser.
Choose the method that best fits your development environment and requirements.
-