wallets

module
v0.0.0-...-d05f80c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 22, 2021 License: MIT

README

wallets

Components

The application has two components:

  1. postgres - database.
  2. wallets - HTTP server.
1. postgres

The database contains two tables wallets and operations.

  • wallets contains wallet name and balance.
  • operations contains deposit and withdrawal operations.

Read migrations for details.

I decided to use sql.LevelSerializable for transactions. This simplifies life on the stage of development. In the future it will be possible to try to optimize.

2. wallets

The wallets component can be run in multiple instances.
It serves four endpoints:

  • POST /wallets - Add wallet.
  • POST /wallets/deposit - Top up wallet.
  • POST /wallets/transfer - Transfer money.
  • GET /wallets/operations - Get wallet operations.

Read api/v1/swagger.yaml for details.

Packages

  • application - creates dependencies and runs application;
  • config - reads configuration from envs (viper);
  • consts - application constants;
  • csv - methods for generating csv;
  • dto - data transfer objects;
  • http - HTTP server;
  • httperr - custom errors;
  • repository - works with database;
  • service - business logic;
  • tests - integration tests.

Use go doc for details.

go doc internal/service

Directories

Path Synopsis
internal
application
Package application runs the required components depending on the parameters.
Package application runs the required components depending on the parameters.
config
Package config contains Config struct that is used for configuring application.
Package config contains Config struct that is used for configuring application.
consts
Package consts contains application constants.
Package consts contains application constants.
csv
Package csv contains methods for generating csv.
Package csv contains methods for generating csv.
dto
Package dto contains data transfer objects.
Package dto contains data transfer objects.
http
Package http contains the HTTP server and associated endpoint handlers.
Package http contains the HTTP server and associated endpoint handlers.
repository
Package repository contains all the functionality for working with the DB.
Package repository contains all the functionality for working with the DB.
service
Package service contains the business logic for wallets application.
Package service contains the business logic for wallets application.
service/mocks
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL