Skip to content

Commit

Permalink
Release v1.2.0 (#64)
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkusThielker authored Mar 24, 2024
2 parents b34f5e7 + 5a42108 commit c16ac9c
Show file tree
Hide file tree
Showing 45 changed files with 1,899 additions and 194 deletions.
8 changes: 8 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

#
# This environment file sets variables for the development
# Database specifics are set in the docker-compose file and the ORIGIN is not required for local development
#

# prisma database url
DATABASE_URL="postgresql://prisma:prisma@localhost:5432/finances?schema=public"
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,6 @@ next-env.d.ts

# IDE
/.idea

# serwist
public/sw.js
67 changes: 67 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,70 @@
# Next-Finances

This is my simple finances tracker that I use to keep track of my spending.

## Using the app

### Understanding the Basics

- **Entities**: The core building blocks of your finances.
- Accounts: Where you hold money (e.g., bank accounts, PayPal account, cash)
- Entities: Where you spend money (e.g., Walmart, Spotify, Netflix)
- **Payments**: Record money movement.
- Expenses: Money leaving an Account. (Account -> Entity)
- Income: Money entering an Account. (Entity -> Account)
- **Categories** *(optional)*: Add labels to Payments for better tracking.

### Your First Steps

- Set up: Create Entities and Accounts that reflect your finances.
- Record a Payment:
- Enter the amount and date.
- Select payor and payee
- *(optional)* Assign a category or enter a note.
- Explore: View your payment history and view your statics at the dashboard

### Tips

- Install the website as a PWA for easy access.
- Get in the habit of recording Payments as they happen for accurate tracking.
- Use categories to understand your spending patterns.

## Development

Clone this repository and run the following commands:

```bash

## create .env file
cp .env.example .env

## start the database
docker compose -f docker/finances-dev/docker-compose.yml up -d

## generate prisma client
npx prisma generate

## apply database migrations
npx prisma migrate deploy

## start the development server
npm run dev

```

Then open [http://localhost:3000](http://localhost:3000) with your browser and create an account.
While in development mode, you can generate sample data from the [Account page](http://localhost:3000/account).

## Deployment

Copy the [docker-compose.yaml](./docker/finances-prod/docker-compose.yaml) file and
the [.env.example](./docker/finances-prod/.env.example) from 'docker/finances-prod' to your server.

Rename the `.env.example` file to `.env` and adjust the required environment variables.

The docker setup expects you to run a Traefik reverse proxy. It will then register itself automatically.
If your setup is different, you will need to adjust the `docker-compose.yaml` file accordingly.

The finances containers will automatically register themselves to a running watchtower container if it is present.

Finally run `docker-compose up -d` on your server to start the application.
11 changes: 11 additions & 0 deletions docker/finances-prod/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

# database configuration
DB_USER="db_user"
DB_PASSWORD="db_password"

# prisma database url
DATABASE_URL="postgresql://$DB_USER:$DB_PASSWORD@postgres:5432/finances?schema=public"

APPLICATION_DOMAIN="finances.thielker.xyz"
COOKIE_DOMAIN="$APPLICATION_DOMAIN"
ORIGIN="https://$APPLICATION_DOMAIN"
4 changes: 2 additions & 2 deletions docker/finances-prod/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ services:
restart: unless-stopped
labels:
- "traefik.enable=true"
- "traefik.http.routers.xyz-next-finances.rule=Host(`finances.thielker.xyz`)"
- "traefik.http.routers.xyz-next-finances.rule=Host(`${APPLICATION_DOMAIN}`)"
- "traefik.http.routers.xyz-next-finances.entrypoints=web, websecure"
- "traefik.http.routers.xyz-next-finances.tls=true"
- "traefik.http.routers.xyz-next-finances.tls.certresolver=lets-encrypt"
Expand All @@ -46,7 +46,7 @@ services:
restart: unless-stopped
labels:
- "traefik.enable=true"
- "traefik.http.routers.xyz-next-finances-studio.rule=Host(`studio.finances.thielker.xyz`)"
- "traefik.http.routers.xyz-next-finances-studio.rule=Host(`studio.${APPLICATION_DOMAIN}`)"
- "traefik.http.routers.xyz-next-finances-studio.entrypoints=web, websecure"
- "traefik.http.services.xyz-next-finances-studio.loadbalancer.server.port=5555"
- "traefik.http.routers.xyz-next-finances-studio.tls=true"
Expand Down
13 changes: 13 additions & 0 deletions docker/finances-prod/traefik.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[entryPoints]
[entryPoints.web]
address = ":80"
# [entryPoints.web.http.redirections.entryPoint]
# to = "websecure"
# scheme = "https"

[entryPoints.websecure]
address = ":443"

[providers.docker]
watch = true
network = "web"
13 changes: 13 additions & 0 deletions docker/finances-prod/traefik_setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

#
# run this container on your server to use traefik as a reverse proxy
#
docker run -d \
-v /var/run/docker.sock:/var/run/docker.sock \
-v $PWD/traefik.toml:/traefik.toml \
-p 80:80 \
-p 443:443 \
--restart unless-stopped \
--network web \
--name traefik \
traefik:v2.10
13 changes: 13 additions & 0 deletions docker/finances-prod/watchtower_setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

#
# run this container on your server to keep the labeled containers up to date
#
# run 'docker login' to authenticate with your docker hub account
# label your containers with 'com.centurylinklabs.watchtower.enable=true' to enable watchtower
#
docker run -d \
--name watchtower \
--restart unless-stopped \
-v $HOME/.docker/config.json:/config.json \
-v /var/run/docker.sock:/var/run/docker.sock \
containrrr/watchtower -s "*/30 * * * * *" --label-enable
14 changes: 9 additions & 5 deletions next.config.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
/** @type {import('next').NextConfig} */
const nextConfig = {
import withSerwistInit from '@serwist/next';

const withSerwist = withSerwistInit({
swSrc: 'src/app/service-worker.ts',
swDest: 'public/sw.js',
});

export default withSerwist({
webpack: (config) => {
config.externals.push(
'@node-rs/argon2',
Expand All @@ -11,6 +17,4 @@ const nextConfig = {
env: {
appVersion: process.env.npm_package_version,
},
};

export default nextConfig;
});
Loading

0 comments on commit c16ac9c

Please sign in to comment.