Skip to content

fjbaldon/inventry

Repository files navigation

📦 Inventry

Kotlin Spring Boot Java 21 Database

Inventry is a modern, high-performance Inventory Management System REST API built with Kotlin, Spring Boot, and Spring Data JDBC. It provides a robust backend solution for managing warehouse inventories, tracking stock levels across multiple categories, and handling product details efficiently.


🚀 Key Features

  • Product Management: Complete CRUD operations for products, including descriptions and pricing.
  • Category Organization: Organize inventory items under custom, unique categories.
  • Stock Tracking: Manage quantity-in-stock and specify precise warehouse locations (e.g., A1, B2, C3).
  • Admin Management: Secure management of administrative and managerial accounts.
  • Automated Database Initialization: Automatic schema creation and seed data execution on startup.

🛠️ Tech Stack & Architecture


📊 Database Schema

The relational schema consists of four main tables. Relationships are kept simple and performance-oriented.

erDiagram
    PRODUCT ||--o{ ITEM : "contains"
    CATEGORY ||--o{ ITEM : "categorizes"
    
    PRODUCT {
        bigint id PK
        varchar name
        text description
        decimal price
    }
    
    CATEGORY {
        bigint id PK
        varchar name UK
    }
    
    ITEM {
        bigint id PK
        bigint product_id FK
        bigint category_id FK
        int quantity_in_stock
        varchar warehouse_location
    }
    
    ADMIN {
        bigint id PK
        varchar username UK
        varchar password
    }
Loading

Table Definitions

Table Column Type Constraints Description
product id BIGINT PRIMARY KEY, AUTO_INCREMENT Unique identifier for each product
name VARCHAR(255) NOT NULL Name of the product
description TEXT NULL Detailed description of the product
price DECIMAL(10,2) NOT NULL Unit price of the product
category id BIGINT PRIMARY KEY, AUTO_INCREMENT Unique identifier for each category
name VARCHAR(255) NOT NULL, UNIQUE Category name
item id BIGINT PRIMARY KEY, AUTO_INCREMENT Unique identifier for the stock item
product_id BIGINT FOREIGN KEY references product(id) The associated product
category_id BIGINT FOREIGN KEY references category(id) The associated category
quantity_in_stock INT NOT NULL Number of items currently available
warehouse_location VARCHAR(255) NOT NULL Storage shelf/zone (e.g., "A1")
admin id BIGINT PRIMARY KEY, AUTO_INCREMENT Unique identifier for administrative users
username VARCHAR(255) NOT NULL, UNIQUE Login username
password VARCHAR(255) NOT NULL Login password (stored securely)

🔌 API Reference

All endpoints accept and return JSON payloads.

1. Products (/api/product)

  • GET /api/product — Retrieve all products.
  • GET /api/product/{id} — Retrieve a specific product by ID.
  • POST /api/product — Create a new product.
    {
      "name": "Mechanical Keyboard",
      "description": "RGB Backlit Mechanical Keyboard",
      "price": 89.99
    }
  • PUT /api/product/{id} — Update an existing product.
  • DELETE /api/product/{id} — Delete a product.

2. Categories (/api/category)

  • GET /api/category — Retrieve all categories.
  • GET /api/category/{id} — Retrieve a specific category by ID.
  • POST /api/category — Create a new category.
    {
      "name": "Peripherals"
    }
  • PUT /api/category/{id} — Update an existing category.
  • DELETE /api/category/{id} — Delete a category.

3. Inventory Items (/api/item)

  • GET /api/item — Retrieve all stock items.
  • GET /api/item/{id} — Retrieve a specific inventory item.
  • POST /api/item — Add items to stock.
    {
      "productId": 1,
      "categoryId": 2,
      "quantityInStock": 150,
      "warehouseLocation": "D4"
    }
  • PUT /api/item/{id} — Update stock levels or location.
  • DELETE /api/item/{id} — Remove an item from inventory.

4. Admin Management (/api/admin)

  • GET /api/admin — List admin accounts.
  • GET /api/admin/{id} — Get detailed admin account info.
  • POST /api/admin — Create a new admin or manager account.
    {
      "username": "new_admin",
      "password": "supersecurepassword"
    }
  • PUT /api/admin/{id} — Update admin password or username.
  • DELETE /api/admin/{id} — Revoke admin access.

⚙️ Setup and Installation

Prerequisites

  • Java 21 or higher.
  • MariaDB database server running locally or accessible remotely.
  • Gradle (included via Gradle wrapper).

1. Database Configuration

Create a MariaDB database and user. By default, the application is configured to connect to localhost:3306 with the database name inventry.

You can modify these settings in src/main/resources/application.properties:

spring.datasource.url=jdbc:mariadb://localhost:3306/inventry
spring.datasource.username=your_username
spring.datasource.password=your_password

On startup, Spring Boot will automatically run src/main/resources/schema.sql to initialize the tables and src/main/resources/data.sql to populate seed data.

2. Run the Application

You can run the Spring Boot application using the Gradle wrapper:

./gradlew bootRun

The server will start by default on http://localhost:8080.

3. Running Tests

To run the automated test suite:

./gradlew test

📂 Project Structure

inventry/
├── build.gradle.kts          # Gradle build and dependency configuration
├── settings.gradle.kts       # Project metadata
├── src/
│   ├── main/
│   │   ├── kotlin/
│   │   │   └── com/github/fjbaldon/inventry/
│   │   │       ├── InventryApplication.kt  # App entry point
│   │   │       ├── Model.kt               # Spring Data JDBC Entities
│   │   │       ├── Repository.kt          # CrudRepository Interfaces
│   │   │       ├── Service.kt             # Business logic layer
│   │   │       └── Controller.kt          # REST Controllers
│   │   └── resources/
│   │       ├── application.properties     # App configuration (DB url/creds)
│   │       ├── schema.sql                 # Database table structures
│   │       └── data.sql                   # Initial database seeds
│   └── test/
│       └── kotlin/
│           └── com/github/fjbaldon/inventry/
│               └── InventryApplicationTests.kt # Spring context load test

📝 License

This project is licensed under the MIT License - see the LICENSE file for details.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages