How mathehluiz/nosso-bolso works
Project Type and Purpose
• This is a full-stack, multi-tenant financial tracking application (“Nosso bolso”) that allows users (individually or in shared groups) to manage bank accounts, transactions, categories, budgets, goals, and view reports.
• The “api” directory is a NestJS monolithic backend exposing REST endpoints, using Prisma for database access.
• The “www” directory is a Next.js frontend (with NextAuth), calling the backend via HTTP and presenting a dashboard, forms, and reports.
Top-Level Architecture Components
a. Frontend (Next.js “www”):
• Pages & Layout (public / protected)
• UI Components (dashboard cards, forms, charts)
• API Client & Services (http-client.ts + domain-specific service functions)
• Authentication (NextAuth routes + auth-provider)
b. Backend (NestJS “api”):
• API Gateway (NestJS Controllers / REST endpoints)
• Domain Modules:
• Organization & Identity (user signup/sign-in, invitation, roles)
• Bank Account (create/update accounts, default account)
• Transaction Category (CRUD categories)
• Transaction Management (CRUD transactions, mark paid)
• Goals (CRUD shared financial goals)
• Transaction Report (aggregate reports)
• Shared Modules:
• Persistence (PrismaService & repositories)
• Event Emitter (intra-module event bus)
• Config & Logger
• Database (PostgreSQL via Prisma ORM + Migrations)
c. Infrastructure
• Docker & docker-compose
• Environment configuration (.env files / config module)
• CI/Test (Jest unit/integration/e2e in “api/test”)
Relationships and Data Flows
1. User → Next.js UI (browser)
2. Next.js → NextAuth → External Identity Provider or JWT session store
3. Next.js UI calls backend REST endpoints (HTTP requests)
4. NestJS Controllers → Services (business logic) → Repositories (Prisma DB operations)
5. Business services emit domain events → Event Emitter Module → other handlers (e.g., cross-domain updates)
6. Services may publish read-model updates or generate reports on demand
7. Frontend polls or fetches updated data for real-time collaboration
Architectural Patterns & Design Principles
• Layered architecture in NestJS (Controller → Service → Repository)
• Domain-Driven Modularization: Each domain feature lives in its own NestJS module.
• Shared modules for cross-cutting concerns (logging, config, persistence, events).
• API-First design: Backend exposes REST, consumed by a clearly separated frontend.
• Event-Driven internals: Domain events for decoupling modules.
• Prisma Migrations for evolving schema.