From 4bb65956e646944115d233ab86ffe6dd9601ac80 Mon Sep 17 00:00:00 2001 From: Walter Oggioni Date: Fri, 4 Jul 2025 17:48:10 +0800 Subject: [PATCH] improved README.md --- README.md | 61 +++++++++++++++++++++---------------------------------- 1 file changed, 23 insertions(+), 38 deletions(-) diff --git a/README.md b/README.md index 4b5d127..27aba82 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,8 @@ ![Rust](https://img.shields.io/badge/rust-%23000000.svg?logo=rust&logoColor=white) ![PostgreSQL](https://img.shields.io/badge/PostgreSQL-316192?style=for-square&logo=postgresql&logoColor=white) -![Axum](https://img.shields.io/badge/Tokio-1.46-green?style=for-square) -![Axum](https://img.shields.io/badge/Sqlx-0.8-green?style=for-square) +![Tokio](https://img.shields.io/badge/Tokio-1.46-green?style=for-square) +![Sqlx](https://img.shields.io/badge/Sqlx-0.8-green?style=for-square) ![Axum](https://img.shields.io/badge/Axum-0.8-green?style=for-square) 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. @@ -24,7 +24,10 @@ Intrasys is an internal financial transfers application built with Rust and Axum ## Quick Start -### 1. Provision PostgreSQL Database +### 1. Ensure you have rust installed +Foolow the steps described [here](https://www.rust-lang.org/tools/install) if you don't + +### 2. Provision PostgreSQL Database The easiest way is to run a PostgreSQL container with Docker: @@ -32,21 +35,24 @@ The easiest way is to run a PostgreSQL container with Docker: 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 +### 2. Run the Application ```bash cargo run ``` -The application will be available at `http://localhost:3000` +The application will be available at `http://localhost:8080` + +## Running unit tests + +Make sure you have an available postgres database and edit `DATABASE_URL` variable in the `.env` file accordingly. If you've used the docker command mentioned in the *Quickstart* +section you don't need to change anything. + +Then run + +```bash +cargo test +``` ## API Endpoints @@ -81,37 +87,16 @@ The application will be available at `http://localhost:3000` "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 +- Decimal precision of 2 decimal places is sufficient for financial amounts, maximum allowed monetary amount is (10^18 -0.01) and the minimum is (-10^18 + 0.01) - Account IDs are positive integers +- Account creation must NOT be idempotent since it also sets the account balance (creating an account that already exists should fail) +- Transfer money to an account that does not exist should not create a new account, but fail with an error (to prevent users from accidentally locking their money forever) -## License - -MIT License - -## Contributing - -Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.