Banco de España
Description
Bank system has a microservice architecture. Server and client linked by GRPC. Also system has support of GRPC-Gateway - it means, that client can communicate with server with help of JSON-messages. System use data store - Postgres DB - in separate docker container (pg-bank).
All applications (data store, server, gateway) working in one docker network
(named net
by default).
Opportunities
-
Add / remove client;
-
Get list of all clients;
-
Get information about client;
-
Create new account;
-
Remove existing account;
-
Get list of all accounts;
-
Get list of all accounts by client id;
-
Get information about account;
-
Update account;
-
Get balance of account;
-
Change balance of account;
-
Transfer money from one account to another account;
-
Get list of all transactions;
-
Get list of transaction by custom period;
-
Cancel transaction;
New transaction is creating for every operations with accounts. Transaction can be cancelled.
Project structure
- api - sourse files, generated by protoc compiler;
- bankservice - implementation of service logig;
- client - simple console client (demonstrate purpose);
- docker - docker-files for applications;
- proto - .proto files for describing all structures and methods (grpc);
- sqlstore - files needed to working with database container;
- src - entry point source codef for applications (server, gateway);
- validate - validation methods implementations;
- vendor - project dependencies (managed by
go dep
).
Local build
Requirments for local machine
- go compiler (v 1.9 and later);
- make;
- dep;
- docker;
- protoc compiler (for GRPC).
Try to build && run
make gen
- generating source codes from proto-schema by protoc compiler;
make dep
- downloads all project dependencies;
make init
- creating new docker network (called net
by default) and create postgres docker
container (named pg-bank
. postgres:10.3-alpine
image by default).
make up
- starting pg-bank
(data store), bank_microservice
(server)
and gw_bank
(grpc-gateway) docker containers. Depends on image
target.
make image
- create bank:latest
(server) and gw-bank
(grpc-gateway) docker images.
This images copy .bin
files and running their in alpine-container. Depends on build
target.
make build
- compiling .bin
files from source codes (move .bin files in /bin folder).
In case of success execution of make up
- try to execute docker ps
- you will see
3 docker containers (pg-bank
, bank_microservice
and gw_bank
). Now you can to try
execute some bank operations.
Also you can use:
make db-create
- migrating .sql schema from ./sqlstore/schema.sql
to postgres database
(creating database and filling by testing data).
make down
- stopping and removing gw_bank
and bank_microservice
docker
containers, removing gw-bank
and bank
docker images.
make clean
- the same as make down
and also stopping and removing pg-bank
docker
container and image; removing docker network; removing ./bin
folder.