An open API service indexing awesome lists of open source software.

https://github.com/x0rd3v1l/payment-backend-service

Rust-based backend service for payment processing, featuring database migrations, Docker support, and API documentation.
https://github.com/x0rd3v1l/payment-backend-service

backend restful-api rocket rust

Last synced: 2 months ago
JSON representation

Rust-based backend service for payment processing, featuring database migrations, Docker support, and API documentation.

Awesome Lists containing this project

README

          

# Payment Backend Service

**Payment Backend Service** contains RESTful API endpoints for User, Account and Transaction Management.

## ๐Ÿ› ๏ธ Technologies Used

* **Programming Language**: Rust
* **Containerization**: Docker
* **Database**: PostgreSQL
* **ORM**: SeaORM
* **Web Framework**: Rocket

## ๐Ÿ“ Project Structure

```
โ”œโ”€โ”€ api_docs..md
โ”œโ”€โ”€ Cargo.lock
โ”œโ”€โ”€ Cargo.toml
โ”œโ”€โ”€ docker-compose.yml
โ”œโ”€โ”€ README.md
โ”œโ”€โ”€ src
โ”‚ย ย  โ”œโ”€โ”€ auth
โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ mod.rs
โ”‚ย ย  โ”œโ”€โ”€ controllers
โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ accounts.rs
โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ auth.rs
โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ mod.rs
โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ profile.rs
โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ transactions.rs
โ”‚ย ย  โ”œโ”€โ”€ db
โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ mod.rs
โ”‚ย ย  โ”œโ”€โ”€ entities
โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ account.rs
โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ mod.rs
โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ prelude.rs
โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ transactions.rs
โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ txns.rs
โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ users.rs
โ”‚ย ย  โ”œโ”€โ”€ fairings
โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ cors.rs
โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ mod.rs
โ”‚ย ย  โ”œโ”€โ”€ kafka
โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ consumer.rs
โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ mod.rs
โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ producer.rs
โ”‚ย ย  โ”œโ”€โ”€ lib.rs
โ”‚ย ย  โ”œโ”€โ”€ main.rs
โ”‚ย ย  โ”œโ”€โ”€ migrator
โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ m20250521_135328_create_users_table.rs
โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ m20250521_135711_create_accounts_table.rs
โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ m20250521_135737_store_transactions_table.rs
โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ mod.rs
โ”‚ย ย  โ””โ”€โ”€ utils
โ”‚ย ย  โ”œโ”€โ”€ mod.rs
โ”‚ย ย  โ”œโ”€โ”€ random.rs
โ”‚ย ย  โ””โ”€โ”€ validations.rs
โ””โ”€โ”€ tests
โ””โ”€โ”€ endpoint_test.rs

11 directories, 33 files
```

## โš™๏ธ Getting Started

### Prerequisites

* Rust (latest stable version)
* Docker & Docker Compose
* psql (PostgreSQL) 17.5 (Ubuntu 17.5-1.pgdg24.04+1)

### Installation

1. **Clone the repository**:

```bash
git clone https://github.com/X0rD3v1L/payment-backend-service.git
cd payment-backend-service
```

2. **Set up environment variables**:

Create a `.env` file in the root directory and configure the necessary environment variables.
```
PAYMENTS_JWT_SECRET="REDACTED"
```

To generate,
```openssl rand -base64 64```

3. **Build and run the application**:

Make sure a database named `payments` exists in your local psql.

```bash
cargo build
cargo run
```

In another terminal,
```bash
docker-compose up
```

The service should now be running and accessible at `http://127.0.0.1:8000`.

## ๐Ÿงช Running Tests

To execute the test suite:

```bash
cargo test
```

A sample test case was written to test the usage, comprenshive unit tests and integration tests need to be written.

## ๐Ÿ“„ API Documentation

Detailed API documentation is available in the [`api_docs.md`](./api_docs.md) file. It provides comprehensive information on available endpoints, request/response structures, and usage examples.