Inventory Management System (by Yevhen Okolielov) #22
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Inventory Management System
Inventory Management CRUD application built with FastAPI, Asyncpg (Raw SQL), and PostgreSQL. It includes a REST API, a CLI tool, and a Dockerized database environment.
Quick Start
1. Prerequisites
2. Start the Database
The project uses a Dockerized PostgreSQL instance.
API URL: http://127.0.0.1:8000
Swagger UI: http://127.0.0.1:8000/docs
Database Port: 5432 (Exposed locally for debugging)
Default credentials: Defined in .env
Init: Schema is automatically applied from init.sql.
Usage Examples
Below are full examples of how to interact with the API using standard
curlcommands or the included Python CLI tool.1. Create a Server
2. List All Servers
3. Get Single Server Details
4. Update a Server
5. Delete a Server
CLI Specification
The command-line interface (
app/cli.py) interacts directly with the running API.Usage:
python3 app/cli.py [COMMAND] [ARGS]listpython3 app/cli.py listgetIDpython3 app/cli.py get 1createHOSTNAMEIP[--state]active.python3 app/cli.py create web-01 10.0.0.5 --state offlineupdateID[--hostname][--ip][--state]python3 app/cli.py update 1 --state retireddeleteIDpython3 app/cli.py delete 1API Specification
The API follows RESTful standards. All request and response bodies are JSON.
Base URL:
http://127.0.0.1:8000Endpoints
1. List Servers
GET/servers200 OK(Array of Server Objects)2. Create Server
POST/servers{ "hostname": "string (unique)", "ip_address": "string (IPv4/IPv6)", "state": "active | offline | retired (optional, default: active)" }201 Created3. Get Server
GET/servers/{id}200 OKor404 Not Found4. Update Server
PUT/servers/{id}{ "hostname": "new-name", "state": "retired" }200 OK5. Delete Server
DELETE/servers/{id}204 No ContentValidation Rules
active,offline, orretired.Testing
The project includes a pytest suite that mocks the database connection, ensuring logic is tested without requiring a running DB.
# Run all tests python3 -m pytest tests/test_main.py -vStart the API Server locally
(http://127.0.0.1:8080)