It is a sample bank application built using the Go programming language. The application allows to create users, charge/remove user balance, transfer money from one user to another
- Create user
- Charge user balance
- Remove user balance
- Transfer money
The following technologies were used in the development of this project:
- Golang
- HttpRouter - HttpRouter by julienschmidt
- PostgreSQL - pgx (PostgreSQL Driver and Toolkit) by jackc
- Swagger - swag (Automatically generate RESTful API) by swaggo
- Docker
Go Bank Service requires Golang v1.20.0+ to run.
- Install and start PostgreSQL
- Change configuration file
/configs/config.local.yml
- Install docker and start the server.
cd go-bank-service
go run app/cmd/app/main.go
Go Messenger is very easy to run through Docker container.
Make sure you have Docker and Docker Compose installed on your machine. You can download Docker Desktop from the official website for your operating system.
Before running the application, you'll need to set some environment variables in the docker-compose.yml file. The following environment variables are used in the provided configuration:
PSQL_HOST
: the hostname or IP address of the Postgres databasePSQL_PORT
: the port number on which Postgres is listeningPSQL_USERNAME
: the username for the Postgres userPSQL_PASSWORD
: the password for the Postgres userPSQL_DATABASE
: the name of the Postgres database to use
You can set these environment variables in the docker-compose.yml file or in your shell environment.
Change into the root directory of the cloned repository and run the following command to build and start the application:
docker-compose up --build
or
make docker.up
This command will build the Go application using the Dockerfile and start two containers: one for the HTTP server and one for Postgres. The --build flag ensures that the latest version of the application is built before starting the containers.
Once the application is running, you should be able to access it in your web browser by navigating to http://localhost:30001. The HTTP server is running on port 30001, which is mapped to the container's port 30001 in the docker-compose.yml file.
To stop the application and remove the containers, press Ctrl-C in the terminal where docker-compose up is running. Alternatively, you can run the following command in the same directory as the docker-compose.yml file:
docker-compose down
or
make docker.stop
If you want to delete containers use:
make docker.down
This command will stop and remove the containers created by the docker-compose up command.
You can view the Swagger documentation for the API by navigating to http://localhost:30001/swagger
in your web browser. This will display a UI that shows all the available endpoints, along with details on the request and response formats.
The Swagger UI provides a convenient way to explore the API and test its endpoints. You can try out each endpoint by clicking on it and entering the required parameters. The UI will display the response in real-time, making it easy to see the results of your requests.
-
Tests
-
Receipts
-
Accounting report