This repository contains a backend solution for the technical challenge proposed by FinTech Solutions Inc.. The goal is to build two API services in Go:
-
Migration Service (
POST /migrate)
Uploads and processes historical transaction data from CSV files into a PostgreSQL database. -
Balance Service (
GET /users/{user_id}/balance)
Retrieves a user's balance summary, with optional date filtering.
The system is designed to be robust, scalable, and easy to deploy locally using Docker.
The project follows a layered architecture to promote separation of concerns and modularity:
- Presentation Layer (Handlers): Handles HTTP requests and delegates logic to services.
- Service Layer (Business Logic): Encapsulates core rules like CSV parsing and balance calculations.
- Repository Layer (Data Access): Abstracts database operations using the Repository Pattern.
- SRP: Each component has a single responsibility.
- DIP: Services depend on interfaces, not concrete implementations.
- Repository Pattern: Decouples persistence from business logic.
- Service Layer Pattern: Keeps transport logic (HTTP) separate from core rules.
- Language: Go (Golang)
- Database: PostgreSQL
- Containers: Docker & Docker Compose
- Libraries:
go-chi/chi— HTTP routingrs/zerolog— Structured loggingsethvargo/go-envconfig— Environment configpgx&database/sql— PostgreSQL driversencoding/csv— CSV parsingswaggo/swag— Swagger documentation
- Docker & Docker Compose installed
git clone https://github.com/Sirpyerre/fintech-backend.git
cd fintech-backend
docker-compose up --buildThe API will be available at:
http://localhost:8080
POST /migrate
- Upload a CSV file with transactions.
- Header:
Content-Type: multipart/form-data - Field name:
file - Expected columns:
id,user_id,amount,datetime
GET /users/{user_id}/balance
- Returns balance, total credits, and total debits.
Optional query params:
from: Start date (RFC3339)to: End date (RFC3339)
{
"balance": 25.21,
"total_debits": 10,
"total_credits": 15
}📎 Swagger UI: /swagger/index.html
- Structured logging with
zerolog
Run unit tests for services:
go test ./internal/services/...Includes coverage for:
- Migration logic
- Balance calculations
- Error handling
- Add Redis caching for frequent balance queries
- Improve CSV validation and error reporting
- Add integration tests with real DB
- Implement graceful shutdown and health checks
- Extend Swagger with response examples and error codes
MIT — free to use, modify, and share.