Active Allocator - React & .NET Core API

An API and Web App for managing budgets with allocations (buckets of funds based on history) and interfacing with Banks, and FireFlyIII.

I started with this tutorial. Here is another one that is handy for good structure.

Reference for adding JWT authentication is here.

Docker Repository Usage

Requirements

User Interface

Use layoutit.com.

React Select

  • View Income overview

    • Projected Income - Based on statistical metrics (with controls for fine-tuning sample date range)
    • Historical Income (with source breakdown)
  • View Allocations (Budgets)

    • View balances for any given date (defaulting today)
    • Show total allocated amount for each account in the given timeframe
    • Detail View for each account
      • Recent Transactions
    • Edit allocation rules for a given account
  • Broad Settings

    • Timescale of App (month? 2-week? quarter?)
    • Choose statistical metrics for estimating allocation amount (default to simple average (with lookback range))

Guides

Easy background worker guide

Back-end Functions

Accounts & Envelopes

Each transaction has these fields, all nullable:

Debit Account (DA)
Credit Account (CA)

Debit Envelope (DE)
Credit Envelope (CE)

Debit denotes that the entity is having value removed from it.

Credit denotes that the entity is having value added to it.

If an account or envelope is null we call it (void), a placeholder entity that isn't tracked.

Scenarios

Conflicting Debit & Credit Entities

If (DA != null && DE.Account != DA)
If (CA != null && CE.Account != CA)
If (DE.Account != DA)
If (DE.Account != DA)
If (DE.Account != DA)
Envelopes Affecting Accounts

If Envelope Accounts differ, account transfer is performed as well as envelope value adjusting.
If Envelopes use the same Account (or null envelope) Account value is unaffected.

Operations with Envelopes should always trigger an update to the virtual balance of the underlying account.

DA -> CA
DE -> CE

Value is deducted from DA
Value is added to CA
Value is deducted from DE
Value is added to CE
DE.A Value isn't necessarily changed
CE.A Value isn't necessarily changed
if (DA != null)
{
    addAmount(DA, -amount);
}

if (DE != null)
{
    addAmount(DE, -amount);
}

if (CA != null)
{
    addAmount(CA, amount);
}

if (CE != null)
{
    addAmount(CE, amount);
}
DA -> CA
null -> null

Value is deducted from DA
Value is added to CA
DA -> null
null -> null

Value is deducted from DA
null -> CA
null -> null

Value is added to CA
null -> null
DE -> CE

Value is deducted from DE
If DE Account differs from CE Account,
    then value must also be transferred between accounts

Value is added to CE
null -> null
DE -> null

Value is deducted from DE
Virtual Value is returned to Envelope Account

Add virtual balance to account

Debit Account -> Credit Envelope = true Debit Envelope -> Credit Account = true Debit Account -> (void) = false (void) -> Credit Account = false Debit Envelope -> (void) = false (void) -> Credit Envelope = false

Debit Account & Debit Envelope -> Credit Envelope = error

Dev Environment Setup

On Archlinux install the following to use dotnet: sudo pacman -Sy dotnet-sdk dotnet-runtime aspnet-runtime.

For Archlinux install docker with sudo pacman -Sy docker docker-compose.

Then run systemctl start docker.service and systemctl enable docker.service to start and enable on boot the docker engine.

When running pgAdmin (a container in the docker compose stack) if there are errors about permission denied, you will need to set the owner of the directory to user 5050. You can do this with:

sudo chown -R 5050:5050 ./Postgres/pg-admin_data

You may also need to allow full rwx (Read, Write, and Execute) rights on the directory.

sudo chmod -R 777 ./Postgres/pg-admin_data

Install React dependencies if needed - npm install in the ClientApp directory.

Download 'Reverse Engineering' Tools

dotnet tool install --global dotnet-ef
dotnet tool install --global dotnet-aspnet-codegenerator

Confirm it is working with dotnet ef.

Scaffolding

  1. Create Entity (or Model) for object.
  2. Add DbSet<object> entry in your DbContext.
  3. Migration
  4. Endpoints (if needed)

To add Migration for new entity:

dotnet ef migrations add InitialCreate
dotnet ef database update

For generating API endpoints for an entity called Note:

$HOME/.dotnet/tools/dotnet-aspnet-codegenerator controller -name NotesController -async -api -m Note -dc MyDBContext --relativeFolderPath Controllers

Deploying

Create Docker Image

Running sudo dotnet publish will create a docker image targetting linux x64 with the "DefaultContainer" profile and image name of "cavaliercraftsmen.site". Edit the .csproj file to change the version of the image.

To create a docker image explicitly run sudo dotnet publish --os linux --arch x64 -p:PublishProfile=DefaultContainer -p:ContainerImageName=cavaliercraftsmen.site in the same folder as the dotnet solution. Because we added the Microsoft.NET.Build.Containers package, we don't actually need to use the Dockerfile.

Pushing Docker Image

You will have to be logged in. sudo docker login gitea.veritablevalor.com

First tag sudo docker tag <image_id> gitea.veritablevalor.com/blizliam/cavaliercraftsmen.site:latest (check that the version is right).

Then push sudo docker push gitea.veritablevalor.com/blizliam/cavaliercraftsmen.site:latest.

Using API

API should be something like - https://localhost:7260/swagger

Description
An API and Web App for managing budgets with allocations (buckets of funds based on history) and interfacing with Banks, and FireFlyIII.
Readme 21 MiB
v1.0.0 Latest
2024-02-02 17:15:36 -06:00
Languages
C# 50.2%
JavaScript 48.4%
HTML 0.5%
SCSS 0.5%
CSS 0.3%