github.com/shoshinnikita/budget-manager@v0.7.1-0.20220131195411-8c46ff1c6778/README.md (about)

     1  # Budget Manager [![Last version](https://img.shields.io/github/v/tag/ShoshinNikita/budget-manager?label=version&style=flat-square)](https://github.com/ShoshinNikita/budget-manager/releases/latest) [![GitHub Workflow Status](https://img.shields.io/github/workflow/status/ShoshinNikita/budget-manager/check%20code?label=CI&logo=github&style=flat-square)](https://github.com/ShoshinNikita/budget-manager/actions) [![Go Report Card](https://goreportcard.com/badge/github.com/ShoshinNikita/budget-manager?style=flat-square)](https://goreportcard.com/report/github.com/ShoshinNikita/budget-manager)
     2  
     3  **Budger Manager** is an easy-to-use, lightweight and self-hosted solution to track your finances
     4  
     5  ![Month Page](./docs/images/month_page_large.png)
     6  
     7  It was inspired by [Poor-Man's Budgeting Spreadsheet](https://www.reddit.com/r/personalfinance/comments/2tymvf/poormans_budgeting_spreadsheet/) and [You have less money than you think (rus)](https://journal.tinkoff.ru/spreadsheet/). These projects have a fatal flaw: you can't add multiple spends in a single day. **Budger Manager** resolves that issue
     8  
     9  **Features:**
    10  
    11  - **Easy-to-use** - simple and intuitive UI
    12  
    13  - **Lightweight** - backend is written in [Go](https://golang.org/), HTML is prepared with [Go templates](https://golang.org/pkg/text/template/). 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 😉)
    14  
    15  - **Self-hosted** - you don't need to trust any proprietary software to store your financial information
    16  
    17  You can find more screenshots [here](./docs/images/README.md)
    18  
    19  ***
    20  
    21  - [Install](#install)
    22  - [Configuration](#configuration)
    23  - [Development](#development)
    24    - [Commands](#commands)
    25    - [Tools](#tools)
    26    - [Endpoints](#endpoints)
    27  
    28  ## Install
    29  
    30  You need [Docker](https://docs.docker.com/install/) and [docker-compose](https://docs.docker.com/compose/install/) (optional)
    31  
    32  1. Create `docker-compose.yml` with the following content (you can find more settings in [Configuration](#configuration) section):
    33  
    34      ```yaml
    35      version: "2.4"
    36  
    37      services:
    38        budget-manager:
    39          image: ghcr.io/shoshinnikita/budget-manager:latest
    40          container_name: budget-manager
    41          environment:
    42            DB_TYPE: postgres
    43            DB_PG_HOST: postgres
    44            DB_PG_PORT: 5432
    45            DB_PG_USER: postgres
    46            DB_PG_PASSWORD: <db password>
    47            DB_PG_DATABASE: postgres
    48            SERVER_AUTH_BASIC_CREDS: <your credentials> # more info in 'Configuration' section
    49          ports:
    50            - "8080:8080"
    51  
    52        postgres:
    53          image: postgres:12-alpine
    54          container_name: budget-manager_postgres
    55          environment:
    56            POSTGRES_USER: postgres
    57            POSTGRES_PASSWORD: <db password>
    58            POSTGRES_DB: postgres
    59          volumes:
    60            # Store data in ./var/pg_data directory
    61            - type: bind
    62              source: ./var/pg_data
    63              target: /var/lib/postgresql/data
    64      ```
    65  
    66  2. Run `docker-compose up -d`
    67  3. Go to `http://localhost:8080` (change the port if needed)
    68  4. Profit!
    69  
    70  ## Configuration
    71  
    72  | Env Var                   | Default value             | Description                                                                                                      |
    73  | ------------------------- | ------------------------- | ---------------------------------------------------------------------------------------------------------------- |
    74  | `LOGGER_MODE`             | `prod`                    | Logging format. `dev` or `prod`                                                                                  |
    75  | `LOGGER_LEVEL`            | `info`                    | Logging level. `debug`, `info`, `warn`, `error`, or `fatal`                                                      |
    76  | `DB_TYPE`                 | `postgres`                | Database type. `postgres` or `sqlite`                                                                            |
    77  | `DB_PG_HOST`              | `localhost`               | PostgreSQL host                                                                                                  |
    78  | `DB_PG_PORT`              | `5432`                    | PostgreSQL port                                                                                                  |
    79  | `DB_PG_USER`              | `postgres`                | PostgreSQL username                                                                                              |
    80  | `DB_PG_PASSWORD`          |                           | PostgreSQL password                                                                                              |
    81  | `DB_PG_DATABASE`          | `postgres`                | PostgreSQL database                                                                                              |
    82  | `DB_SQLITE_PATH`          | `./var/budget-manager.db` | Path to the SQLite database                                                                                      |
    83  | `SERVER_PORT`             | `8080`                    |                                                                                                                  |
    84  | `SERVER_USE_EMBED`        | `true`                    | Use the [embedded](https://pkg.go.dev/embed) templates and static files or read them from disk                   |
    85  | `SERVER_AUTH_DISABLE`     | `false`                   | Disable authentication                                                                                           |
    86  | `SERVER_AUTH_BASIC_CREDS` |                           | List of comma separated `login:password` pairs. Passwords must be hashed using BCrypt (`htpasswd -nB <user>`)    |
    87  | `SERVER_ENABLE_PROFILING` | `false`                   | Enable [pprof](https://blog.golang.org/pprof) handlers. You can find handler urls [here](internal/web/routes.go) |
    88  
    89  ## Development
    90  
    91  ### Commands
    92  
    93  #### Run
    94  
    95  ```bash
    96  # Run the app with installed Go and PostgreSQL in a Docker container
    97  make
    98  
    99  # Or run both the app and PostgreSQL in a Docker containers
   100  make docker
   101  ```
   102  
   103  #### Test
   104  
   105  ```bash
   106  make test
   107  ```
   108  
   109  #### More
   110  
   111  You can find more commands in [Makefile](./Makefile)
   112  
   113  ### Tools
   114  
   115  #### Linter
   116  
   117  [golangci-lint](https://github.com/golangci/golangci-lint) can be used to lint the code. Just run `make lint`. Config can be found [here](./.golangci.yml)
   118  
   119  #### API documentation
   120  
   121  [swag](https://github.com/swaggo/swag) is used to generate API documentation. You can find more information about API endpoints in section [API](#api)
   122  
   123  ### Endpoints
   124  
   125  #### Pages
   126  
   127  You can find screenshots of pages [here](./docs/images/README.md)
   128  
   129  - `/months` - Last 12 months
   130  - `/months/month?year={year}&month={month}` - Month info
   131  - `/search/spends` - Search for Spends
   132  
   133  #### API
   134  
   135  You can find Swagger 2.0 Documentation [here](docs/swagger.yaml). Use [Swagger Editor](https://editor.swagger.io/) to view it