Skip to content

Commit d36b35a

Browse files
committed
Commit
1 parent c67c676 commit d36b35a

File tree

1 file changed

+148
-59
lines changed

1 file changed

+148
-59
lines changed

β€ŽREADME.md

Lines changed: 148 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,87 +1,176 @@
1-
# πŸ›οΈ Flask MongoDB Product API
1+
# NOSQL-MONGO-FLASK-PYMONGO-RESTAPI-METHODS-CRUD
22

3-
A lightweight and scalable RESTful API built with **Flask** and **MongoDB**, designed for managing products using clean CRUD operations. Ideal for learning backend architecture, REST principles, and NoSQL integration.
3+
![GitHub release](https://img.shields.io/github/release/Lehuuuuuuuu/NOSQL-MONGO-FLASK-PYMONGO-RESTAPI-METHODS-CRUD.svg) ![License](https://img.shields.io/github/license/Lehuuuuuuuu/NOSQL-MONGO-FLASK-PYMONGO-RESTAPI-METHODS-CRUD.svg)
44

5-
---
5+
## Overview
66

7-
## πŸ“Œ Table of Contents
7+
Welcome to the **NOSQL-MONGO-FLASK-PYMONGO-RESTAPI-METHODS-CRUD** repository! This project offers a fully functional REST API built with Flask and MongoDB. It is designed for managing product data with clean CRUD (Create, Read, Update, Delete) operations. The architecture is modular and supports both query and path parameters, making it suitable for real-world applications.
88

9-
1. [Features](#-features)
10-
2. [Tech Stack](#-tech-stack)
11-
3. [Getting Started](#-getting-started)
12-
4. [API Endpoints](#-api-endpoints)
13-
5. [Project Structure](#-project-structure)
14-
6. [Contributing](#-contributing)
15-
7. [Author](#-author)
9+
### Features
1610

17-
---
11+
- **CRUD Operations**: Implemented cleanly and efficiently.
12+
- **Modular Structure**: Easy to maintain and expand.
13+
- **Query/Path Parameter Support**: Flexible API for various needs.
14+
- **Professional Backend Architecture**: Suitable for production use.
1815

19-
## πŸš€ Features
16+
### Technologies Used
2017

21-
- βœ… Full REST API using Flask Blueprint
22-
- βœ… CRUD operations with MongoDB (via PyMongo)
23-
- βœ… Handles both query and path parameters
24-
- βœ… ObjectId and numeric ID support
25-
- βœ… Modular code: routes, models, DB connection separated
26-
- βœ… Environment-based config with `.env`
27-
- βœ… Built-in validation and error handling
18+
- **Flask**: A lightweight WSGI web application framework.
19+
- **MongoDB**: A NoSQL database for storing product data.
20+
- **PyMongo**: A Python driver for MongoDB.
21+
- **RESTful Principles**: Ensures the API is stateless and scalable.
2822

29-
---
23+
### Topics
3024

31-
## 🧰 Tech Stack
25+
This repository covers a variety of topics, including:
3226

33-
- **Language:** Python 3.10+
34-
- **Framework:** Flask
35-
- **Database:** MongoDB (NoSQL)
36-
- **Driver:** PyMongo
37-
- **Environment Config:** `python-dotenv`
38-
- **Testing:** Postman / Curl
39-
- **Tooling:** Git, VSCode, pip
27+
- backend-api
28+
- crud
29+
- crud-api
30+
- crud-application
31+
- crud-operation
32+
- database
33+
- flask-api
34+
- flask-application
35+
- flask-restful
36+
- mongodb
37+
- mongodb-atlas
38+
- nosql-database
39+
- queryparameters
40+
- rest-api
41+
- routing
4042

41-
---
43+
## Getting Started
44+
45+
To get started with this project, you will need to have Python and MongoDB installed on your machine. Follow these steps to set up the project:
46+
47+
### Prerequisites
48+
49+
1. **Python**: Make sure you have Python 3.x installed. You can download it from [python.org](https://www.python.org/downloads/).
50+
2. **MongoDB**: Install MongoDB. You can find the installation guide [here](https://docs.mongodb.com/manual/installation/).
51+
3. **Virtual Environment**: It's recommended to create a virtual environment for your project.
52+
53+
### Installation
54+
55+
1. **Clone the Repository**:
56+
57+
```bash
58+
git clone https://github.com/Lehuuuuuuuu/NOSQL-MONGO-FLASK-PYMONGO-RESTAPI-METHODS-CRUD.git
59+
cd NOSQL-MONGO-FLASK-PYMONGO-RESTAPI-METHODS-CRUD
60+
```
61+
62+
2. **Set Up a Virtual Environment**:
63+
64+
```bash
65+
python -m venv venv
66+
source venv/bin/activate # On Windows use `venv\Scripts\activate`
67+
```
68+
69+
3. **Install Dependencies**:
70+
71+
```bash
72+
pip install -r requirements.txt
73+
```
74+
75+
### Configuration
76+
77+
1. **MongoDB Connection**: Update the MongoDB connection string in the configuration file. You can use MongoDB Atlas or a local MongoDB instance.
78+
79+
2. **Environment Variables**: Set any necessary environment variables, such as your database URI.
80+
81+
### Running the Application
82+
83+
To run the application, execute the following command:
84+
85+
```bash
86+
flask run
87+
```
88+
89+
Your API will be available at `http://127.0.0.1:5000`.
90+
91+
### API Endpoints
92+
93+
The API provides several endpoints for managing product data:
94+
95+
- **Create a Product**: `POST /products`
96+
- **Get All Products**: `GET /products`
97+
- **Get a Product by ID**: `GET /products/<id>`
98+
- **Update a Product**: `PUT /products/<id>`
99+
- **Delete a Product**: `DELETE /products/<id>`
100+
101+
### Example Usage
102+
103+
You can use tools like Postman or curl to interact with the API. Here are some example requests:
104+
105+
1. **Create a Product**:
106+
107+
```bash
108+
curl -X POST http://127.0.0.1:5000/products -H "Content-Type: application/json" -d '{"name": "Product1", "price": 100}'
109+
```
110+
111+
2. **Get All Products**:
112+
113+
```bash
114+
curl http://127.0.0.1:5000/products
115+
```
42116

43-
## βš™οΈ Getting Started
117+
3. **Get a Product by ID**:
118+
119+
```bash
120+
curl http://127.0.0.1:5000/products/<id>
121+
```
122+
123+
4. **Update a Product**:
124+
125+
```bash
126+
curl -X PUT http://127.0.0.1:5000/products/<id> -H "Content-Type: application/json" -d '{"name": "Updated Product", "price": 150}'
127+
```
128+
129+
5. **Delete a Product**:
130+
131+
```bash
132+
curl -X DELETE http://127.0.0.1:5000/products/<id>
133+
```
134+
135+
### Testing
136+
137+
You can run tests using the built-in test suite. Make sure to have your virtual environment activated, then run:
44138

45-
### 1️⃣ Clone the Repository
46139
```bash
47-
git clone https://github.com/your-username/flask-mongo-api.git
48-
cd flask-mongo-api
140+
pytest
49141
```
50142

51-
## 2️⃣ Create Virtual Environment
143+
### Documentation
144+
145+
For detailed API documentation, please refer to the [Releases section](https://github.com/Lehuuuuuuuu/NOSQL-MONGO-FLASK-PYMONGO-RESTAPI-METHODS-CRUD/releases). Here you can find the latest updates, features, and changes.
52146

53-
python -m venv venv
54-
source venv/bin/activate # Windows: venv\Scripts\activate
147+
### Contribution
55148

149+
Contributions are welcome! If you would like to contribute to this project, please follow these steps:
56150

57-
## πŸ”— API Endpoints
151+
1. Fork the repository.
152+
2. Create a new branch for your feature or bug fix.
153+
3. Make your changes.
154+
4. Submit a pull request.
58155

59-
- πŸ“„ Get All Products
60-
- πŸ” Get Product by ID (Path)
61-
- βž• Create Product (Query Params)
62-
- πŸ” Update Entire Product (PUT - Query Params)
63-
- 🩹 Partial Update (PATCH - Query Params)
64-
- ❌ Delete Product (Path Param)
156+
### License
65157

158+
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
66159

67-
## πŸ—‚ Project Structure
160+
### Acknowledgments
68161

69-
![image](https://github.com/user-attachments/assets/53153400-86e8-4837-9e29-6e59ac707b7a)
162+
- **Flask Documentation**: [Flask](https://flask.palletsprojects.com/)
163+
- **MongoDB Documentation**: [MongoDB](https://docs.mongodb.com/)
164+
- **PyMongo Documentation**: [PyMongo](https://pymongo.readthedocs.io/)
70165

166+
### Contact
71167

72-
## 🀝 Contributing
73-
### Pull requests are welcome!
74-
### To contribute:
168+
For any inquiries, please reach out to the repository owner via GitHub.
75169

76-
- Fork the repository
77-
- Create a new branch (git checkout -b feature/your-feature)
78-
- Commit your changes (git commit -m 'Add new feature')
79-
- Push the branch (git push origin feature/your-feature)
80-
- Open a Pull Request πŸš€
170+
### Links
81171

172+
- Visit the [Releases section](https://github.com/Lehuuuuuuuu/NOSQL-MONGO-FLASK-PYMONGO-RESTAPI-METHODS-CRUD/releases) for downloadable files and execution instructions.
173+
174+
---
82175

83-
### πŸ‘¨β€πŸ’» Author
84-
Sikandar Khan
85-
πŸ“§ sikandaraidev@gmail.com
86-
🌐 LinkedIn: https://www.linkedin.com/in/sikandaraidev/
87-
πŸ’Ό AI Engineer | Backend Developer
176+
Feel free to explore the code, make improvements, and enjoy building your applications with this robust REST API!

0 commit comments

Comments
Β (0)