This is a Go-based REST API for managing SWIFT codes (Bank Identifier Codes). The application allows you to retrieve, add, and delete SWIFT codes, as well as fetch all SWIFT codes for a specific country. The project is containerized using Docker Compose, with a PostgreSQL database for data storage. The database has been denormalized to optimize query performance. This reduces the number of joins and improves read speed at the cost of redundancy.
- Docker and Docker Compose installed on your machine.
- Git for cloning the repository.
-
Clone the repository:
git clone https://github.com/czyz-bartosz/swift-codes-api.git cd swift-codes-api -
Set up environment variables:
- Copy the
.env.examplefile to.env:cp .env.example .env
- Update the
.envfile with your database credentials:DB_USER=your_db_username DB_PASSWORD=your_db_password DB_NAME=mydb
- Copy the
-
Build and run the application using Docker Compose:
⚠️ Warning: Port Conflicts
Before running the application, ensure that the following ports are not already in use on your machine:
- Port 8080: Used by the Go application.
- Port 5432: Used by the PostgreSQL database.
If these ports are occupied, the application will fail to start.
docker compose up --buildThis will start the PostgreSQL database and the Go application. The API will be accessible at http://localhost:8080.
⚠️ Warning: Running Integration Tests Will Reset the Database to Its Initial State
To run the unit and integration tests on your local computer, execute the following command.:
go test ./...or on the container:
docker compose exec app go test ./...Make sure the Docker containers are running before running the integration tests.