https://github.com/allansomensi/printer-supplies-api
A simple REST API using Axum for managing printer supplies, such as toners and drums.
https://github.com/allansomensi/printer-supplies-api
api axum crud docker openapi postgresql printer rust sqlx stock-management swagger-ui
Last synced: 6 months ago
JSON representation
A simple REST API using Axum for managing printer supplies, such as toners and drums.
- Host: GitHub
- URL: https://github.com/allansomensi/printer-supplies-api
- Owner: allansomensi
- License: mit
- Created: 2024-09-09T13:55:19.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-07-06T21:10:22.000Z (9 months ago)
- Last Synced: 2025-07-06T22:20:30.688Z (9 months ago)
- Topics: api, axum, crud, docker, openapi, postgresql, printer, rust, sqlx, stock-management, swagger-ui
- Language: Rust
- Homepage:
- Size: 229 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Printer Supplies API ๐จ๏ธ
A **REST API** using **Axum** for managing **printer supplies**, such as toners and drums. The project includes CRUD functionalities for various resources and inventory movement tracking.
## Technologies Used
- **Axum:** Asynchronous web framework for Rust.
- **SQLx:** For interaction with the database and migrations.
- **Just:** For utility scripts.
- **Docker:** For database container.
- **Swagger:** API documentation.
## Features
- CRUD operations for movements, printers, brands, drums, and toners.
- Inventory management for toners and drums.
- Docker Compose setup for easy deployment.
- Database migrations included, executable via CLI or endpoint.
- Error handling with thiserror for descriptive error responses.
- Includes development, production, and test environments.
- Includes unit and integration tests.
- API documentation available with Swagger UI.
---
# Getting Started ๐ฏ
## Prerequisites:
- **Rust** *(latest stable version)*
- **Docker** and **Docker Compose**
- **Just** for scripts
## 1. Installation
``` bash
git clone https://github.com/allansomensi/printer-supplies-api.git
cd printer-supplies-api
```
For the scripts:
``` elixir
cargo install just
```
## 2. Load environment variables
By default, the selected file is `.env.development`, so there's no need to run this command in a development environment.
If you're running in a **production** environment, execute the command below to ensure the correct environment variables are loaded.
``` bash
source scripts/set_env.sh
```
## 3. Build and run the Docker container:
``` elixir
just services-up
```
## 4. Run migrations:
``` elixir
just migrate-run
```
## 5. Start server ๐ ๐
``` elixir
just serve
```
# Running Tests ๐จโ๐ฌ
For once:
``` elixir
just test
```
For watching mode:
``` elixir
just test-watch
```
## Endpoint tests ๐งช
> Endpoint tests are located at `/tests` folder

## API Documentation ๐
API endpoints and usage details are documented using `Swagger UI` and `OpenAPI` with `Utoipa`.
The full documentation is available in the `openapi.json` file, which can be accessed and imported as needed. Run the application and navigate to `/swagger-ui` to view the interactive Swagger documentation.