Backend for managing company inventory: devices, employees, and device assignments.
- Device management (create, update location, delete, detailed view)
- Employee management (create, admin role changes, device ownership)
- JWT auth (access + refresh tokens)
- FastAPI
- SQLAlchemy
- PostgreSQL
- Docker
docker-compose up --buildpython -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
uvicorn src.api:app --host 0.0.0.0 --port 8000Copy the example env file and update values:
cp .env.example .envEnvironment variables:
- POSTGRES_USER
- POSTGRES_PASSWORD
- POSTGRES_DB
- JWT_SECRET_KEY
- JWT_ALGORITHM
- ACCESS_TOKEN_EXPIRE_MINUTES
- REFRESH_TOKEN_EXPIRE_MINUTES
- ADMIN_USERNAME
- ADMIN_PASSWORD
- ADMIN_CREATE_ENABLED
- ADMIN_EMAIL
- ADMIN_FIRST_NAME
- ADMIN_LAST_NAME
- ADMIN_PHONE_NUMBER
Optional:
- INVENTORY_DB_URL (overrides the Postgres connection string)
Admin auto-create (optional):
- If
ADMIN_CREATE_ENABLED=true, andADMIN_USERNAME/ADMIN_PASSWORDare set, the app creates the admin user on startup.
POST /auth/login(form data:username,password)- Use
Authorization: Bearer <access_token>for protected endpoints
curl -X POST http://localhost:8000/auth/login \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "username=admin&password=your_password"pytest- TODO: Alembic migrations, additional API tests, and input validation hardening
