A Go-based expense tracking API that uses Gemini AI to parse natural language text (like SMS or chat) into structured financial transactions.
- AI Parsing: Converts "Spent 25 USD on coffee" into structured JSON using Gemini 1.5 Flash.
- Asynchronous Processing: Uses Redis and a worker pattern to handle AI requests without slowing down the API.
- Secure Auth: JWT-based authentication and Bcrypt password hashing.
- Infrastructure as Code: Fully containerized Postgres and Redis setup.
git clone https://github.com/yourusername/spender-backend.git
cd spender-backend
Create a .env file in the root directory:
# Database & Redis
DATABASE_URL=postgres://postgres:postgres@localhost:5432/spender?sslmode=disable
REDIS_ADDR=localhost:6379
# Secrets
JWT_SECRET=your_random_secret_string
GEMINI_API_KEY=your_google_api_key_here
docker-compose up -d postgres redis migrate
go mod tidy
go run cmd/apis/main.go
| Method | Endpoint | Description | Auth Required |
|---|---|---|---|
POST |
/register |
Create a new account | No |
POST |
/login |
Get JWT access token | No |
POST |
/api/notify |
Send raw text for AI parsing | Yes |
curl -X POST http://localhost:8080/api/notify \
-H "Authorization: Bearer <YOUR_TOKEN>" \
-d '{"rawText": "Dinner at Five Guys for 50 AED"}'
cmd/- Application entry points.internal/domain/- Business logic interfaces and models.internal/service/- Core logic (Auth, Engine, AI integration).internal/repository/- Database and Redis implementations.migration/- SQL schema files.
To verify the database tables were created:
docker exec -it spender_db psql -U postgres -d spender -c "\dt"