Financer is a simple financial tracker app that helps you track monthly expenses, income, savings, and investments.
- 🚀 Quick Start
- Requirements
- Create an OAuth App for Development
- Local Development Setup
- Start the Development Environment
- Installing New Dependencies
- Updating Types
- Testing Guide
- Production Tooling
- Update the Database version
- 1. Create a new backup from the database
- 2. Check that the backup was successful
- 3. If the job status is Completed, delete the manual job
- 4. Delete the existing PostgreSQL cluster
- 5. Deploy a new PostgreSQL instance with the latest version, update image tag before applying
- 6. Wait for the new PostgreSQL instance to be ready
- 7. List all backups in the /backup folder
- 8. Restore the backup to the new PostgreSQL instance
- 9. Restart the web application deployment to refresh the DB connection
- Update the Database version
- Adding
TEST_ROLEto Users (Development Only) - Authors
Follow this guide to quickly set up your local development environment.
- Docker
- Docker Compose
- NVM
- GitHub account (for OAuth setup)
- Visit the GitHub Developer Settings and click
New OAuth App. - Fill out the form with the following details:
- Application Name: Can be anything you like.
- Homepage URL:
http://localhost:3000/ - Authorization Callback URL:
http://localhost:3000/auth/github/redirect
- Register the application.
git clone git@github.com:sebarickert/financer.git
cd financercd backend
cp .env .env.localEdit the .env.local file and add your GITHUB_CLIENT_ID and GITHUB_CLIENT_SECRET.
nvm use # Install Node version (via nvm)
npm ci # Install dependenciesnpm startnpm -w frontend install DEPENDENCY-NAMEnpm -w backend install DEPENDENCY-NAMETo update the types, run:
npm run types:updateThis will export the types from the backend, copy the API spec to the frontend, and generate the necessary types for both the frontend and Playwright.
By following these commands, you can ensure that your codebase remains robust and maintainable.
To ensure the quality and reliability of the application, we have set up various testing commands. Below are the commands you can use to run different types of tests:
To run unit tests for both the backend and frontend, use the following command:
npm run testWe use Playwright for end-to-end testing. You can run the tests using the following commands:
- To run all end-to-end tests:
npm run e2e:test- To run end-to-end tests against an external server:
npm run e2e:test:external- To open the Playwright test UI:
npm run e2e:open- To open the Playwright test UI against an external server:
npm run e2e:open:externalTo check the types across the workspace, use:
npm run check-typeskubectl create job --from=cronjob/postgres-backup postgres-backup-manual -n financerkubectl get pods -n financerYou should find jobs postgres-backup-manual-xxxxx with status Completed. Example output:
NAME READY STATUS RESTARTS AGE
postgres-backup-manual-x2nt9 0/1 Completed 0 61skubectl delete job postgres-backup-manual -n financerkubectl delete -f kubernetes/production.postgres-deployment.yamlkubectl apply -f kubernetes/production.postgres-deployment.yamlkubectl rollout status statefulset/postgres-deployment -n financerkubectl run -i --tty --rm list-backups --image=busybox --restart=Never --namespace=financer --overrides='
{
"apiVersion": "v1",
"spec": {
"containers": [
{
"name": "list-backups",
"image": "busybox",
"stdin": true,
"tty": true,
"command": ["/bin/sh", "-c", "ls -lh /backup"],
"volumeMounts": [
{
"name": "backup-volume",
"mountPath": "/backup"
}
]
}
],
"volumes": [
{
"name": "backup-volume",
"persistentVolumeClaim": {
"claimName": "postgres-backup-volume"
}
}
]
}
}'Note: Please find the backup name from the list-backups output and use the backup that you created in step 1.
BACKUP_NAME=financer_20XX-XX-XX_XX-XX.backup
kubectl run -i --tty --rm postgres-restore --image=postgres:latest --restart=Never --namespace=financer --overrides="
{
\"apiVersion\": \"v1\",
\"spec\": {
\"containers\": [
{
\"name\": \"postgres-restore\",
\"image\": \"postgres:latest\",
\"stdin\": true,
\"tty\": true,
\"command\": [\"/bin/sh\", \"-c\", \"PGPASSWORD=\$POSTGRES_PASSWORD pg_restore -U \$POSTGRES_USER -h \$POSTGRES_HOST -p \$POSTGRES_PORT -d \$POSTGRES_DB /backup/$BACKUP_NAME\"],
\"env\": [
{
\"name\": \"POSTGRES_DB\",
\"value\": \"financer\"
},
{
\"name\": \"POSTGRES_USER\",
\"value\": \"admin\"
},
{
\"name\": \"POSTGRES_HOST\",
\"value\": \"postgres\"
},
{
\"name\": \"POSTGRES_PORT\",
\"value\": \"5432\"
},
{
\"name\": \"POSTGRES_PASSWORD\",
\"valueFrom\": {
\"secretKeyRef\": {
\"name\": \"database-credentials\",
\"key\": \"DB_PASSWORD\"
}
}
}
],
\"volumeMounts\": [
{
\"name\": \"backup-volume\",
\"mountPath\": \"/backup\"
}
]
}
],
\"volumes\": [
{
\"name\": \"backup-volume\",
\"persistentVolumeClaim\": {
\"claimName\": \"postgres-backup-volume\"
}
}
]
}
}"kubectl rollout restart deployment webapp-deployment -n financerFor development purposes, you can assign the TEST_ROLE to all users by running the following command:
npm run setup:development-users- Sebastian Rickert - sebarickert
- Teemu Sillantaus - silte