Skip to content

Latest commit

Β 

History

History
80 lines (65 loc) Β· 2.57 KB

File metadata and controls

80 lines (65 loc) Β· 2.57 KB

πŸ’Έ Ledger - Decoupled Personal Expense Tracker Architecture

A high-performance, minimal personal finance dashboard split into decoupled client/ and server/ packages.


πŸ“ Monorepo Folder Structure

expense-tracker/
β”œβ”€β”€ client/                     # Next.js 15 Frontend Application
β”‚   β”œβ”€β”€ app/                    # Next.js App Router (Dashboard, Analytics, Categories, Transactions, Settings, Profile)
β”‚   β”œβ”€β”€ components/             # Reusable UI & Layout Components (Dock Sidebar, Navbar, Modals)
β”‚   β”œβ”€β”€ features/               # Domain feature modules (Dashboard, Expenses, Analytics, Categories, Profile)
β”‚   β”œβ”€β”€ lib/
β”‚   β”‚   β”œβ”€β”€ api/api-client.ts   # Decoupled API Client (supports NEXT_PUBLIC_API_URL)
β”‚   β”‚   β”œβ”€β”€ auth/auth-context.ts# Pluggable Auth Context (login, OAuth, logout slots)
β”‚   β”‚   β”œβ”€β”€ config/app-config.ts# Configurable Backend Connection Modes (LOCAL_PRISMA vs REMOTE_HTTP)
β”‚   β”œβ”€β”€ package.json
β”‚   └── tsconfig.json
β”‚
β”œβ”€β”€ server/                     # Standalone Express & Database Server
β”‚   β”œβ”€β”€ src/                    # Backend API Controllers & Route Handlers
β”‚   β”œβ”€β”€ prisma/                 # Prisma PostgreSQL Schema & Database Seed Scripts
β”‚   β”œβ”€β”€ package.json
β”‚   β”œβ”€β”€ tsconfig.json
β”‚   └── .env
β”‚
└── package.json                # Root Monorepo Scripts

πŸ”Œ How to Plug In Your Backend & Database

Option A: Plug Your Custom API Server into server/

  1. Place your backend API code inside server/src/.
  2. Configure environment variables in server/.env:
    PORT=5000
    DATABASE_URL="postgresql://user:password@localhost:5432/ledger?schema=public"
    CORS_ORIGIN="http://localhost:3000"
  3. In client/.env, point the frontend API client to your backend server:
    NEXT_PUBLIC_BACKEND_MODE="REMOTE_HTTP"
    NEXT_PUBLIC_API_URL="http://localhost:5000/api/v1"

Option B: Run Next.js App Router + Prisma PostgreSQL locally in client/

  1. Set DATABASE_URL in client/.env.
  2. Run database migrations:
    cd client
    npx prisma db push

πŸš€ Quick Start (Local Development)

1. Install Dependencies

# Install client dependencies
cd client && npm install

# Install server dependencies
cd ../server && npm install

2. Run Applications

# From the root directory:

# Start Next.js Frontend (Runs on http://localhost:3000)
npm run dev:client

# Start Express Backend Server (Runs on http://localhost:5000)
npm run dev:server