Skip to content

SajjadHadi/Spenser

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Rust Actix Docker MySQL SeaORM JWT RustRover

Spenser

Spenser is a RESTful API server built with Rust, Actix Web, SeaORM, MySQL, and Docker. It provides authentication and transaction management functionalities.

Requirements

  • Rust
  • Docker & Docker-Compose
  • MySQL

Environment Variables

The application requires the following environment variables:

DATABASE_URL=mysql://<USER>:<PASSWORD>@localhost:3306/<DB_NAME>
MYSQL_URL=mysql://<USER>:<PASSWORD>@db:3306/<DB_NAME>
MYSQL_USER=<USER>
MYSQL_DB=<DB_NAME>
MYSQL_PASSWORD=<PASSWORD>
MYSQL_ROOT_PASSWORD=<ROOT_PASSWORD>
JWT_SECRET=<YOUR_SECRET>

Running with Docker-Compose

docker-compose up --build

API Endpoints

Method Path Auth? Description
POST /auth/sign-up Create a new account.
POST /auth/sign-in Sign in, returns JWT on success.
GET /api/categories List categories.
POST /api/categories Create a new category.
GET /api/categories/{id} Get category by ID.
PUT /api/categories/{id} Update category by ID.
DELETE /api/categories/{id} Delete category by ID.
GET /api/categories/{id}/transactions List transactions in a category.
GET /api/transactions List all transactions.
POST /api/transactions Create a new transaction.
GET /api/transactions/{id} Get transaction by ID.
PUT /api/transactions/{id} Update transaction by ID.
DELETE /api/transactions/{id} Delete transaction by ID.

Authentication: Include Authorization: Bearer <JWT> in the header for authenticated requests.

Database

The service uses MySQL as the database and runs inside a Docker container. Ensure MySQL is configured correctly before running the app.

Build and Run Manually

cargo build --release
./target/release/Spenser

Notes

  • Ensure .env is correctly configured before running.
  • Uses JWT-based authentication with a token lifetime of 4 hours.