A comprehensive RESTful API for e-commerce product management built with FastAPI, React, and MongoDB.
This project demonstrates a complete e-commerce API with full CRUD operations for product management. It includes both a robust backend API and a beautiful frontend interface for managing products.
- β Complete CRUD Operations for products
- β RESTful API Design with proper HTTP methods and status codes
- β Input Validation with comprehensive error handling
- β Interactive Documentation with Swagger/OpenAPI
- β Modern Frontend Interface with React and Tailwind CSS
- β Real-time Updates and responsive design
- β Production-ready with proper logging and monitoring
- FastAPI - Modern, fast web framework for building APIs
- MongoDB - NoSQL database for flexible data storage
- Pydantic - Data validation and settings management
- Python 3.9+ - Programming language
- React - JavaScript library for building user interfaces
- Tailwind CSS - Utility-first CSS framework
- JavaScript ES6+ - Modern JavaScript features
- Docker - Containerization
- Supervisor - Process management
- Kubernetes - Container orchestration (production)
https://api.example.com/api
| Method | Endpoint | Description | Status Code |
|---|---|---|---|
GET |
/api/health |
Health check | 200 |
POST |
/api/products |
Create product | 201 |
GET |
/api/products |
List all products | 200 |
GET |
/api/products/{id} |
Get specific product | 200 |
PUT |
/api/products/{id} |
Update product | 200 |
DELETE |
/api/products/{id} |
Delete product | 204 |
GET |
/api/products/category/{category} |
Get products by category | 200 |
{
"id": "uuid-string",
"name": "string (required, 1-200 chars)",
"description": "string (required, 1-1000 chars)",
"price": "float (required, > 0)",
"category": "string (required, 1-100 chars)",
"stock_quantity": "integer (required, >= 0)",
"image_url": "string (optional)",
"created_at": "datetime",
"updated_at": "datetime"
}curl -X POST "https://api.example.com/api/products" \
-H "Content-Type: application/json" \
-d '{
"name": "Wireless Bluetooth Headphones",
"description": "Premium quality wireless headphones with noise cancellation",
"price": 129.99,
"category": "Electronics",
"stock_quantity": 50,
"image_url": "https://example.com/headphones.jpg"
}'curl -X GET "https://api.example.com/api/products"curl -X GET "https://api.example.com/api/products?skip=0&limit=10"curl -X GET "https://api.example.com/api/products/{product-id}"curl -X PUT "https://api.example.com/api/products/{product-id}" \
-H "Content-Type: application/json" \
-d '{
"price": 119.99,
"stock_quantity": 45
}'curl -X DELETE "https://api.example.com/api/products/{product-id}"curl -X GET "https://api.example.com/api/products/category/Electronics"Access the product management interface at:
https://yourapp.example.com
- Product Listing - View all products with images, prices, and stock status
- Create Products - Add new products with full form validation
- Edit Products - Update existing product information
- Delete Products - Remove products with confirmation dialogs
- Responsive Design - Works on desktop, tablet, and mobile devices
- Real-time Updates - UI updates immediately after operations
/app/
βββ backend/ # FastAPI backend
β βββ server.py # Main FastAPI application
β βββ requirements.txt # Python dependencies
β βββ .env # Environment variables
βββ frontend/ # React frontend
β βββ src/
β β βββ App.js # Main React component
β β βββ App.css # Component styles
β β βββ index.js # Entry point
β β βββ index.css # Global styles
β βββ public/ # Static assets
β βββ package.json # Node.js dependencies
β βββ tailwind.config.js # Tailwind CSS configuration
β βββ .env # Environment variables
βββ tests/ # Test files
βββ scripts/ # Utility scripts
βββ README.md # This file
Access the interactive API documentation at:
https://yourapp.example.com/docs
Get the OpenAPI JSON schema at:
https://yourapp.example.com/openapi.json
The project includes comprehensive test coverage:
- β All CRUD operations
- β Input validation and error handling
- β Edge cases and concurrent operations
- β Database integration
- β Health checks
- β Component rendering
- β Form interactions
- β API integration
- β Error handling
- β Responsive design
All tests pass successfully, confirming:
- API endpoints work correctly
- Frontend integrates seamlessly with backend
- Data persistence across operations
- Proper error handling and validation
| Code | Description |
|---|---|
200 |
Success (GET, PUT) |
201 |
Created (POST) |
204 |
No Content (DELETE) |
400 |
Bad Request (validation errors) |
404 |
Not Found (invalid ID) |
422 |
Unprocessable Entity (validation errors) |
500 |
Internal Server Error |
- Python 3.9+
- Node.js 16+
- MongoDB
- Docker (optional)
-
Backend Setup
cd backend pip install -r requirements.txt python server.py -
Frontend Setup
cd frontend yarn install yarn start -
Database Setup
- MongoDB running on
mongodb://localhost:27017 - Database name:
ecommerce_db
- MongoDB running on
Backend (.env)
MONGO_URL=mongodb://localhost:27017
DB_NAME=ecommerce_db
Frontend (.env)
REACT_APP_BACKEND_URL=https://yourapi.example.com
- Input validation with Pydantic models
- SQL injection prevention (NoSQL MongoDB)
- CORS configuration for cross-origin requests
- Proper error handling without sensitive data exposure
- UUID-based IDs (non-sequential, secure)
- Efficient MongoDB queries with indexing
- Pagination for large datasets
- Async/await for non-blocking operations
- Optimized frontend rendering with React
- CDN-ready static assets
The application is containerized and ready for production deployment:
- Docker containers for both frontend and backend
- Kubernetes configuration for scalability
- Supervisor process management for reliability
- Load balancer ready with proper health checks
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new functionality
- Submit a pull request
This project is open source and available under the MIT License.
For support and questions:
- Check the interactive API documentation at
/docs - Review the test cases for usage examples
- Examine the frontend implementation for integration patterns
Potential enhancements for this API:
- Authentication & Authorization (JWT tokens, user roles)
- Order Management (shopping cart, checkout process)
- Payment Integration (Stripe, PayPal)
- Inventory Management (low stock alerts, batch updates)
- Search & Filtering (full-text search, advanced filters)
- Image Upload (file handling, image optimization)
- Caching (Redis for improved performance)
- Rate Limiting (API usage controls)
- Monitoring (logging, metrics, alerting)
Built with β€οΈ using FastAPI, React, and MongoDB