NamNV2496 / go-wallet

This is a basic online wallet implemented by Golang with TCC pattern. The project includes: Authorization, distributed task queue, send email, and transfer money.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Setup

postgres

1. download image

	docker pull postgres:16.3-alpine

2. run container

	docker run --name postgres -e POSTGRES_USER=root -e POSTGRES_PASSWORD=secret -e POSTGRES_DB=wallet -p 5432:5432 -d postgres:16.3-alpine

sqlc

1. Download sqlc binary

	go install github.com/sqlc-dev/sqlc/cmd/sqlc@latest

2. confile file `sql.yaml`
3. run command

	sqlc generate

This is a basic wallet was implemented by Golang.

Technologies

1. sqlc - "https://github.com/sqlc-dev/sqlc"
2. golang-migrate - "github.com/golang-migrate/migrate/v4"
3. migration - "github.com/rubenv/sql-migrate" or "github.com/golang-migrate/migrate/v4/database/postgres"
4. kafka - "github.com/IBM/sarama"
5. jwt - "github.com/golang-jwt/jwt"
6. paseto - "github.com/o1egl/paseto"
7. asynq - "github.com/hibiken/asynq"
8. email - "github.com/jordan-wright/email"
9. DB transaction - "github.com/jackc/pgx/v5/pgxpool"

alt text

Feature

1. Login with jwt or paseto with session to renew token
2. Get all accounts of user
3. Create new user (send email link to confirm)
4. Create new account
5. Find account by username of phone
6. Transfer money between 2 accounts (with confirm result through kafka)
7. Get history of transfer money

How to run

Run with docker

1. docker compose up
2. Call API to migrate DB `http://localhost:8080/migration`

Run with normal

1. Modify docker compose `- KAFKA_CFG_ADVERTISED_LISTENERS=PLAINTEXT://127.0.0.1:29092` and comment `api-service:`
2. run `docker compose up` to setup kafka, redis and postgres
3. `make server`
4. Call API to migrate DB `http://localhost:8080/migration`

Database

alt text

Demostration

alt text alt text alt text alt text alt text

How to config email for sender

After 2-steps login. Create app password and change data in app.env field EMAIL_SENDER_PASSWORD

link alt text

alt text

alt text

About

This is a basic online wallet implemented by Golang with TCC pattern. The project includes: Authorization, distributed task queue, send email, and transfer money.


Languages

Language:Go 71.9%Language:HTML 26.8%Language:Makefile 0.7%Language:Dockerfile 0.4%Language:Shell 0.2%