A payment service implementation built with Rust, featuring user management, transaction processing, and account balance tracking. This service provides a RESTful API using the Actix web framework with PostgreSQL as the database backend.
- User Management
- Registration and authentication
- JWT-based authorization
- Secure password handling with bcrypt
- Transaction Management
- Create and process transactions
- Transaction history tracking
- Per-user transaction listing
- Account Management
- Multiple accounts per user
- Account creation and management
- Built with
actix-web
for high performance - Asynchronous operations using Rust's async/await
- Rate limiting with
actix-governor
- Request logging and tracing
- CORS support
- Structured API error responses
src/
├── app_state.rs # Application state management
├── constants.rs # Global constants
├── features/
│ ├── accounts/ # Account management
│ ├── transactions/ # Transaction processing
│ ├── user/ # User profile management
│ └── healthcheck/ # Service health check
├── middlewares/ # Middleware for JWT and CORS
├── routes.rs # API route configuration
├── types.rs # Common type definitions
├── util.rs # Utility functions and error handling
└── main.rs # Application entry point
- Rust : Install using rustup and/or checkout documentation
- PostgreSQL : Download from here
- Docker (optional) : Download from here
- sea-orm-cli : Install using
cargo install [email protected]
-
Clone the repository:
git clone https://github.com/claddyy/dodo-assignment.git cd dodo-assignment
-
Set up the database:
# PostgreSQL connection details should be configured in your .env # Set you database url in .env.example mv .env.example .env cd db/ sea-orm-cli migrate fresh #This migrates the database to schema.
To install sea-orm-cli, simply run
cargo install [email protected]
- Run the server
cd .. cd http/ cargo run
The service will start on localhost:3000
by default.
Installation using Docker
The setup handles everything automatically, including the database setup and migrations.
git clone https://github.com/claddyy/dodo-assignment.git
cd dodo-assignment/
docker-compose up --build
The service exposes the following API endpoints:
User Management
POST /api/user/register
- Register a new userPOST /api/user/login
- Authenticate a user
Account Management
POST /api/account/create
- Create a new accountGET /api/account/{account_id}
- Get account detailsGET /api/account/list/acc
- List all user accountsGET /api/account/{account_id}/balance
- Get account balance
Transaction Management
POST /api/transaction/create
- Create a new transactionGET /api/transaction/{transaction_id}
- Get transaction detailsGET /api/transaction/usertx/tx
- List user transactions
This repo support rustdocs
and documentation can be generated with:
cargo doc
Format your code with:
cargo fmt