Skip to content

Commit

Permalink
add README ToC and some Contributing docs
Browse files Browse the repository at this point in the history
using the xgo pattern to cross-compile requires installing
a version of Docker Engine to host the xgo build containers

these readme updates point the way towards Docker's platform-
specific instructions on how to install Docker Engine on
various flavours of linux, as well as the docker-for-desktop
builds for MacOS and Windows

hopefully this can help others get up and running to build
and run godbledger code locally and assist with cross-compiling
in the future.
  • Loading branch information
davidalpert committed Nov 24, 2020
1 parent f258bdf commit c337812
Showing 1 changed file with 88 additions and 7 deletions.
95 changes: 88 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,22 @@
## Go DB Ledger
# Go DB Ledger

GoDBLedger is an open source accounting system that aims to make the recording of double entry bookkeeping transactions programmable. It provide users with normal features that most finance systems tend to lack such as api endpoints for your scripts and a database backend with a clear schema so you can analyse your financial data using your software of choice. The ultimate goal is for your whole financial process to be automated from data entry to compilation of financials/tax returns.

#### How it works:
- [How it works:](#how-it-works)
- [Executables](#executables)
- [Communicating with Godbledger and software examples](#communicating-with-godbledger-and-software-examples)
- [Database and configuration](#database-and-configuration)
- [Building the Proto Buffers](#building-the-proto-buffers)
- [SQL Querys](#sql-querys)
- [Contributing](#contributing)
- [Local Development](#local-development)
- [Build architecture](#build-architecture)
- [Cross-compiling with xgo/docker](#cross-compiling-with-xgodocker)
- [Install Docker Engine](#install-docker-engine)
- [TODO/Milestones](#todomilestones)


## How it works:
You are a business or individual wanting a system to record your profits and produce financial reports. You dont want to pay a cloud provider and you want to keep your financial data under your own control. You spin up a linux server (or raspberry pi) choose a database (Currently SQLite3 and MySQL are available) and you set up GoDBLedger to run on that server. You now have a place to send your double entry bookkeeping transactions which get saved into your own database!

GoDBLedger gives you an api for the recording of transactions and there are some command line binaries included to get you started.
Expand All @@ -26,7 +40,7 @@ https://discord.gg/xHFufYC
| `Ledger_cli` | A CLI client that can be used to transmit transactions to the server. |
| `Reporter` | Builds basic reports from the database on the command line. |

### Communicating with Godbledger and software examples
## Communicating with Godbledger and software examples

**GRPC and Proto Buffers**
The primary way to communicate with Godbledger is through the GRPC endpoint, submitting a transaction that contains your journal entry/transaction.
Expand Down Expand Up @@ -59,7 +73,7 @@ The PDF files are generated from [handlebars](https://handlebarsjs.com/) iterati

Templates can be viewed [here](https://github.com/darcys22/pdf-generator)

### Database and configuration
## Database and configuration

Godbledger will set a default configuration if none has been provided using Sqlite3 as the default database.

Expand All @@ -68,13 +82,13 @@ The config file can be found by default at:
~/.ledger/config.toml
```

### Building the Proto Buffers
## Building the Proto Buffers
Call from the root directory
```
protoc -I proto/ proto/transaction.proto --go_out=plugins=grpc:proto
```

### SQL Querys
## SQL Querys
default stored location for database is .ledger/ledgerdata `sqlite3 ledger.db`

**Select all transactions**
Expand All @@ -89,7 +103,74 @@ SELECT * FROM accounts where account_id in (select account_id from account_tag w
```

### TODO/Milestones
## Contributing

### Local Development

1. Install golang version 1.13 or higher for your OS and architecture:

- https://golang.org/doc/install

1. To build the `godbledger` executables natively for your OS and architecture you can simply use Make

```
make
```

The default make target is `build-native` which builds binaries native to your environment into the `./build/bin/native/` folder.

NOTE: on windows you may need to install a C++ tool chain (e.g. [`tdm-gcc`](https://jmeubank.github.io/tdm-gcc/)) in order to cross compile the sqlite dependency.

After building you can run the version you just built:

```
./build/bin/native/godbledger
```

1. Run the linter to discover any style or structural errors:

```
make lint
```

1. Run the tests

```
make test
```

NOTE: the test suite depends on the `build-native` target as it includes an integration test which spins up an instance of `godbledger`

### Build architecture

The primary entrypoint into the build scripts is the `Makefile` which provides the aforementioned build targets:
- `build-native` (default)
- `lint`
- `test`

All three of which call into the `./utils/ci.go` script to do the actual work of setting up required env vars, building the executiables, and configuring output folders.

An additional `./utils/make-release.sh` script is available to help orchestrate the creation of zip/tarfiles.

### Cross-compiling with xgo/docker

In addition to the default, native build target, the `Makefile` also offers a `build-cross` target which uses a forked version of `xgo` (https://github.com/techknowlogick/xgo) to build for different operating systems and architectures, including linux variants, a MacOS-compatible binary, and windows-compatible exe files.

```
make build-cross
```

Go tooling natively offers cross-compiling features when the `CGO_ENABLED=0` flag is set; `godbledger`'s `go-sqlite3` dependency however requires `CGO_ENABLED=1` in order to link in the C-level bindings for SQLite. Cross-compiling golang when `CGO` is enable is significantly more complicated as each platform and architecture can require a custom C++ toolchain.

`xgo` achieves consistency in cross-compilation using Docker, so running Docker Engine on your dev box is a requirement to running the `build-cross` target.

#### Install Docker Engine

The Docker web site includes detailed instructions on [installing and running Docker Engine](https://docs.docker.com/engine/install/) on a variety of supported platforms.

NOTE: if installing Docker Engine on a linux system make sure to follow the [Post-installation steps for Linux](https://docs.docker.com/engine/install/linux-postinstall/) in order to be able to run `docker` commands from local user accounts.

## TODO/Milestones
- ~~GoDBLedger server runs and accepts transactions~~
- ~~trial balance and transaction reports of journals~~
- ~~analyse database using metabase to create financial dashboard~~
Expand Down

0 comments on commit c337812

Please sign in to comment.