Git Product home page Git Product logo

go-bank-v1's Introduction

Go Bank 1.0

Description

This is a simple bank application that allows users to create an account, deposit, withdraw, and transfer money between accounts.

Technologies

  • Golang/Gin
  • PostgreSQL
  • Docker
  • Docker Compose
  • Makefile
  • Sqlc
  • Gomock
  • Testify
  • Golang-migrate

Features

Installation

Usage

  • The database is running on port 5432 in the docker container.

    • If connecting to the DB for the first time:
      1. Run make pgstart to initialize the docker database container.
      2. Run make createdb to create the database.
      3. Connect to the DB with TablePlus or any other DB client.
      4. Run make migrateup to run the migrations.
    • For subsequent connections:
      1. Run make postgresstart to start the database container.
      2. To stop the database container, run make pgstop.
  • Gin server is running on port 8080. Start the server by running make server in the root directory of the project. Make sure the database is running before starting the server.

  • SQLC is used to generate idiomatic Go code for working with the database based on the pre-defined SQL queries we've written in the db/query folder.

    • SQLC looks at the sqlc.yaml file in the root directory to configure and generate the code.
    • To add new/update SQL queries:
      1. Write the queries in the db/query folder.
      2. To generate the SQLC code, run make sqlc in the root directory of the project.
      3. The generated code is placed in the db/sqlc directory.
        • models.go contains the structs for the tables in the database.
        • db.go contains the Queries struct for using with a sql.DB object or with a sql.Tx object for transactions.
        • The Go code ends with .sql.go.
      4. Make sure to create the corresponding <table>_test.go file in the db/sqlc directory to test the generated code.
  • Gomock / Mockgen is used to generate a mock db and mock services for testing the 2 layers.

    1. To generate the mock db, run make mockdb in the root directory of the project.
    2. To generate the mock services, run make mockservice in the root directory of the project.

go-bank-v1's People

Contributors

1barcode avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.