Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pundit4real/fastapi-mongodb-crud_app
https://github.com/pundit4real/fastapi-mongodb-crud_app
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/pundit4real/fastapi-mongodb-crud_app
- Owner: Pundit4Real
- Created: 2024-02-01T20:07:51.000Z (12 months ago)
- Default Branch: main
- Last Pushed: 2024-02-16T11:48:44.000Z (11 months ago)
- Last Synced: 2024-02-16T12:41:51.629Z (11 months ago)
- Language: Python
- Size: 20.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# FastApi simple CRUD app on student details with MongoDB as the database.
This is a simple fastApi CRUD app with MongoDB integration as the database that allows for performing CRUD (create,retrieve, update, and delete) on Student information.
## Table of Contents
- [Pre-requisites](#pre-requisites)
- [Getting Started](#Getting-started)
- [Installation](#Installation)
- [Database setup](#Database-setup)
- [Running the Api](#Starting-the-server)
- [Api Endpoints](#Api-endpoints)
- [Create a student profile](#create-a-student-profile)
- [Retrieve all student](#Retriev-all-student)
- [Update a student profile](#Update-a-student-profile)
- [Delete a student profile](#Delete-a-student)
- [Limitations and Assumptions](#Limitations-and-assumptions)## Pre-requisites
Before you begin, ensure you have met the following requirements:
- Python 3.x installed.
- Pip package manager installed.
- A code editor (e.g., VSCode) for development.
- MongoDB install on your system.## Getting Started
### Installation
1. Clone the repository:
https://github.com/Pundit4Real/Fastapi-MongoDB-CRUD_app.git
2. Create a virtual environment (recommended):
python -m venv ('environment name')
3. Activate the virtual environment:
```bash
- On Windows:
venv\Scripts\activate
- On macOS and Linux:
source venv/bin/activate4. Install the required dependencies:
`pip install -r requirements.txt`
## Database Setup
With MongoDB install on your system;
create a directory called __config.__
Inside the config directory, create a file called __database.py__ which will contain all the database connection codes.Write this line of code in your database.py file to establish the connection with MongoDB server.
from pymongo import MongoClient
connection = MongoClient("mongodb://localhost:27017/student")
## Running the Api
*To start the server, run the following commands;*
uvicorn your_app_name:app --reload
or
python -m uvicorn your_app_name:app --reloadReplace your_app_name with the actual name of your FastAPI application file.
The endpoint will be available at
__http://127.0.0.1:8000/docs__## The Endpoints
### Follow the swagger ui to test the various endpoints