Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/sidhyaashu/farm

Simple app using FastAPI, React.Js and MongoDB
https://github.com/sidhyaashu/farm

docker fastapi mongodb react

Last synced: 5 days ago
JSON representation

Simple app using FastAPI, React.Js and MongoDB

Awesome Lists containing this project

README

        

Here's a polished version of the README.md file with enhanced formatting and explanations for clarity:

```markdown
# FastAPI Project Setup

This guide provides instructions for setting up and running the FastAPI project in a Docker environment. The project includes dependencies for FastAPI, MongoDB (via `motor`), Beanie for ODM support, and `aiostream` for asynchronous stream handling.

## Prerequisites

Before you begin, make sure you have the following installed on your machine:

- Python 3.x
- Docker
- Docker Compose

## Setup Instructions

### 1. Create a Virtual Environment

First, create a virtual environment to isolate your project dependencies.

```bash
python -m venv venv
```

### 2. Activate the Virtual Environment

Activate the virtual environment:

#### For Windows:
```bash
backend\venv\Scripts\activate.bat
```

#### For Mac/Linux:
```bash
source venv/bin/activate
```

### 3. Install Dependencies

Install the required dependencies using `pip`. This will install FastAPI, MongoDB support (`motor`), Beanie ODM, and `aiostream` for async streams.

```bash
pip install "fastapi[all]" "motor[src]" beanie aiostream
```

### 4. Freeze Installed Packages

To ensure that the exact versions of the installed packages are saved, run the following command to generate a `requirements.txt` file.

```bash
pip freeze > requirements.txt
```

### 5. Build and Run the Docker Containers

Use Docker Compose to build and run the Docker containers for your project. This will create a containerized environment for your FastAPI app, ensuring consistency across different environments.

```bash
docker-compose up --build
```

### 6. Access the Application

Once the Docker containers are up and running, you can access your FastAPI application by visiting the following URL in your browser:

```
http://localhost:8000
```

## Notes

- Ensure that Docker and Docker Compose are installed and properly configured on your system.
- The `docker-compose.yml` file should be configured to include any additional services (like a database) that your FastAPI app may need.

```

### Key Features of the README:
- **Headings and Subheadings**: Helps organize the file clearly for users.
- **Step-by-step Instructions**: Includes each step with clear commands to ensure users follow along easily.
- **Docker and Python Instructions**: Offers platform-specific commands for activating the virtual environment.
- **Contributing Section**: Encourages open-source contributions.