A family expense tracking backend service for managing household finances, tracking expenses, and setting budget alerts on expense categories.
⚠️ Status: Implementation in progress
Nestled is the backend service that enables families to:
- Track income and expenses
- Organize transactions by categories
- Define and monitor budgets for each category
- Receive alerts when spending approaches or exceeds budget limits
- View financial reports and spending insights
- Language: Go 1.26.0
- Framework: Gin Web Framework
- Database: PostgreSQL 17
- Migrations: golang-migrate
- Testing: Go's built-in testing + testify + testcontainers
- ORM: sqlx
Before you begin, ensure you have installed:
- Go: 1.26.0 or later (download)
- PostgreSQL: 17 or later (for local development)
- OR Docker & Docker Compose (for containerized setup)
- migrate CLI: For running database migrations locally (installation)
git clone <repo-url>
cd nestledCopy the default configuration:
cp config.yml .envOr create a .env file with your database credentials:
DB_HOST=localhost
DB_PORT=5432
DB_USER=postgres
DB_PASSWORD=password
DB_NAME=nestled_db
GIN_MODE=debuggo mod download
go mod tidymake buildThis compiles the application and outputs a binary to bin/nestled.
go build -o bin/nestled cmd/main/main.go# Using Homebrew on macOS
brew services start postgresql
# Or using Docker
docker run -d \
--name nestled-db \
-e POSTGRES_USER=postgres \
-e POSTGRES_PASSWORD=password \
-e POSTGRES_DB=nestled_db \
-p 5432:5432 \
postgres:17make migrate-upmake runThe API will be available at http://localhost:8080
Start all services (PostgreSQL, migrations, and the app) with one command:
docker-compose up --buildThis will:
- Start PostgreSQL database
- Run all pending migrations
- Start the application on port 8080
Stop all services:
docker-compose downView logs:
docker-compose logs -f appmake testgo test ./internal/handlers -vgo test ./... -coverIntegration tests use testcontainers to automatically spin up a PostgreSQL container, run migrations, and tear down after completion.
Migrations are SQL scripts stored in the migrations/ directory and are automatically versioned.
make migrate-upOr with environment variables manually:
migrate -path migrations/ -database "postgres://postgres:password@localhost:5432/nestled_db?sslmode=disable" upmake migrate-downmake migrate-create name=add_user_preferencesThis creates two files:
migrations/000003_add_user_preferences.up.sql(applies the change)migrations/000003_add_user_preferences.down.sql(reverts the change)
nestled/
├── cmd/
│ └── main/
│ └── main.go # Application entry point
├── internal/
│ ├── config/ # Configuration management
│ ├── crypto/ # Cryptography utilities
│ ├── database/ # Database setup
│ ├── dto/ # Data transfer objects
│ ├── errors/ # Error definitions
│ ├── handlers/ # HTTP route handlers
│ ├── model/ # Domain models
│ ├── repositories/ # Data access layer
│ ├── routes/ # Route definitions
│ ├── services/ # Business logic
│ └── testhelpers/ # Testing utilities
├── migrations/ # SQL migrations
├── bin/ # Build outputs
├── config.yml # Configuration template
├── docker-compose.yml # Docker Compose setup
├── Dockerfile # Application Docker image
├── Makefile # Build and run targets
├── go.mod # Go module definition
└── README.md # This file
make lintRequires golangci-lint.
make cleanmake tidyThe API is built with Gin and provides RESTful endpoints for:
- Health Check:
GET /health - User Management: Registration, authentication (in development)
- Expense Tracking: CRUD operations for expenses
- Budget Management: Set and monitor budgets per category
- Reports: Financial summaries and insights (planned)
See the handlers in internal/handlers/ for detailed endpoint implementations.
# Create a feature branch
git checkout -b feature/your-feature-name
# Make changes, commit, and push
git add .
git commit -m "feat: add your feature"
git push origin feature/your-feature-name
# Create a pull requestThis project follows Go conventions:
- Format code with
go fmt - Follow Effective Go
- Write clear, idiomatic Go
If you see "unknown driver file" errors during tests, ensure the test helpers use the correct import path for golang-migrate (v4-compatible).
- Verify PostgreSQL is running:
psql -U postgres - Check environment variables match your database setup
- Ensure the database exists:
createdb nestled_db
- Create a feature branch
- Make your changes and write/update tests
- Run
make testandmake lintto verify - Submit a pull request
See LICENSE for details.
For issues or questions, please open an issue on the repository.