aboutsummaryrefslogtreecommitdiff
path: root/inventory-service/app/api
diff options
context:
space:
mode:
Diffstat (limited to 'inventory-service/app/api')
-rw-r--r--inventory-service/app/api/deps.py10
-rw-r--r--inventory-service/app/api/v1/api.py9
-rw-r--r--inventory-service/app/api/v1/endpoints/products.py54
-rw-r--r--inventory-service/app/api/v1/endpoints/stock_movements.py47
4 files changed, 120 insertions, 0 deletions
diff --git a/inventory-service/app/api/deps.py b/inventory-service/app/api/deps.py
new file mode 100644
index 0000000..d8dd349
--- /dev/null
+++ b/inventory-service/app/api/deps.py
@@ -0,0 +1,10 @@
+from typing import Generator
+from app.core.database import SessionLocal
+
+
+def get_db() -> Generator:
+ db = SessionLocal()
+ try:
+ yield db
+ finally:
+ db.close()
diff --git a/inventory-service/app/api/v1/api.py b/inventory-service/app/api/v1/api.py
new file mode 100644
index 0000000..b5d56d3
--- /dev/null
+++ b/inventory-service/app/api/v1/api.py
@@ -0,0 +1,9 @@
+from fastapi import APIRouter
+from app.api.v1.endpoints import products, stock_movements
+
+api_router = APIRouter()
+
+api_router.include_router(products.router, prefix="/products", tags=["products"])
+api_router.include_router(
+ stock_movements.router, prefix="/stock-movements", tags=["stock-movements"]
+)
diff --git a/inventory-service/app/api/v1/endpoints/products.py b/inventory-service/app/api/v1/endpoints/products.py
new file mode 100644
index 0000000..2e5a2b5
--- /dev/null
+++ b/inventory-service/app/api/v1/endpoints/products.py
@@ -0,0 +1,54 @@
+from fastapi import APIRouter, Depends, status
+from sqlalchemy.orm import Session
+from typing import List
+
+from app.api import deps
+from app.schemas.inventory import ProductCreate, ProductUpdate, ProductOut
+
+
+router = APIRouter()
+
+
[email protected]("/", response_model=ProductOut, status_code=status.HTTP_201_CREATED)
+def create_product(product_in: ProductCreate, db: Session = Depends(deps.get_db)):
+ """
+ Register a new product with an initial stock level.
+ """
+ pass # TODO: implement
+
+
[email protected]("/", response_model=List[ProductOut])
+def list_products(skip: int = 0, limit: int = 100, db: Session = Depends(deps.get_db)):
+ """
+ Return a paginated list of all products and their current stock levels.
+ """
+ pass # TODO: implement
+
+
[email protected]("/{product_id}", response_model=ProductOut)
+def get_product(product_id: int, db: Session = Depends(deps.get_db)):
+ """
+ Return a single product by its database ID.
+ """
+ pass # TODO: implement
+
+
[email protected]("/{product_id}", response_model=ProductOut)
+def update_product(
+ product_id: int,
+ product_in: ProductUpdate,
+ db: Session = Depends(deps.get_db),
+):
+ """
+ Partially update a product (name or stock level).
+ Useful for manual stock adjustments by warehouse staff.
+ """
+ pass # TODO: implement
+
+
[email protected]("/{product_id}", status_code=status.HTTP_204_NO_CONTENT)
+def delete_product(product_id: int, db: Session = Depends(deps.get_db)):
+ """
+ Remove a product from the inventory.
+ """
+ pass # TODO: implement
diff --git a/inventory-service/app/api/v1/endpoints/stock_movements.py b/inventory-service/app/api/v1/endpoints/stock_movements.py
new file mode 100644
index 0000000..f70396f
--- /dev/null
+++ b/inventory-service/app/api/v1/endpoints/stock_movements.py
@@ -0,0 +1,47 @@
+from fastapi import APIRouter, Depends, status
+from sqlalchemy.orm import Session
+from typing import List
+
+from app.api import deps
+from app.schemas.inventory import StockMovementOut
+
+
+router = APIRouter()
+
+
[email protected]("/", response_model=List[StockMovementOut])
+def list_stock_movements(
+ skip: int = 0,
+ limit: int = 100,
+ db: Session = Depends(deps.get_db),
+):
+ """
+ Return a paginated list of all stock movements across all products.
+ Useful for auditing the full history of reservations and releases.
+ """
+ pass # TODO: implement
+
+
[email protected]("/product/{product_id}", response_model=List[StockMovementOut])
+def list_movements_for_product(
+ product_id: int,
+ skip: int = 0,
+ limit: int = 100,
+ db: Session = Depends(deps.get_db),
+):
+ """
+ Return all stock movements for a specific product.
+ """
+ pass # TODO: implement
+
+
[email protected]("/order/{order_id}", response_model=List[StockMovementOut])
+def list_movements_for_order(
+ order_id: int,
+ db: Session = Depends(deps.get_db),
+):
+ """
+ Return all stock movements associated with a specific order.
+ Lets you see exactly what was reserved/released for a given order.
+ """
+ pass # TODO: implement