diff --git a/README.md b/README.md index 4b5d127..8e8dd24 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,13 @@ 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` ## API Endpoints @@ -83,35 +78,32 @@ The application will be available at `http://localhost:3000` } ``` -## Development Setup +## Configuration +The app can be configured using environmental variable that can also be provided through a `.dotenv` file. +The following variables affect the application behavior: -1. Install Rust toolchain: - ```bash - curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh - ``` +- `INTRASYS_LOG` changes the logging level, can be set to one of `trace`, `debug`, `info`, `warn`, `error` +- `INTRASYS_HOST` is the address the HTTP server will bind to +- `INTRASYS_PORT` is the port the HTTP server will listen to +- any of the environmental variables mentioned [here](https://docs.rs/sqlx/latest/sqlx/postgres/struct.PgConnectOptions.html#method.options) affects the postgres database connection -2. Clone the repository: - ```bash - git clone https://github.com/yourusername/intrasys.git - cd intrasys - ``` +## Running unit tests -3. Run database migrations (optional - the app will create tables if they don't exist): - ```bash - sqlx migrate run - ``` +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 +``` ## 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.