Skip to content

SH1roV12/BalanceApp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

💳 Wallet System (Go + gRPC + JWT + YooKassa SDK)

A backend system written in Go using a microservice architecture with gRPC communication.
The project simulates a simple financial system with authentication via jwt, payments via YooKassa, and balance management.


🛠 Technology Stack

Go Fiber GORM gRPC Protobuf PostgreSQL Docker

🧠 Architecture Overview

The system consists of gRPC module + main backend API which both work in grpc client and server mode simultaneously for creating and confirming payment:

  • Main Backend (HTTP + Auth + API + Users with balance) ↓ (gRPC)
  • Payment Service (YooKassa integration and balance + transactions) (gRPC)

🧱 Services

🟢 Main Backend

Responsible for:

  • User registration & login
  • JWT authentication (access + refresh tokens)
  • HTTP API (Fiber)
  • Creating payment requests
  • User balance management

🟡 Payment Service (gRPC)

Responsible for:

  • Creating payment sessions via YooKassa
  • Handling payment webhooks
  • Tracking payment status
  • Communicating payment result to main backend

👤 User Flow

  • Registration:
    User sends: POST /api/v1/new:
{
    "first_name":"John",
    "last_name":"Pork",
    "username": "Johny1821",
    "email":"[email protected]",
    "password":"hello1212"
}

Reply:


{
    "message": "successfully registered"
}
  • Login:
    User sends: GET /api/v1/login:
{
    "email":"[email protected]",
    "password":"hello1212"
}

Reply:

{
    "id": "cf074995-c549-40d5-b7d7-da59318cf967",
    "first_name": "John",
    "last_name": "Pork",
    "username": "Johny1821",
    "balance": 0,
    "email": "[email protected]"
}

and tokens in cookies:
refresh_token: eyJhbGciOiJIUzI1NiIs...5iYcU
access_token: eyJhbGciOiJIUzI1NiIs...-cFhC7U

💳 Payment Flow

  1. User sends: POST /api/v1/auth/payment { "price": 129 } with cookies

  2. Main backend sends request via grpc to payment module

  3. Payment module sends request to yookassa and return response:

{
    "result": "https://yoomoney.ru/checkout/payments/v2/contract?orderId=318d8984-000f-5000-b000-14607dcab9c2"
}
  1. After confirming the payment in your personal yookassa account webhook updates payment status in payment Service.
    Then Payment Service triggers main backend via gRPC

  2. User sends: GET /api/v1/auth/get with cookies Reply:

{
    "id": "cf074995-c549-40d5-b7d7-da59318cf967",
    "first_name": "John",
    "last_name": "Pork",
    "username": "Johny1821",
    "balance": 129,
    "email": "[email protected]"
}

🚦 Getting Started

Prerequisites

  • Docker & Docker Compose
  • Go 1.21+ (for local development)

Configuration

  1. Clone the repository:

    git clone https://github.com/SH1roV12/BalanceApp.git
  2. Environment Setup: Define your .env file.

  3. Run docker compose

docker compose up
  1. Start ngrok
ngrok http HTTP_YOOKASSA_PORT 

and paste the link in your personal account in yookassa

  1. Use routes:
POST	/api/v1/new	
POST	/api/v1/login	
GET	/api/v1/users	
GET	/api/v1/refresh	
POST	/api/v1/auth/payment	JWT Middleware(send with cookies)
GET	/api/v1/auth/get	JWT Middleware(send with cookies)

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors