Backend
The Backend is the central component of the web application and provides the API as well as the business logic.
Overview
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
- Framework: Express.js
- Language: TypeScript
- Database: PostgreSQL
- Cache: Redis
- ORM: Drizzle Kit
Structure
Explain briefly the folder structure or important modules of the service.
API Documentation
| Method | Path | Description |
|---|---|---|
| GET | /health | Health Check Endpoint |
Development
Start service locally
Linting & Formatting
Configuration
Environment Variables
| Variable | Description | Default Value |
|---|---|---|
NODE_ENV | Execution environment (development, production, test) | development |
DATABASE_URL | Connection string to the database | - |
REDIS_URL | Connection string for Redis cache | - |
REDIS_DB | Index of the Redis database | 1 |
TRUSTED_ORIGINS | Comma-separated list of trusted origins for CORS | - |
AUTH_SERVICE_HOST | Host URL under which the Auth Service is reachable | - |
LOG_LEVEL | Log level for the application | info |
LOG_HIDE_META | Whether to hide metadata in logs | false |
TIMEZONE | Timezone for the application (for scheduling jobs) | Europe/Berlin |
PORT | Port on which the service runs | 9000 |
LOKI_URL | URL for the Loki logging service | http://loki:3100 |
TEMPO_URL | Ingest URL for the Tempo tracing service | http://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:
Using the following command, the migrations can be applied to the database:
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:
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.
Dependencies
The Auth Service uses the following internal packages:
and requires the following external services:
- Resend for sending emails
BudgetBuddyDE