budget-manager

module
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 6, 2020 License: MIT

README

Budget Manager Last version GitHub Workflow Status Go Report Card

Budger Manager is an easy-to-use, lightweight and self-hosted solution to track your finances

Month Page

It was inspired by Poor-Man's Budgeting Spreadsheet and You have less money than you think (rus). These projects have a fatal flaw: you can't add multiple spends in a single day. Budger Manager resolves that issue

Features:

  • Easy-to-use - simple and intuitive UI

  • Lightweight - backend is written in Go, HTML is prepared with Go templates. Vanilla JavaScript is used just to make frontend interactive. So, JS code is very primitive and lightweight: it won't devour all your CPU and RAM (even with Chrome 😉)

  • Self-hosted - you don't need to trust any proprietary software to store your financial information

You can find more screenshots here


Install

You need Docker and docker-compose (optional)

  1. Create docker-compose.yml with the following content (you can find more settings in Configuration section):

    version: "2.4"
    
    services:
      budget-manager:
        image: docker.pkg.github.com/shoshinnikita/budget-manager/budget-manager:latest
        container_name: budget-manager
        environment:
          DB_TYPE: postgres
          DB_PG_HOST: postgres
          DB_PG_PORT: 5432
          DB_PG_USER: postgres
          DB_PG_PASSWORD: very_strong_password
          DB_PG_DATABASE: postgres
          SERVER_PORT: 8080
          SERVER_CREDENTIALS: your credentials # more info in 'Configuration' section
        ports:
          - "8080:8080"
    
      postgres:
        image: postgres:12-alpine
        container_name: budget-manager_postgres
        environment:
          POSTGRES_USER: postgres
          POSTGRES_PASSWORD: very_strong_password
          POSTGRES_DB: postgres
        volumes:
          # Store data in ./var/pg_data directory
          - type: bind
            source: ./var/pg_data
            target: /var/lib/postgresql/data
        command: -c "log_statement=all"
    
  2. Run docker-compose up -d

  3. Go to http://localhost:8080 (change the port if needed)

  4. Profit!

Configuration

Env Var Default value Description
DEBUG false Is Debug Mode on
LOGGER_MODE prod Logger mode. Available options: prod (or production), dev (or develop).
LOGGER_LEVEL info Min level of log messages. Available options: debug, info, warn, error, fatal.

Note: level is always debug when Debug Mode is on
DB_TYPE postgres Database type. Only postgres is available now
DB_PG_HOST localhost Host for connection to the db
DB_PG_PORT 5432 Port for connection to the db
DB_PG_USER postgres Use for connection to the db
DB_PG_PASSWORD Password for connection to the db
DB_PG_DATABASE postgres Database for connection
SERVER_PORT 8080
SERVER_CACHE_TEMPLATES true Defines whether templates have to be loaded from disk every request
SERVER_CREDENTIALS List of comma separated login:password pairs. Password must be encrypted with MD5 algorithm (you can use this command openssl passwd -apr1 YOUR_PASSWORD).

More info about password encryption: Password Formats - Apache HTTP Server
SERVER_SKIP_AUTH false Disables authentication. Works only in Debug mode!
SERVER_ENABLE_PROFILING false Enable pprof handlers. You can find handler urls here

Development

Commands
Run
# Run the app with 'go run' command and PostgreSQL in Docker container
make

# Or run both the app and PostgreSQL in Docker containers
make docker-run

After the launch you can use tools/api.rest file to make basic API requests. More info about the .rest and .http files:

Also you can use tools/fill_db.go script to fill the DB. This script makes POST requests to create Incomes, Monthly Payments, Spends and Spend Types.

Test
make test
More

You can find more commands in Makefile

Tools
Linter

golangci-lint can be used to lint the code. Just run make lint. Config can be found here

The recommended version of golangci-lint is v1.27.0

API documentation

swag is used to generate API documentation. You can find more information about API endpoints in section API

Mocks

Mocks are weakly used in tests. mockery was used to generate them. But it must be replaced with gomock due to the poor maintenance

Endpoints
Pages

You can find screenshots of pages here

  • /overview - Overview Page (it is not ready yet)
  • /overview/{year} - Year Page
  • /overview/{year}/{month_number} - Month Page
  • /search/spends - Search for Spends
API

You can find Swagger 2.0 Documentation here. Use Swagger Editor to view it

Directories

Path Synopsis
cmd
internal
db
Package db contains common entities (errors, models and etc).
Package db contains common entities (errors, models and etc).
db/pg
Package pg provides a PostgreSQL implementation for DB
Package pg provides a PostgreSQL implementation for DB
pkg/version
Package version contains global variables which must be set during the build process For example, version and commit hash
Package version contains global variables which must be set during the build process For example, version and commit hash
web
web/models
Package models contains models of requests and responses
Package models contains models of requests and responses
web/templates
Package templates provides a store for templates which supports caching
Package templates provides a store for templates which supports caching

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL