Git Product home page Git Product logo

bank-go's Introduction

Go Bank

App built in Go 1.20

The app uses:

Getting started

  1. Clone the repository
  2. Go to the project's root directory
  3. Rename app.env.sample to app.env and replace the values
  4. Run in your terminal:
    • docker-compose up --build to run the containers
  5. Now everything should be ready and the server running on SERVER_ADDRESS specified in app.env

Testing

  1. Run the containers (database container is sufficient)
  2. Run in your terminal:
    • make test or
    • make test_coverage p={PATH} - to get the coverage in the HTML format - where {PATH} is the path to the target directory for which you want to generate test coverage. The {PATH} should be replaced with the actual path you want to use. For example ./api or
    • simply use go test commands

API Endpoints

Users (only endpoints that do not require authentication)

  • /users - handles POST requests to create users
  • /users/login - handles POST requests to log in users
  • /tokens/renew - handles POST requests to renew the access tokens

Accounts

  • /accounts - handles POST requests to create accounts
  • /accounts - handles GET requests to get all accounts
  • /accounts/{id} - handles GET requests to get account details
  • /accounts/{id} - handles DELETE requests to delete an account

Transfers

  • /transfers - handles POST requests to transfer money from one account to another

Documentation

API

After running the server, the API (HTTP gateway) documentation can be found at http://localhost:8080/docs/

Database

The database's schema and intricate details can be found on dedicated webpage, which provides a comprehensive overview of the data structure, tables, relationships, and other essential information. To explore the database further, please visit this dbdocs.io webpage. Password: bankgopassword

bank-go's People

Contributors

aalug avatar

Watchers

 avatar  avatar

bank-go's Issues

Add database docs

Add database documentation using dbdocs.io.
Create the .dbml schema of the database and create a webpage with the documentation.

Implement update user functions in gRPC

Implement update user functions in gRPC.
Create an SQL query code and generate the UpdateUser function with sqlc.
Using this newly created function, implement functionality to update users through gRPC and HTTP.

Add refresh tokens

Add handling of refresh tokens.
Create migrations with new sessions table.
Add a function to handle POST requests to renew access tokens.

Implement the env file

Implement the .env file with Viper.
Add config file which will load environment variables in the main function.

Create transfers API

Create transfers API. Handle POST requests to the /transfers endpoint. Validate and create a transfer.

Add users table

Add users table and set the accounts owner to reference the users table.

Extract metadata from context

Extract metadata from context.
The metadata needed right now is:

  • user agent
  • client IP
    Both of those are required to create a session in the database.

Add HTTP gateway

Add HTTP gateway.
Use grpc-gateway.
For now, there will be only two endpoints working with this.
The rest will be implemented later.

Update `TransferTx` function

Update TransferTx function to avoid deadlocks. Add order to updating accounts to avoid deadlocks.
Add another test to test that.

Implement create and login user in gRPC

Implement create and login user functions in gRPC.
Most of the functions will be the same as it was in the gin app.
Main difference are errors and data validation.

Add middleware to protect routes

Add middleware to protect routes.
Update tests that will fail because of this change.
Add tests to check that only authenticated users can use protected routes.

Add a transactions store

Add a transactions store that will handle all transfer-related logic. It will create a transaction, two entries, and update accounts balances.
Test it.

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.