How juliengdev/personal_finance works
Project type and purpose
• This is a full-stack Personal Finance web application built with Next.js (app directory), React, TypeScript, and Prisma.
• The app implements authentication (NextAuth), CRUD operations on budgets, pots, transactions, and recurring bills, backed by a relational database managed via Prisma.
• It exposes API routes for auth and business-logic actions, and renders both server- and client-side React components.
File structure
• Top-level “app” directory: Next.js 13+ routes and React Server/Client Components.
• “app/api/auth/[...nextauth]”: NextAuth route for login/signup, backed by Prisma adapter.
• “actions”: server actions for budgets, pots, transactions, signup—invoked from client components.
• “components”: UI layer organized by feature (auth, budgets, pots, transactions, recurring-bills, overview, filters, modal, pagination, ui).
• “lib”: shared utilities (auth, constants, font loading, Prisma client, Zod schemas, file upload, business utils).
• “prisma”: schema, migrations, seed scripts—defines database tables for users, budgets, transactions, pots, bills.
• “public” & “styles”: static assets & CSS.
• “__tests__” & jest.config.ts: automated tests for services & components.
README for additional insights
• Describes core features: overview dashboard, paginated/searchable transactions, CRUD budgets & pots, recurring bills, accessibility, responsive layouts.
• Suggests use of data.json for initial load, and optionally persisting to database (in our case we do).
• Mentions authentication and database as bonuses—our implementation includes both.
Main components & relationships
a. Frontend (Client)
• React components in “app” & “components” folders, some using server actions (form submissions) and client hooks.
• Pages (e.g., /dashboard/overview, /transactions) render UI, call actions via Next.js form actions or fetch API.
b. Backend (Server)
• Next.js Server: handles page rendering, API routes, server actions.
• API/auth route: NextAuth endpoint, integrates with OAuth/providers and session management.
• Actions: functions run server-side (in “actions”) to read/write data via Prisma.
c. Database
• PostgreSQL/MySQL (configured via environment) accessed through Prisma Client (lib/prisma.ts).
• Tables: User, Budget, Transaction, Pot, RecurringBill, Session.
d. External Services
• OAuth providers for social login (GitHub, Google, etc.) via NextAuth.
• File upload service if used (lib/upload.ts).
e. Build & Deployment
• Hosted on Vercel/Netlify: Next.js app, serverless functions for API routes/actions.
• Prisma migrations & seed scripts run at deploy time to create schema & initial data.
Architectural patterns & design principles
• “App Router” pattern: Next.js file-based routing in “app” folder, mixing Server and Client Components.
• Server Actions: form-based mutations handled directly in component files, reducing explicit fetch code.
• MVC-lite: React UI (View), actions & API (Controller), Prisma & DB (Model).
• Modularization: feature folders under “components” and “hooks” for reusability and separation of concerns.
• Type-safe schema/validation: Zod schemas in lib/schemas.ts for request payloads.
Final advice
• Every distinct layer: Client, Server (App Router vs. API vs. Actions), DB, External Auth.
• Keep labels concise, group related features (budgets, pots, transactions) under the Actions/API section.