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.
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)
Responsible for:
- User registration & login
- JWT authentication (access + refresh tokens)
- HTTP API (Fiber)
- Creating payment requests
- User balance management
Responsible for:
- Creating payment sessions via YooKassa
- Handling payment webhooks
- Tracking payment status
- Communicating payment result to main backend
- 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
-
User sends: POST /api/v1/auth/payment { "price": 129 } with cookies
-
Main backend sends request via grpc to payment module
-
Payment module sends request to yookassa and return response:
{
"result": "https://yoomoney.ru/checkout/payments/v2/contract?orderId=318d8984-000f-5000-b000-14607dcab9c2"
}
-
After confirming the payment in your personal yookassa account webhook updates payment status in payment Service.
Then Payment Service triggers main backend via gRPC -
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]"
}
- Docker & Docker Compose
- Go 1.21+ (for local development)
-
Clone the repository:
git clone https://github.com/SH1roV12/BalanceApp.git
-
Environment Setup: Define your .env file.
-
Run docker compose
docker compose up
- Start ngrok
ngrok http HTTP_YOOKASSA_PORT
and paste the link in your personal account in yookassa
- 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)