An open API service indexing awesome lists of open source software.

https://github.com/ski043/financial-hub-cursor


https://github.com/ski043/financial-hub-cursor

Last synced: 1 day ago
JSON representation

Awesome Lists containing this project

README

          

# Finance Hub

Your complete financial life in one dashboard — net worth, cash flow, spending, subscriptions, assets, and debts. See [PRD.md](PRD.md) for the product spec and [CONTEXT.md](CONTEXT.md) for the domain language.

## Stack

- **Next.js 16** (App Router, TypeScript) — note: Middleware is now `proxy.ts`.
- **Prisma 7 + PostgreSQL** with the `@prisma/adapter-pg` driver adapter. Config lives in [prisma.config.ts](prisma.config.ts); the client is generated to `generated/`.
- **Better Auth** (email + password) — config in [lib/auth.ts](lib/auth.ts).
- **Tailwind + shadcn/ui** (base-nova style, `@base-ui/react`).

## Getting started

### 1. Install dependencies

```bash
npm install
```

`postinstall` runs `prisma generate` automatically.

### 2. Configure environment

Copy the example and fill in your values:

```bash
cp .env.example .env
```

- `DATABASE_URL` — your Postgres connection string.
- `BETTER_AUTH_SECRET` — generate one with `openssl rand -base64 32`.
- `BETTER_AUTH_URL` — `http://localhost:3000` for local dev.

### 3. Migrate the database

```bash
npm run db:migrate
```

### 4. Seed the demo user

```bash
npm run db:seed
```

Creates `demo@financehub.app` / `demo-password-123`.

### 5. Run the dev server

```bash
npm run dev
```

Open [http://localhost:3000](http://localhost:3000). Sign in with the demo user or create a new account at `/signup`.

## Auth architecture

- **Schema**: generated by the Better Auth CLI (`npm run auth:generate`). It produces `User` (extended with `baseCurrency`, `expectedMonthlyIncomeCents`, `savingsTargetCents`), `Session`, `AuthAccount`, and `Verification`. Better Auth's credential table is mapped to `AuthAccount` so the domain `Account` (cash) stays free per [CONTEXT.md](CONTEXT.md).
- **Route handler**: `app/api/auth/[...all]/route.ts` via `toNextJsHandler`.
- **Route protection**: [proxy.ts](proxy.ts) does an optimistic session-cookie check (redirects `/dashboard` → `/login` and away from auth pages when signed in). The authoritative check is `requireSession()` in [lib/auth-guard.ts](lib/auth-guard.ts), used by Server Components.

## Useful scripts

| Script | Description |
|--------|-------------|
| `npm run dev` | Start the dev server |
| `npm run db:migrate` | Create/apply a Prisma migration |
| `npm run db:generate` | Regenerate the Prisma client |
| `npm run db:seed` | Seed the demo user |
| `npm run auth:generate` | Regenerate auth models from the Better Auth config |
| `npm run lint` | Run ESLint |