https://github.com/paulorohling/txplorer
TxPlorer is a transactional application that allows users to transfer funds between their accounts.
https://github.com/paulorohling/txplorer
clean-architecture go go-chi money-transfer postgres rest-api transaction
Last synced: 2 months ago
JSON representation
TxPlorer is a transactional application that allows users to transfer funds between their accounts.
- Host: GitHub
- URL: https://github.com/paulorohling/txplorer
- Owner: pauloRohling
- License: mit
- Created: 2024-08-10T22:24:54.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2025-03-01T15:23:15.000Z (3 months ago)
- Last Synced: 2025-03-01T16:26:29.486Z (3 months ago)
- Topics: clean-architecture, go, go-chi, money-transfer, postgres, rest-api, transaction
- Language: Go
- Homepage:
- Size: 207 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# TxPlorer
TxPlorer is a transactional accounting system that allows users to manage their financial accounts and track their
transactions. This project was created as an experiment about how to build a transactional system using Go and
PostgreSQL, while also applying clean architecture principles. One of the main challenges in dealing with transactions
in a clean architecture is how to handle them across multiple repositories without leaking database specific code to the
domain layer.In this project, a transaction manager interface was used inside each use case, ensuring that no database specific code
was used to rollback or commit a transaction. This interface is also responsible for sharing the transaction object as a
context value to allow repositories to access it. This approach allows the domain layer to be kept clean and focused on
the business logic, while the persistence layer handles the transactional aspects of the application.## Features
- Create accounts
- Transfer funds between accounts
- View account balances
- View transaction history## Prerequisites
- [Go](https://go.dev/doc/install)
- [PostgreSQL](https://www.postgresql.org/download/)
- [Docker](https://www.docker.com/products/docker-desktop)
- [Air](https://github.com/air-verse/air)
- [Make](https://www.gnu.org/software/make/)
- [Migrate](https://github.com/golang-migrate/migrate)
- [Mockery](https://github.com/vektra/mockery)
- [Sqlc](https://github.com/kyleconroy/sqlc)
- [Swag](https://github.com/swaggo/swag)## API
| Endpoint | Description | Method |
|-------------------------------|-----------------------------------|--------|
| `/api/v1/accounts` | Creates a new account | POST |
| `/api/v1/accounts/{id}` | Gets an account | GET |
| `/api/v1/accounts/{id}` | Deletes an account | DELETE |
| `/api/v1/operations/transfer` | Transfer funds to another account | POST |
| `/api/v1/operations/deposit` | Deposit funds to an account | POST |
| `/api/v1/operations/withdraw` | Withdraw funds from an account | POST |
| `/api/v1/users` | Changes the password of a user | POST |
| `/api/v1/users/login` | Generates a new access token | POST |## Environment Variables
| Variable | Description | Default Value | Required |
|-------------------------------|-------------------------------------|---------------|----------|
| `SERVER_PORT` | Port to listen on | 8080 | false |
| `SECURITY_SECRET` | Secret used to sign JWT tokens | - | true |
| `SECURITY_TOKEN_EXPIRATION` | Expiration time of JWT tokens | 24h | false |
| `DATABASE_HOST` | Host of the database | - | true |
| `DATABASE_PORT` | Port of the database | - | true |
| `DATABASE_NAME` | Name of the database | - | true |
| `DATABASE_USER` | User to connect to the database | - | true |
| `DATABASE_PASSWORD` | Password to connect to the database | - | true |
| `DATABASE_SSL` | Whether to use SSL | false | false |
| `DATABASE_MAX_OPEN_CONNS` | Maximum number of open connections | 100 | false |
| `DATABASE_MAX_IDLE_CONNS` | Maximum number of idle connections | 10 | false |
| `DATABASE_CONN_MAX_LIFETIME` | Maximum lifetime of a connection | 5m | false |
| `DATABASE_CONN_MAX_IDLE_TIME` | Maximum idle time of a connection | 30s | false |## License
TxPlorer is released under the MIT License. See the [LICENSE](LICENSE) file for more information.