Skip to content

Commit

Permalink
Update README
Browse files Browse the repository at this point in the history
  • Loading branch information
viralparmarme committed Sep 29, 2023
1 parent 347dc46 commit 7e7e6a8
Showing 1 changed file with 106 additions and 2 deletions.
108 changes: 106 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,109 @@
# Simple Bank

## DB Schema
This repository contains code for a simple bank service written completely in Go, supporting the following operations:

https://dbdiagram.io/d/Simple-Bank-650d067f02bd1c4a5e0e347d
1. Create and manage bank accounts, which are composed of owner’s name, balance, and currency.
2. Record all balance changes to each of the account. So every time some money is added to or subtracted from the account, an account entry record will be created.
3. Perform a money transfer between 2 accounts. This should happen within a transaction, so that either both accounts’ balance are updated successfully or none of them are.

## Setup local development

### Install tools

- [Docker desktop](https://www.docker.com/products/docker-desktop)
- [TablePlus](https://tableplus.com/)
- [Golang](https://golang.org/)
- [Homebrew](https://brew.sh/)
- [Migrate](https://github.com/golang-migrate/migrate/tree/master/cmd/migrate)

```bash
brew install golang-migrate
```

- [Sqlc](https://github.com/kyleconroy/sqlc#installation)

```bash
brew install sqlc
```

- [Gomock](https://github.com/golang/mock)

```bash
go install github.com/golang/mock/[email protected]
```

### Setup infrastructure

- Start postgres container:

```bash
make postgres
```

- Create simple_bank database:

```bash
make createdb
```

- Run db migration up all versions:

```bash
make migrateup
```

- Run db migration up 1 version:

```bash
make migrateup1
```

- Run db migration down all versions:

```bash
make migratedown
```

- Run db migration down 1 version:

```bash
make migratedown1
```

### Documentation

- DB Schema:

https://dbdiagram.io/d/Simple-Bank-650d067f02bd1c4a5e0e347d

- API Schema:

https://github.com/viralparmarme/simple-bank/blob/main/postman.json

### How to generate code

- Generate SQL CRUD with sqlc:

```bash
make sqlc
```

- Generate DB mock with gomock:

```bash
make mock
```

### How to run

- Run server:

```bash
make server
```

- Run test:

```bash
make test
```

0 comments on commit 7e7e6a8

Please sign in to comment.