
- Set up project structure with FastAPI and SQLite - Create database models for inventory management - Set up SQLAlchemy and Alembic for database migrations - Create initial database migrations - Implement CRUD operations for products, categories, suppliers - Implement stock movement tracking and inventory management - Add authentication and user management - Add API endpoints for all entities - Add health check endpoint - Update README with project information and usage instructions
Small Business Inventory Management System
A RESTful API for small business inventory management built with FastAPI and SQLite.
Features
- User Authentication: Secure login and role-based access control
- Product Management: Add, update, and remove products with detailed information
- Category and Supplier Management: Organize products by categories and suppliers
- Inventory Tracking: Monitor stock levels and receive alerts for low stock
- Stock Movement Tracking: Record purchases, sales, returns, and inventory adjustments
- Search Functionality: Search for products, categories, and suppliers
Technical Stack
- Backend: FastAPI (Python)
- Database: SQLite
- ORM: SQLAlchemy
- Migrations: Alembic
- Authentication: JWT (JSON Web Tokens)
API Endpoints
Authentication
POST /api/v1/login/access-token
- Get access tokenPOST /api/v1/login/test-token
- Test token validity
Users
GET /api/v1/users/
- List all users (admin only)POST /api/v1/users/
- Create a new user (admin only)GET /api/v1/users/me
- Get current user informationPUT /api/v1/users/me
- Update current user informationGET /api/v1/users/{user_id}
- Get specific user informationPUT /api/v1/users/{user_id}
- Update specific user (admin only)
Products
GET /api/v1/products/
- List all productsPOST /api/v1/products/
- Create a new productGET /api/v1/products/{product_id}
- Get specific productPUT /api/v1/products/{product_id}
- Update specific productDELETE /api/v1/products/{product_id}
- Delete specific product (admin only)GET /api/v1/products/by-category/{category_id}
- Get products by categoryGET /api/v1/products/by-supplier/{supplier_id}
- Get products by supplierGET /api/v1/products/search/
- Search productsGET /api/v1/products/low-stock/
- Get products with low stock
Categories
GET /api/v1/categories/
- List all categoriesPOST /api/v1/categories/
- Create a new categoryGET /api/v1/categories/{category_id}
- Get specific categoryPUT /api/v1/categories/{category_id}
- Update specific categoryDELETE /api/v1/categories/{category_id}
- Delete specific category (admin only)GET /api/v1/categories/search/
- Search categories
Suppliers
GET /api/v1/suppliers/
- List all suppliersPOST /api/v1/suppliers/
- Create a new supplierGET /api/v1/suppliers/{supplier_id}
- Get specific supplierPUT /api/v1/suppliers/{supplier_id}
- Update specific supplierDELETE /api/v1/suppliers/{supplier_id}
- Delete specific supplier (admin only)GET /api/v1/suppliers/search/
- Search suppliers
Stock Movements
GET /api/v1/stock-movements/
- List all stock movementsPOST /api/v1/stock-movements/
- Create a new stock movementGET /api/v1/stock-movements/{stock_movement_id}
- Get specific stock movementGET /api/v1/stock-movements/by-product/{product_id}
- Get stock movements by productGET /api/v1/stock-movements/by-type/{movement_type}
- Get stock movements by type
Health Check
GET /health
- Check API health status
Installation and Setup
-
Clone the repository:
git clone <repository-url> cd smallbusinessinventorymanagementsystem
-
Install dependencies:
pip install -r requirements.txt
-
Run the application:
uvicorn main:app --reload
-
Access the API documentation:
- Swagger UI: http://localhost:8000/docs
- ReDoc: http://localhost:8000/redoc
Database Migrations
Initialize and apply database migrations:
alembic upgrade head
Creating a Superuser
To create an admin user, use the following API endpoint:
POST /api/v1/users/
With the payload:
{
"email": "admin@example.com",
"username": "admin",
"password": "your-secure-password",
"is_superuser": true
}
License
This project is licensed under the MIT License - see the LICENSE file for details.
Description
Languages
Python
99.1%
Mako
0.9%