Automated Action e8172f2bc2 Implement complete FastAPI inventory management system
- Set up project structure with FastAPI and SQLite
- Created database models for users, categories, suppliers, items, and stock transactions
- Implemented Alembic for database migrations with proper absolute paths
- Built comprehensive CRUD operations for all entities
- Added JWT-based authentication and authorization system
- Created RESTful API endpoints for all inventory operations
- Implemented search, filtering, and low stock alerts
- Added health check endpoint and base URL response
- Configured CORS for all origins
- Set up Ruff for code linting and formatting
- Updated README with comprehensive documentation and usage examples

The system provides complete inventory management functionality for small businesses
including product tracking, supplier management, stock transactions, and reporting.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-06-18 10:55:22 +00:00

37 lines
1.1 KiB
Python

from datetime import timedelta
from typing import Any
from fastapi import APIRouter, Depends, HTTPException, status
from sqlalchemy.orm import Session
from app.core import security
from app.core.config import settings
from app.crud import user as user_crud
from app.db.session import get_db
from app.schemas.user import UserLogin
router = APIRouter()
@router.post("/login")
def login_access_token(
db: Session = Depends(get_db), form_data: UserLogin = None
) -> Any:
user = user_crud.authenticate(
db, email=form_data.email, password=form_data.password
)
if not user:
raise HTTPException(
status_code=status.HTTP_401_UNAUTHORIZED,
detail="Incorrect email or password",
)
elif not user_crud.is_active(user):
raise HTTPException(
status_code=status.HTTP_401_UNAUTHORIZED, detail="Inactive user"
)
access_token_expires = timedelta(minutes=settings.ACCESS_TOKEN_EXPIRE_MINUTES)
return {
"access_token": security.create_access_token(
user.email, expires_delta=access_token_expires
),
"token_type": "bearer",
}