feat: implement complete CMT backend with API endpoints and test suite

- Add 7 core API endpoints: users, transactions, partners, products, inventory, payments, credit
- Implement role-based authentication (admin/write/read-only access)
- Add comprehensive database models with proper relationships
- Include full test coverage for all endpoints and business logic
- Set up Alembic migrations and Docker configuration
- Configure FastAPI app with CORS and database integration
This commit is contained in:
2025-09-14 21:04:07 +02:00
parent 49c813778b
commit c086f64363
48 changed files with 6992 additions and 126 deletions
+28 -9
View File
@@ -5,11 +5,16 @@ NOTE:
-
"""
from app.core.config import settings
from typing import Union
from fastapi import FastAPI
from backend.app.api.endpoints.clients import router as clients_router
from backend.app.api.endpoints.suppliers import router as supplier_router
from backend.app.api.endpoints.products import router as product_router
from fastapi.middleware.cors import CORSMiddleware
from app.api.v1.users import router as users_router
from app.api.v1.transactions import router as transactions_router
from app.api.v1.partners import router as partners_router
from app.api.v1.products import router as products_router
from app.api.v1.transaction_details import router as transaction_details_router
from app.api.v1.payments import router as payments_router
from app.api.v1.credit import router as credit_router
from app.api.v1.inventory import router as inventory_router
app = FastAPI(
@@ -18,12 +23,26 @@ app = FastAPI(
)
# CORS for React frontend
app.add_middleware(
CORSMiddleware,
allow_origins=["http://localhost:5173"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"]
)
app.include_router(users_router, prefix=settings.api_v1_str)
app.include_router(transactions_router, prefix=settings.api_v1_str)
app.include_router(partners_router, prefix=settings.api_v1_str)
app.include_router(products_router, prefix=settings.api_v1_str)
app.include_router(transaction_details_router, prefix=settings.api_v1_str)
app.include_router(payments_router, prefix=settings.api_v1_str)
app.include_router(credit_router, prefix=settings.api_v1_str)
app.include_router(inventory_router, prefix=settings.api_v1_str)
@app.get("/")
def read_root():
"""
"""
return {"Hello": "World"}
app.include_router(clients_router, tags=["clients"])
app.include_router(supplier_router, tags=["suppliers"])
app.include_router(product_router, tags=["products"])
return {"message": "CMT API v1"}