118 lines
2.7 KiB
Markdown
118 lines
2.7 KiB
Markdown
# Intrasys - Internal Transfers System
|
|
|
|

|
|

|
|

|
|

|
|

|
|
|
|
Intrasys is an internal financial transfers application built with Rust and Axum, providing HTTP endpoints for account management and transaction processing with PostgreSQL as the backing database.
|
|
|
|
## Features
|
|
|
|
- Account creation with initial balance
|
|
- Account balance queries
|
|
- Secure transaction processing between accounts
|
|
- Atomic transaction handling with database integrity
|
|
- Precise decimal arithmetic for financial amounts
|
|
|
|
## Prerequisites
|
|
|
|
- Rust (latest stable version)
|
|
- Docker (for database provisioning)
|
|
- PostgreSQL client (optional)
|
|
|
|
## Quick Start
|
|
|
|
### 1. Provision PostgreSQL Database
|
|
|
|
The easiest way is to run a PostgreSQL container with Docker:
|
|
|
|
```bash
|
|
docker run --name intrasys-pg -d -e POSTGRES_PASSWORD=password -p 127.0.0.1:5432:5432 postgres:alpine
|
|
```
|
|
|
|
### 2. Configure Environment
|
|
|
|
Create a `.env` file in the project root:
|
|
|
|
```bash
|
|
echo "DATABASE_URL=postgres://postgres:password@localhost:5432/postgres" > .env
|
|
```
|
|
|
|
### 3. Run the Application
|
|
|
|
```bash
|
|
cargo run
|
|
```
|
|
|
|
The application will be available at `http://localhost:3000`
|
|
|
|
## API Endpoints
|
|
|
|
### Account Management
|
|
|
|
- **Create Account**
|
|
`POST /accounts`
|
|
```json
|
|
{
|
|
"account_id": 123,
|
|
"initial_balance": "100.23344"
|
|
}
|
|
```
|
|
|
|
- **Get Account Balance**
|
|
`GET /accounts/{account_id}`
|
|
Response:
|
|
```json
|
|
{
|
|
"account_id": 123,
|
|
"balance": "100.23344"
|
|
}
|
|
```
|
|
|
|
### Transactions
|
|
|
|
- **Process Transaction**
|
|
`POST /transactions`
|
|
```json
|
|
{
|
|
"source_account_id": 123,
|
|
"destination_account_id": 456,
|
|
"amount": "50.12345"
|
|
}
|
|
```
|
|
|
|
## Development Setup
|
|
|
|
1. Install Rust toolchain:
|
|
```bash
|
|
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
|
|
```
|
|
|
|
2. Clone the repository:
|
|
```bash
|
|
git clone https://github.com/yourusername/intrasys.git
|
|
cd intrasys
|
|
```
|
|
|
|
3. Run database migrations (optional - the app will create tables if they don't exist):
|
|
```bash
|
|
sqlx migrate run
|
|
```
|
|
|
|
## Assumptions
|
|
|
|
- All accounts use the same currency
|
|
- No authentication or authorization is implemented
|
|
- Decimal precision of 10 decimal places is sufficient for financial amounts
|
|
- Account IDs are positive integers
|
|
|
|
## License
|
|
|
|
MIT License
|
|
|
|
## Contributing
|
|
|
|
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
|