BudgetBuddyDE

Backend

The Backend is the central component of the web application and provides the API as well as the business logic.

Overview

CI Build StatusVersion

The Backend is based on Node.js with the Express.js Framework and is written in TypeScript. It provides a RESTful API that is used by the frontend application and other services. Most requests to the endpoints are authenticated and authorized by the Auth-Service to ensure that only authorized users have access to protected resources. The current user session is also integrated into the request context and the result set is filtered according to the user.

Features

  • RESTful API for providing data and business logic
  • Processing of Recurring Payments using a job

Jobs

process-recurring-payments

Scheduled at: 30 1 * * * (daily at 01:30 AM) in the timezone Europe/Berlin.

This job processes due recurring payments and creates corresponding transactions. It also takes into account months with fewer than 31 days by executing payments for non-existent calendar days at the end of the month. Paused payments are skipped and the entire process is logged.

Architecture

Technologies

Structure

Explain briefly the folder structure or important modules of the service.

src/
├── db/        # Contains database models and adapters to access the database
├── jobs/        # Contains functions for background jobs
├── lib/        # Contains library functions and initializations
├── middleware/        # Contains Express middleware functions
├── models/        # Providing classes and interfaces
├── types/        # Providing types and
├── config.ts        # Configuration file for the service
├── server.ts        # Main entry point of the application

API Documentation

MethodPathDescription
GET/healthHealth Check Endpoint

Development

Start service locally

# Install dependencies
npm install
 
# Copy environment variables
cp .env.example .env
 
# Start in development mode
npm run dev

Linting & Formatting

# Check linter
npm run check
 
# Automatically fix linter errors
npm run check:write
 
# Format code
npm run format

Configuration

Environment Variables

VariableDescriptionDefault Value
NODE_ENVExecution environment (development, production, test)development
DATABASE_URLConnection string to the database-
REDIS_URLConnection string for Redis cache-
REDIS_DBIndex of the Redis database1
TRUSTED_ORIGINSComma-separated list of trusted origins for CORS-
AUTH_SERVICE_HOSTHost URL under which the Auth Service is reachable-
LOG_LEVELLog level for the applicationinfo
LOG_HIDE_METAWhether to hide metadata in logsfalse
TIMEZONETimezone for the application (for scheduling jobs)Europe/Berlin
PORTPort on which the service runs9000
LOKI_URLURL for the Loki logging servicehttp://loki:3100
TEMPO_URLIngest URL for the Tempo tracing servicehttp://tempo:4318

Logs & Traces

The environment variable TEMPO_URL is only required if the server is started with tracing functionality (via instrumentation.js or npm run start:instrumentation) and logs are to be transmitted. If the environment variable LOKI_URL is not set, logs will be output "locally" to the console.

Database Migrations

The environment variable DATABASE_URL must be set for migrations to be executed.

Database migrations are managed using Drizzle Kit. To create a new migration (for the database), the following command can be used:

npm run db:generate

Using the following command, the migrations can be applied to the database:

npm run db:migrate

Deployment

Information about the deployment process (e.g. Docker, CI/CD Pipelines).

Docker

The service can be containerized and deployed using the Dockerfile in the repository. The following command can be used for this:

docker pull ghcr.io/budgetbuddyde/backend:latest
docker run -d -p 9000:9000 --env-file ./path/to/env/file ghcr.io/budgetbuddyde/backend:latest

Additionally, a docker-compose.yml file is available in the repository, which can be used to start the service locally together with a PostgreSQL and Redis instance.

Railway

BudgetBuddyDE is designed to be easily deployable on Railway.

Deploy on Railway

Dependencies

The Auth Service uses the following internal packages:

and requires the following external services:

On this page