Skip to content

Repository files navigation

Inventory API

Backend for managing company inventory: devices, employees, and device assignments.

Features

  • Device management (create, update location, delete, detailed view)
  • Employee management (create, admin role changes, device ownership)
  • JWT auth (access + refresh tokens)

Swagger Docs

Tech Stack

  • FastAPI
  • SQLAlchemy
  • PostgreSQL
  • Docker

Quick Start (Docker)

docker-compose up --build

Quick Start (Local)

python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
uvicorn src.api:app --host 0.0.0.0 --port 8000

Configuration

Copy the example env file and update values:

cp .env.example .env

Environment 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, and ADMIN_USERNAME/ADMIN_PASSWORD are set, the app creates the admin user on startup.

Authentication

  1. POST /auth/login (form data: username, password)
  2. Use Authorization: Bearer <access_token> for protected endpoints

API Examples

curl -X POST http://localhost:8000/auth/login \
	-H "Content-Type: application/x-www-form-urlencoded" \
	-d "username=admin&password=your_password"

Tests

pytest

Status

  • TODO: Alembic migrations, additional API tests, and input validation hardening

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages