Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

104 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

BudgetGenius

image

Smart personal finance management β€” track expenses, set budgets, and achieve your financial goals with AI-powered insights.

Status License Version Node

---

πŸ“– Table of Contents


πŸ“‹ Overview

BudgetGenius is a full-stack web application that helps users manage their personal finances through an intuitive budgeting tool. Users can track income and expenses, create custom budgets with categories, set savings goals, monitor progress with visual dashboards, and receive AI-powered financial insights from "Finny", our bilingual financial assistant.

The application follows a Clean Architecture pattern across both its frontend and backend, with strict layer separation ensuring maintainable, testable code.

Core Capabilities

  • Expense & Income Tracking β€” Log, categorize, and monitor all financial transactions
  • Budget Planning β€” Create custom budgets with categorized allocations and real-time spending tracking
  • Financial Goals β€” Set short-term and long-term goals with progress visualization
  • Savings Goals β€” Track saving progress with target dates and percentage completion (Premium)
  • Investment Tracking β€” Monitor investment portfolio performance (Premium)
  • Reports & Analytics β€” Generate detailed financial reports with charts (Premium)
  • AI Financial Assistant ("Finny") β€” Get personalized insights and advice powered by OpenAI
  • Multi-Authentication β€” Email/password, Google OAuth 2.0, and Firebase authentication
  • Bilingual Support β€” Full English & Spanish support across the AI assistant

πŸ— Architecture

alt text

                        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                        β”‚     webClient         β”‚
                        β”‚   React 19 + Vite 6   β”‚
                        β”‚   Tailwind + Recharts β”‚
                        β”‚      Port 3001        β”‚
                        β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                    β”‚ HTTP (axios)
                                    β”‚
                        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                        β”‚         api           β”‚
                        β”‚      NestJS 10        β”‚
                        β”‚  TypeORM + Passport   β”‚
                        β”‚      Port 3000        β”‚
                        β””β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”˜
                            β”‚       β”‚       β”‚
                    β”Œβ”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β” β”Œβ”€β”€β–Όβ”€β”€β”€β” β”Œβ–Όβ”€β”€β”€β”€β”€β”€β”
                    β”‚PostgreSQLβ”‚ β”‚Redis β”‚ β”‚OpenAI β”‚
                    β”‚   15     β”‚ β”‚ 7.2  β”‚ β”‚  GPT  β”‚
                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”˜

Layered Architecture (Clean Architecture)

Both apps follow the same layered architecture with strict dependency rules:

Layer Responsibility Backend Path Frontend Path
Domain Entities, repository interfaces, value objects src/domain/ src/domain/
Application Business logic, service orchestration src/application/ src/application/
Infrastructure Technical details: config, modules, middleware src/infrastructure/ src/infrastructure/
Adapters External interfaces: controllers, HTTP repositories src/adapters/ src/adapters/
Presentation UI components, pages, layouts, routes β€” src/presentation/

Dependencies always point inward β€” Domain never imports from outer layers.

Monorepo Structure

This project uses a pnpm workspace monorepo with Turbo for build orchestration:

BudgetGenius/
β”œβ”€β”€ apps/
β”‚   β”œβ”€β”€ api/              # NestJS backend (TypeScript)
β”‚   β”œβ”€β”€ webClient/        # React frontend (TypeScript + Vite)
β”‚   └── mobile/           # Capacitor native wrapper (Android APK)
β”œβ”€β”€ docs/
β”‚   └── rpi/              # RPI Development Framework docs
β”œβ”€β”€ scripts/
β”‚   └── bootstrap.sh      # One-command setup
β”œβ”€β”€ docker-compose.yml     # Base Docker services
β”œβ”€β”€ docker-compose.dev.yml # Development overrides
β”œβ”€β”€ docker-compose.prod.yml# Production overrides
└── turbo.json             # Turbo pipeline config

πŸ›  Tech Stack

Backend (apps/api)

Technology Purpose
NestJS 10 Server-side framework with modular architecture
TypeScript 5.7 Type-safe development
TypeORM 0.3 Object-Relational Mapping for PostgreSQL
PostgreSQL 15 Primary relational database
Redis 7.2 Caching, session store, rate limiting, AI history
Passport.js Authentication middleware (JWT + Google OAuth)
Firebase Admin SDK Firebase token verification
OpenAI SDK AI financial assistant integration
Swagger/OpenAPI Auto-generated API documentation
Winston + Morgan Structured logging and HTTP request logging

Frontend (apps/webClient)

Technology Purpose
React 19 UI library with functional components
Vite 6 Fast development server and build tool
TypeScript 5.7 Type-safe development
Tailwind CSS 3 Utility-first CSS framework
Redux Toolkit Client-side state management (auth, settings)
React Query (TanStack) Server state management and caching
React Router 7 Client-side routing with lazy loading
Recharts Composable charting library
Lucide React Icon library
Axios HTTP client with interceptors

Mobile (apps/mobile)

Technology Purpose
Capacitor 7 Native wrapper for Android (and iOS) β€” wraps the Vite build output
@capgo/capacitor-social-login Native Android Credential Manager plugin (replaces the older @capacitor-firebase/authentication flow which opened Chrome Custom Tabs β€” see docs/changelog.md v1.2.0)
Android Gradle Build system for Android APK generation

DevOps & Infrastructure

Technology Purpose
Docker + Docker Compose Containerized development and deployment
GitHub Actions CI/CD pipeline (test, build, deploy)
Turbo Monorepo task orchestration
pnpm Fast, disk-efficient package manager
Vercel Frontend hosting
Firebase Hosting Static asset hosting
AWS RDS Managed PostgreSQL (production)
Playwright End-to-end browser testing
Jest Backend unit and e2e testing

✨ Features

πŸ” Authentication & Authorization

  • Multi-provider auth: Email/Password, Google OAuth 2.0, Firebase
  • JWT access tokens (1h) with refresh token rotation (7d in Redis)
  • Rate limiting: 4 requests per 10 seconds per device
  • Role-based access control (User/Admin)
  • Premium feature gating

πŸ’° Transaction Management

  • Full CRUD operations on transactions
  • Categorization and status tracking
  • Date-based filtering and sorting
  • Paginated transaction lists

πŸ“Š Budget Planning

  • Create budgets with custom date ranges
  • Category-based allocation tracking
  • Real-time spending vs. allocated comparison
  • Visual progress indicators

🎯 Financial Goals

  • Short-term and long-term goal tracking
  • Target amounts with current progress
  • Contribution frequency settings
  • Visual percentage completion

πŸ’Ž Premium Features

  • Savings goals with color-coded progress
  • Detailed financial reports and analytics
  • Investment portfolio tracking

πŸ€– AI Financial Assistant ("Finny")

  • Context-aware financial advice
  • Bilingual (English/Spanish) interaction
  • Conversation history stored in Redis
  • System prompt tailored to user's financial data

🌐 Localization

  • Currency, timezone, and locale preferences per user
  • Bilingual AI responses

πŸš€ Getting Started

Prerequisites

  • Node.js v18 or higher
  • pnpm v10.x (install: npm install -g pnpm)
  • Docker & Docker Compose (for PostgreSQL and Redis)

First-Time Setup

Option A: Quick Start with Bootstrap (Recommended)

This single command handles everything:

git clone <repository-url>
cd BudgetGenius
chmod +x scripts/bootstrap.sh
./scripts/bootstrap.sh

The bootstrap script automates:

  1. βœ… Checks prerequisites (Node.js, pnpm)
  2. βœ… Installs all workspace dependencies via pnpm install
  3. βœ… Creates .env.development from templates with generated JWT secret
  4. βœ… Starts Docker services (PostgreSQL + Redis) via docker compose
  5. βœ… Builds backend and frontend container images

Option B: Manual Setup

# 1. Install dependencies
pnpm install

# 2. Create environment files
cp apps/api/.env.example apps/api/.env.development
cp apps/webClient/.env.example apps/webClient/.env.development

# 3. Edit apps/api/.env.development with your values:
#    - Set JWT_SECRET (generate: openssl rand -hex 32)
#    - DB_HOST=localhost, DB_USER=postgres_admin_dev
#    - DB_PASS=dev_password, DB_NAME=budgetgenius_dev
#    - REDIS_HOST=localhost, REDIS_PORT=6379

# 4. Start Docker services (PostgreSQL + Redis only)
docker compose -f docker-compose.yml -f docker-compose.dev.yml up -d database redis

After Bootstrap β€” What's Next?

Once the bootstrap script finishes (or you start Docker manually), follow these steps in order:

1. Verify Services are Running

# Check that PostgreSQL and Redis are healthy
docker ps --filter name='bg-'

# Expected output:
# bg-db-dev     ... (healthy)    ports: 5432
# bg-redis-dev  ... (healthy)    ports: 6379

2. Run Database Migrations

Migrations create the required tables in the bg_public schema:

pnpm --filter api migration:run

Note: If you used the full bootstrap (which starts all Docker containers), the Docker backend auto-runs migrations on startup β€” so they're already applied. Running this again locally is safe; it will simply report "no pending migrations." If you only started database and redis containers (without the backend), you'll need to run migrations manually here.

❗ If this command fails with EAI_AGAIN database or password authentication failed, your shell may have stale environment variables from an old root .env file. See the Stale Environment Variables section below to fix it.

3. Start the Development Servers

pnpm dev

This starts both the NestJS backend and the Vite frontend with hot reload via Turbo.

4. Access the Application

Service URL (Mode A β€” local dev) URL (Mode B β€” Docker) Description
🌐 Frontend http://localhost:5173 (Vite) http://localhost:3001 (nginx) React SPA
πŸš‚ Backend API http://localhost:5000 http://localhost:3000 NestJS REST API (binds process.env.PORT || 5000, see apps/api/src/main.ts)
πŸ“š Swagger Docs http://localhost:5000/docs http://localhost:3000/docs Interactive API documentation
🐘 PostgreSQL localhost:5432 localhost:5432 (via Docker port mapping) Schema bg_public (user: postgres_admin_dev, pass: dev_password, db: budgetgenius_dev)
πŸ”΄ Redis localhost:6379 localhost:6379 (via Docker port mapping) Cache, refresh tokens, throttle buckets

Wave 1 [T1.6] reconciliation note: the architecture diagram and this table show both Mode A and Mode B ports side-by-side. Mode A = pnpm dev (Vite + nest start, hot reload). Mode B = docker compose up (nginx + image-baked NestJS). The .env.development files always keep Mode A defaults (localhost:5000 for backend); Docker overrides them to redis/database hostnames via docker-compose.dev.yml.

5. Default Users (Auto-Seeded)

On first startup, the backend automatically creates two test users:

Role Email Password Premium?
πŸ‘‘ Admin admin@admin.com #Password123 βœ… Yes
πŸ‘€ User normal@normal.com #Password123 ❌ No

You can log in with either account immediately.


πŸ’» Web Development Workflow

Daily Development Cycle

Each time you come back to work on the project:

# 1. Start Docker services (if not already running)
docker compose -f docker-compose.yml -f docker-compose.dev.yml up -d database redis

# 2. Run any new migrations (if entities were changed)
pnpm --filter api migration:run

# 3. Start the dev servers
pnpm dev

🐳 Two Development Modes

The project supports two complementary workflows. Choose based on what you need:

Mode A: Docker for Data Services + Local Dev Servers (Recommended)

# Terminal 1 β€” Start only PostgreSQL and Redis in Docker
docker compose -f docker-compose.yml -f docker-compose.dev.yml up -d database redis

# Terminal 2 β€” Start backend and frontend with hot reload
pnpm dev

⚠️ Important: In this mode, the backend runs on port 5000 (not 3000). Make sure your frontend .env.development has VITE_API_URL=http://localhost:5000/api. If you ran pnpm bootstrap and chose "Y" for Docker, it set VITE_API_URL=http://localhost:3000/api β€” edit it to port 5000 for Mode A.

Why choose this?

  • βœ… Hot reload on code changes (NestJS watches for file changes)
  • βœ… Faster iteration β€” no need to rebuild Docker images
  • βœ… Full TypeScript debugging support
  • βœ… Frontend served by Vite dev server on port 5173 or by nginx on port 3001

Mode B: Everything in Docker (CI/Production-like)

# Build and start all containers
docker compose -f docker-compose.yml -f docker-compose.dev.yml up -d --build

# View logs
docker compose logs -f

Why choose this?

  • βœ… Exact replica of production environment
  • βœ… Migrations run automatically on container start
  • βœ… Useful for testing Docker-specific issues
  • ❌ No hot reload β€” you must rebuild the image for each code change

Stopping Everything

# Stop dev servers β€” press Ctrl+C in the terminal running pnpm dev

# Stop Docker services (data persists in named volumes)
docker compose -f docker-compose.yml -f docker-compose.dev.yml down

# Stop Docker services AND delete all data (reset database)
docker compose -f docker-compose.yml -f docker-compose.dev.yml down -v

⚠️ Common Pitfall: Stale Environment Variables

Docker Compose reads a .env file from the project root and injects its variables into your shell environment. If you previously had a root .env file with values like DB_HOST=database, DB_USER=postgres_admin_prod, or DB_PASSWORD=<production-password>, these will persist in your shell session and override the local localhost values in apps/api/.env.development.

Symptoms:

  • pnpm --filter api migration:run fails with EAI_AGAIN database (can't resolve Docker hostname)
  • Backend connects to wrong database or uses wrong credentials
  • password authentication failed errors despite correct .env.development

Fix:

# 1. Remove the root .env file if it has conflicting vars
mv .env .env.bak

# 2. Clear the stale variables from your current shell (important!)
unset DB_HOST DB_PORT DB_USER DB_PASSWORD DB_PASS DB_NAME DB_URL
unset REDIS_HOST REDIS_PORT REDIS_URL REDIS_PASSWORD

# 3. Verify they're gone β€” all should be empty
echo $DB_HOST $DB_USER $DB_PASSWORD $REDIS_HOST

The bootstrap script no longer creates a root .env file to avoid this issue.


Common Commands Reference

Command Description
pnpm bootstrap One-command first-time setup (deps + env + Docker)
pnpm dev Start all services in development mode
pnpm build Build entire workspace
pnpm test Run all test suites
pnpm --filter api dev Start backend only
pnpm --filter frontend-web dev Start frontend only
pnpm --filter mobile dev:android Sync Capacitor config for dev mode (hot reload)
pnpm --filter mobile build Build webClient + sync APK assets
pnpm --filter mobile build:android Sync + open Android Studio
pnpm --filter mobile sync Sync Capacitor config only
pnpm --filter api test Run backend tests (Jest)
pnpm --filter frontend-web test Run frontend E2E tests (Playwright)
pnpm --filter api lint Lint backend code
pnpm --filter frontend-web lint Lint frontend code
pnpm --filter api migration:run Run pending migrations
pnpm --filter api migration:create Create new DB migration
pnpm --filter api migration:revert Revert last migration

Database Migrations

When running in Docker (Mode B), migrations run automatically on container start.

When developing locally (Mode A), run migrations manually:

cd apps/api

pnpm run migration:show      # Show migration status
pnpm run migration:generate  # Auto-generate migration from entity changes
pnpm run migration:create    # Create empty migration file
pnpm run migration:run       # Apply pending migrations
pnpm run migration:revert    # Revert the last migration

Docker Service Management

# Start all services
docker compose -f docker-compose.yml -f docker-compose.dev.yml up -d

# Start only data services (for local dev)
docker compose -f docker-compose.yml -f docker-compose.dev.yml up -d database redis

# View logs
docker compose -f docker-compose.yml -f docker-compose.dev.yml logs -f

# Rebuild a single service
docker compose -f docker-compose.yml -f docker-compose.dev.yml up -d --build backend

# Stop everything
docker compose -f docker-compose.yml -f docker-compose.dev.yml down

# Reset all data (deletes volumes)
docker compose -f docker-compose.yml -f docker-compose.dev.yml down -v


πŸ“± Mobile Development

BudgetGenius runs as a native Android APK via Capacitor 7, which wraps the existing Vite/React web app in a native WebView. This means 100% code reuse β€” no rewrite needed.

How It Works

[React App] β†’ [Vite Build (dist/)] β†’ [Capacitor] β†’ [WebView Nativo] β†’ [APK]
                    ↓
              Sin cambios en el cΓ³digo
  • The Vite build is output to apps/webClient/dist/
  • Capacitor serves these files from the native Android WebView
  • In dev mode (CAP_DEV=true), the WebView loads directly from the Vite dev server at http://10.0.2.2:5173 for hot reload
  • Google Login uses a Strategy Pattern: signInWithPopup / signInWithRedirect in web, @capgo/capacitor-social-login plugin (Android Credential Manager bottom sheet) in native

Prerequisites

In addition to the base prerequisites:

  • Java JDK 21 β€” Required for Android builds (Adoptium Temurin)
  • Android Studio β€” For the Android SDK, emulator, and APK generation
  • ANDROID_HOME env var pointing to your Android SDK (e.g., /mnt/c/Users/User/AppData/Local/Android/Sdk for WSL)

πŸ“± Mobile App Structure

apps/mobile/
β”œβ”€β”€ package.json           # Capacitor dependencies + build scripts
β”œβ”€β”€ capacitor.config.ts    # Capacitor configuration (webDir, plugins, server.url)
β”œβ”€β”€ tsconfig.json          # TypeScript config
└── android/               # Native Android project (generated by npx cap add android)
    β”œβ”€β”€ app/
    β”‚   └── src/main/assets/  # ← Web assets copied here by cap sync
    β”œβ”€β”€ build.gradle
    └── gradlew            # Gradle wrapper for APK builds

πŸš€ Quick Start: Build & Run on Emulator

Step 1 β€” Start the Dev Servers

# Terminal 1 β€” Start PostgreSQL + Redis (Docker)
docker compose -f docker-compose.yml -f docker-compose.dev.yml up -d database redis

# Terminal 2 β€” Start Vite + NestJS with hot reload
pnpm dev

Verify both are running:

Service Expected URL
Vite dev server http://localhost:5173/
NestJS API http://127.0.0.1:5000 (HTTP 200 on /api)

Step 2 β€” Sync Capacitor Config for Dev Mode

cd apps/mobile
pnpm dev:android  # Sets CAP_DEV=true and runs npx cap sync

This writes the dev config (server.url: http://10.0.2.2:5173) to the Android project so the WebView loads from the Vite dev server.

Step 3 β€” Build & Install APK

cd apps/mobile/android
export JAVA_HOME=~/jdk-21.0.5+11   # Or your JDK 21 path
export ANDROID_HOME=/path/to/Android/Sdk
./gradlew assembleDebug

# Install on emulator
adb install -r app/build/outputs/apk/debug/app-debug.apk

πŸ’‘ Tip: The first build takes ~3-4 min (Gradle downloads dependencies). Subsequent builds with no dependency changes take ~8s.

Step 4 β€” Open on Emulator

Open the BudgetGenius app in your Android emulator. The app loads from the Vite dev server with hot reload β€” any code change reflects instantly.

πŸ” Development Cycle (Two Modes)

Dev Mode: Hot Reload (Recommended)

Step Command Note
1 pnpm dev Start Vite + NestJS
2 pnpm dev:android Sync config (needed once or after config changes)
3 Open app on emulator Hot reload works automatically

One-time setup only: After pnpm dev:android + adb install, you only need pnpm dev and the emulator. Re-sync is only needed if you change capacitor.config.ts.

Production Mode: Static APK

# Build web assets with production API URL
export VITE_API_URL=https://api-budgetgenius.alkiory.com/api
pnpm --filter frontend-web build

# Sync + build APK (CAP_DEV is not set β†’ uses local assets)
cd apps/mobile
pnpm build && cd android
./gradlew assembleDebug

This produces a self-contained APK that loads from local assets (no dev server needed).

πŸ”Œ Google Login Strategy

The app uses a Strategy Pattern that automatically selects the right auth method:

googleLogin()
  β†’ Capacitor.isNativePlatform() = true  β†’  NativeGoogleLoginStrategy
  β”‚     β†’ @capgo/capacitor-social-login β†’ signInWithGoogle()
  β”‚     β†’ idToken β†’ POST /auth/firebase-login
  β”‚
  β†’ Capacitor.isNativePlatform() = false β†’  WebGoogleLoginStrategy
        β†’ Firebase JS SDK β†’ signInWithPopup()
        β†’ idToken β†’ POST /auth/firebase-login
  • Web: Uses signInWithPopup / signInWithRedirect (Firebase JS SDK) β€” unchanged from the original behavior
  • Native: Uses @capgo/capacitor-social-login@7 plugin which delegates to Android's Credential Manager β€” shows an in-app bottom sheet (no Chrome Custom Tab, no deeplink round-trip). The selected Google account's signed idToken flows directly to POST /auth/firebase-login like the Web SDK path. See docs/changelog.md v1.2.0 for the incident postmortem that motivated the swap.

πŸ”§ Troubleshooting

API calls fail on emulator

Ensure Vite dev server is running on port 5173. The APK's Capacitor config points to http://10.0.2.2:5173 (the emulator's alias for the host). Vite proxies /api to http://localhost:5000/api.

If Vite is on a different port, update capacitor.config.ts:

server: { url: 'http://10.0.2.2:<NEW_PORT>', cleartext: true }

Then re-sync: pnpm --filter mobile dev:android && adb install -r ...

Gradle build fails (JAVA_HOME)

Ensure JAVA_HOME points to JDK 21 (not 17, not 11):

java -version  # Must show 21.x

Redis not available

If Redis isn't running, the API starts with a warning and operates without Redis β€” rate limiting and refresh tokens use safe defaults. To run Redis:

  • Docker: docker compose up -d redis
  • Local: Install Redis and run redis-server

CORS errors

If you see CORS errors in the emulator's WebView, make sure the backend's CORS allow-list includes the Capacitor dev server origin. The default dev origins already include http://10.0.2.2:5173 in apps/api/src/main.ts.


GitHub Actions Workflows

Workflow Trigger Actions
CI/CD Push to main, PR to main/dev Backend: test β†’ build Docker β†’ push to registry β†’ deploy via SSH; Frontend: test
Playwright Push/PR to main/dev E2E browser tests
Firebase Merge Push to main Deploy frontend to Firebase Hosting
Firebase PR Pull request Preview channel deployment

Deployment Architecture

  • Frontend: Vercel (primary) + Firebase Hosting (static assets)
  • Backend: Docker container deployed via SSH to VPS
  • Database: AWS RDS PostgreSQL (production) / Docker PostgreSQL (development)
  • Cache: Redis (Docker in development, managed service in production)

πŸ§ͺ Testing

Backend Tests (Jest)

# Unit and integration tests
pnpm --filter api test

# E2E tests
pnpm --filter api test:e2e

# Coverage report
pnpm --filter api test:cov

Frontend Tests (Playwright)

# Run all E2E tests
pnpm --filter frontend-web test

# Run with UI mode
pnpm --filter frontend-web test:ui

# Generate tests via codegen
pnpm --filter frontend-web test:codegen

# CI mode
pnpm --filter frontend-web test:ci

πŸ“ RPI Development Framework

BudgetGenius integrates the RPI (Research β†’ Plan β†’ Implement) framework for structured, AI-assisted development. This framework ensures that all non-trivial changes are properly researched, planned with atomic tasks, and executed with quality gates at every step.

How It Works

  1. Research Phase β€” Analyze the problem, map affected code, gather context β†’ validated with FAR Scale (Factual, Actionable, Relevant β‰₯ 4.00)
  2. Plan Phase β€” Break solution into atomic, single-responsibility tasks β†’ validated with FACTS Scale (Feasibility, Atomicity, Clarity, Testability, Size β‰₯ 3.00)
  3. Implement Phase β€” Execute tasks sequentially with quality gates (Build β†’ Lint β†’ Test) before marking complete

Complete framework documentation is in docs/rpi/.

Quick Start with RPI

To begin a new feature using RPI, create a directory rpi/<task-name>/ and follow the templates in docs/rpi/. See docs/rpi_instructions.md for exact AI agent prompts.


πŸ“‚ Project Structure

BudgetGenius/
β”œβ”€β”€ apps/
β”‚   β”œβ”€β”€ api/                          # NestJS Backend
β”‚   β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”‚   β”œβ”€β”€ domain/               # Entities & Repository Ports
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ auth/             # Auth entities, repository interface
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ user/             # User, UserSettings entities
β”‚   β”‚   β”‚   β”‚   └── dashboard/        # Transaction, Budget, Goal entities
β”‚   β”‚   β”‚   β”œβ”€β”€ application/          # Business Logic Services
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ auth/             # Auth service, DTOs
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ user/             # User service, seeder
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ ai/               # OpenAI assistant service
β”‚   β”‚   β”‚   β”‚   └── dashboard/        # Budget, Goal, Transaction services
β”‚   β”‚   β”‚   β”œβ”€β”€ infrastructure/       # Technical Implementation
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ config/           # Redis, Cookie, JWT strategy, throttling
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ auth/             # Google OAuth, Firebase middleware
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ dashboard/        # Dashboard module
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ user/             # User modules
β”‚   β”‚   β”‚   β”‚   └── log/              # Winston logger
β”‚   β”‚   β”‚   β”œβ”€β”€ adapters/             # Controller & Repository Implementations
β”‚   β”‚   β”‚   β”œβ”€β”€ migrations/           # TypeORM migrations
β”‚   β”‚   β”‚   └── main.ts               # Application bootstrap
β”‚   β”‚   β”œβ”€β”€ test/                     # Jest test files
β”‚   β”‚   └── Dockerfile
β”‚   β”œβ”€β”€ webClient/                    # React Frontend
β”‚   β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”‚   β”œβ”€β”€ domain/               # Entity types & Repository interfaces
β”‚   β”‚   β”‚   β”œβ”€β”€ application/          # Auth & User services
β”‚   β”‚   β”‚   β”œβ”€β”€ infrastructure/       # API config, Error boundary, Firebase
β”‚   β”‚   β”‚   β”œβ”€β”€ adapters/             # HTTP repositories, Redux store, hooks
β”‚   β”‚   β”‚   β”œβ”€β”€ presentation/
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ pages/            # Page components
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ components/       # Reusable UI components
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ layouts/          # Layout components
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ routes/           # Route config, auth guards
β”‚   β”‚   β”‚   β”‚   └── utils/            # Routes enum, colors, currency
β”‚   β”‚   β”‚   └── main.tsx              # Entry point
β”‚   β”‚   β”œβ”€β”€ tests/                    # Playwright E2E tests
β”‚   β”‚   └── dockerfile
β”‚   └── mobile/                       # Capacitor Native Wrapper
β”‚       β”œβ”€β”€ package.json              # Capacitor deps & scripts
β”‚       β”œβ”€β”€ capacitor.config.ts       # Config (webDir, plugins, server.url)
β”‚       └── android/                  # Native Android project
β”œβ”€β”€ docs/
β”‚   β”œβ”€β”€ rpi/                          # RPI Framework docs
β”‚   └── rpi_instructions.md           # AI agent prompt guide
β”œβ”€β”€ scripts/
β”‚   └── bootstrap.sh                  # Automated setup script
β”œβ”€β”€ .github/workflows/                # CI/CD pipelines
β”œβ”€β”€ docker-compose.yml                # Base Docker services
β”œβ”€β”€ docker-compose.dev.yml            # Development config
β”œβ”€β”€ docker-compose.prod.yml           # Production config
β”œβ”€β”€ pnpm-workspace.yaml               # Workspace definition
└── turbo.json                         # Turbo pipeline

πŸ”§ Environment Variables

Backend (apps/api/.env.development)

# Database (localhost for local dev; Docker overrides to 'database' via compose)
DB_HOST=localhost
DB_PORT=5432
DB_USER=postgres_admin_dev
DB_PASS=dev_password
DB_NAME=budgetgenius_dev
DB_URL=postgresql://postgres_admin_dev:dev_password@localhost:5432/budgetgenius_dev

# Server
PORT=5000
NODE_ENV=development
FRONTEND_URL=http://localhost:3001

# JWT (REQUIRED β€” app won't start without it)
JWT_SECRET=<generate-with-openssl-rand-hex-32>

# Redis (localhost for local dev; Docker overrides to 'redis' via compose)
REDIS_HOST=localhost
REDIS_PORT=6379
REDIS_URL=redis://localhost:6379

# OpenAI (optional β€” for AI assistant "Finny")
OPENAI_API_KEY=sk-...

# OAuth (optional)
GOOGLE_CLIENT_ID=
GOOGLE_CLIENT_SECRET=

# Firebase (optional)
FIREBASE_PROJECT_ID=
FIREBASE_PRIVATE_KEY=
FIREBASE_CLIENT_EMAIL=
FIREBASE_API_KEY=
FIREBASE_AUTH_DOMAIN=

Note: When running the backend inside Docker (docker compose), DB_HOST, REDIS_HOST, and REDIS_URL are automatically overridden to Docker service names (database, redis, redis://redis:6379) via docker-compose.dev.yml. The .env.development file always keeps localhost values for local pnpm dev usage.

Frontend (apps/webClient/.env.development)

VITE_API_URL=http://localhost:3000/api
VITE_FRONTEND_URL=http://localhost:3001

# Firebase (optional)
VITE_FIREBASE_PROJECT_ID=
VITE_FIREBASE_API_KEY=
VITE_FIREBASE_AUTH_DOMAIN=
VITE_FIREBASE_MEASUREMENT_ID=

Wave 1 [T1.4] alias note. Operators who set this var under the older name VITE_FIREBASE_MEASURENT_ID (the typo'd spelling historically propagated through this README, .env.example and 3 GitHub Actions workflows) β€” ensure your GitHub Secret is renamed too, otherwise the firebaseConfig.ts measurementId reads as undefined and Analytics silently fails to initialize.

Complete Reference

See .env.example files in each app directory for the full list of available variables:


πŸ“š API Documentation

When the backend is running, Swagger API documentation is available at:


🀝 Contributing

Development Process

  1. All non-trivial changes follow the RPI Framework
  2. Create a feature branch from dev
  3. Implement changes with quality gates (Build β†’ Lint β†’ Test)
  4. Submit a PR to dev
  5. Use the Pull Request Template

Code Conventions

  • Imports: Use path aliases (@domain/, @application/, etc.) β€” never relative paths
  • Architecture: Respect layer boundaries β€” Domain never imports from outer layers
  • Naming: kebab-case files, PascalCase classes, camelCase variables
  • Database: All tables under bg_public schema; always create migrations for schema changes

For AI Agents

If you're an AI coding agent working on this project, read the comprehensive knowledge.md guide first. It provides the complete context needed to navigate and extend this codebase effectively.


πŸ“„ License

This project is proprietary and unlicensed. All rights reserved.


BudgetGenius β€” Smart money management, powered by AI.
Built with ❀️ by Alkiory