Skip to content

MVP Web + App (Expo) — Finanças a Dois#5

Draft
Copilot wants to merge 6 commits intomvp-web-app-expofrom
copilot/implement-mvp-financas-a-dois
Draft

MVP Web + App (Expo) — Finanças a Dois#5
Copilot wants to merge 6 commits intomvp-web-app-expofrom
copilot/implement-mvp-financas-a-dois

Conversation

Copy link
Contributor

Copilot AI commented Nov 8, 2025

End-to-end MVP for shared financial management: pnpm monorepo with Next.js 14 PWA (App Router, NextAuth magic link, Prisma), Expo mobile app (offline queue, NetInfo sync), and shared Zod schemas.

Architecture

Monorepo Structure

  • packages/shared: Zod schemas, TypeScript types, utility functions (currency/date/RFC7807)
  • apps/web: Next.js 14 App Router, Prisma (SQLite), NextAuth Email provider, PWA
  • apps/mobile: Expo 50, React Navigation bottom tabs, AsyncStorage offline queue

Database (Prisma + SQLite)

model Transaction {
  amount   Float    // SQLite: use Float not Decimal
  kind     String   // INCOME | EXPENSE
  category Category
  user     User
  family   Family
  // ... indices on familyId+date, familyId+kind
}

Web App

API Routes (/api/v1/)

  • Auth: POST /auth/magic-link, GET /auth/callback, GET /me
  • Transactions: CRUD with cursor pagination, Idempotency-Key on POST, If-Match on PATCH/DELETE
  • Dashboard: KPIs + top 5 expense categories + recent 10
  • Onboarding: POST /onboarding/activate creates family, categories, seed transactions
  • RBAC: OWNER edits any transaction, PARTNER only own

Pages

/ (Dashboard)         → KPIs, category bars, recent transactions, FAB
/new                  → Single-step form: amount, tipo toggle, categoria, data, nota
/history              → List with INCOME/EXPENSE/ALL filter
/onboarding           → Shows seed summary, "Activate Month" button
/auth/signin          → Magic link flow

PWA: manifest.webmanifest + sw.js (network-first for /api, cache-first for assets)

Mobile App

Offline Support

// Queue actions when offline
await offlineQueue.enqueue({
  endpoint: '/api/v1/transactions',
  method: 'POST',
  data: { amount: '100.00', kind: 'EXPENSE', ... },
  idempotencyKey: generateKey()
});

// NetInfo listener auto-syncs on reconnect
setupNetworkListener(); // processes queue with Idempotency-Key

Screens: Dashboard (mirrors web KPIs), NewTransaction (offline banner if disconnected), History (filter chips)

Seed Data

Migration + seed script creates:

  • Family "Rafael + Nine"
  • User rafael@example.com (OWNER)
  • 9 categories (Salário, Freelance, Investimentos | Alimentação, Moradia, Transporte, Saúde, Lazer, Educação)
  • 8 transactions for current month (R$ 6,700 income, R$ 2,400.50 expense)

Setup

pnpm install
cd apps/web
pnpm prisma generate && pnpm db:migrate && pnpm db:seed
pnpm dev:web  # http://localhost:3000

Requires EMAIL_SERVER and EMAIL_FROM in apps/web/.env.local for magic link auth.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • checkpoint.prisma.io
    • Triggering command: /usr/local/bin/node /home/REDACTED/work/finance/finance/node_modules/.pnpm/prisma@5.22.0/node_modules/prisma/build/child {"product":"prisma","version":"5.22.0","cli_install_type":"local","information":"","local_timestamp":"2025-11-08T00:35:32Z","project_hash":"c1a373f1","cli_path":"/home/REDACTED/work/finance/finance/apps/web/node_modules/prisma/build/index.js","cli_path_hash":"0b21fa27","endpoint":"REDACTED","disable":false,"arch":"x64","os":"linux","node_version":"v20.19.5","ci":true,"ci_name":"GitHub Actions","command":"generate","schema_providers":["sqlite"],"schema_preview_features":[],"schema_generators_providers":["prisma-client-js"],"cache_file":"/home/REDACTED/.cache/checkpoint-nodejs/prisma-0b21fa27","cache_duration":43200000,"remind_duration":172800000,"force":false,"timeout":5000,"unref":true,"child_path":"/home/REDACTED/work/finance/finance/node_modules/.pnpm/prisma@5.22.0/node_modules/prisma/build/child","client_event_id":"","previous_client_event_id":"","check_if_update_available":true} (dns block)
    • Triggering command: /usr/local/bin/node /home/REDACTED/work/finance/finance/node_modules/.pnpm/prisma@5.22.0/node_modules/prisma/build/child {"product":"prisma","version":"5.22.0","cli_install_type":"local","information":"","local_timestamp":"2025-11-08T00:36:22Z","project_hash":"c1a373f1","cli_path":"/home/REDACTED/work/finance/finance/apps/web/node_modules/prisma/build/index.js","cli_path_hash":"0b21fa27","endpoint":"REDACTED","disable":false,"arch":"x64","os":"linux","node_version":"v20.19.5","ci":true,"ci_name":"GitHub Actions","command":"migrate deploy","schema_providers":["sqlite"],"schema_preview_features":[],"schema_generators_providers":["prisma-client-js"],"cache_file":"/home/REDACTED/.cache/checkpoint-nodejs/prisma-0b21fa27","cache_duration":43200000,"remind_duration":172800000,"force":false,"timeout":5000,"unref":true,"child_path":"/home/REDACTED/work/finance/finance/node_modules/.pnpm/prisma@5.22.0/node_modules/prisma/build/child","client_event_id":"","previous_client_event_id":"","check_if_update_available":true} (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

Implement an end-to-end MVP for “Finanças a Dois” with a pnpm monorepo containing Web (Next.js 14 + App Router + API routes + Prisma + NextAuth) and Mobile (Expo + React Navigation + React Query + offline queue/sync) apps, plus a Shared package with Zod schemas and utilities.

Requirements (implement everything below):

Monorepo structure

  • root: pnpm-workspace.yaml, package.json, tsconfig.base.json, .gitignore, README.md, .env.example
  • packages/shared: Zod schemas (DTOs), types, utils (currency/date/problem helpers)
  • apps/web: Next.js app (App Router) with Tailwind, React Query; API routes under /app/api/v1/* implementing REST contracts for categories, transactions, dashboard, invites, onboarding, me, auth wrappers; Prisma schema (SQLite) and seed; NextAuth Email provider (magic link) using PrismaAdapter; PWA manifest + service worker; pages: / (Dashboard), /new, /history, /onboarding
  • apps/mobile: Expo app (TypeScript) with bottom tabs (Dashboard, +Lançar, Histórico), React Query, AsyncStorage queue, NetInfo sync; base API URL configurable via EXPO_PUBLIC_API_BASE_URL or app.json extra

Database (Prisma)

  • Use provided Prisma schema: User (role OWNER|PARTNER, familyId optional), VerificationToken, Family, Setting, Category (unique familyId+name+kind), Transaction (Decimal(12,2), indices), Invite
  • Add migrations and seed script that creates Family "Rafael + Nine", OWNER user rafael@example.com, categories (income/expense) and transactions for current month as specified.

Auth & API

  • NextAuth Email provider (magic link) with JWT session and PrismaAdapter.
  • Implement POST /api/v1/auth/magic-link (thin wrapper to NextAuth email sign-in) returning 204.
  • Implement GET /api/v1/auth/callback passthrough to NextAuth email callback (302).
  • Implement GET /api/v1/me returning session user data.
  • Implement REST endpoints (/v1/) with contracts specified: categories, transactions (cursor pagination minimal), dashboard aggregates, invites, onboarding activation.
  • Use Idempotency-Key for POSTs, ETag/If-Match for PATCH/DELETE, RFC7807 minimal problem details for errors.
  • Enforce RBAC: OWNER can edit/delete any transaction; PARTNER only own.

Web UI

  • Dashboard: KPIs (Receitas, Despesas, Saldo), top categories (bars), recent 10 items, FAB + to /new
  • New: single-step form (valor, tipo toggle, categoria select, data default today, nota optional), POST /transactions with Idempotency-Key and redirect to /
  • History: list with Type filter; show category, note, amount, date
  • Onboarding: show seed summary and Activate Month button calling /api/v1/onboarding/activate to create family, categories and seed transactions and assign user as OWNER to family
  • Layout includes QueryClientProvider and registers service worker; Tailwind + globals

Mobile App

  • Expo app providing Dashboard/History/NewTransaction screens using React Query
  • Implement offline queue in AsyncStorage with tempId and payload; NetInfo listener to sync on reconnect using Idempotency-Key header
  • UI minimal but functional and mirroring Web flows

PWA

  • manifest.webmanifest and sw.js implementing static cache and network-first for /api

Scripts & README

  • Add pnpm scripts for dev and build, README with setup and .env.example and commands to run migrations and seed

Acceptance Criteria (to verify)

  1. Magic link login functional (web + mobile using API endpoints)
  2. Onboarding applies seed for current month
  3. Create transaction in 3 taps/clicks; dashboard updates
  4. Dashboard shows KPIs + top categories + recent
  5. History with filters and ability to edit/delete via API
  6. Mobile offline create and sync on reconnect
  7. PWA installable and app compilable via EAS

Notes for the coding agent

  • Keep microcopy in pt-BR
  • No telemetry and no automated tests
  • Make amounts strings with 2 decimals in API; Decimal(12,2) in DB
  • Use Inter/Roboto fonts, tabular-nums for monetary displays (CSS is optional)

Implementation instructions

  • Create branch mvp-web-app-expo if not present and commit files there
  • Add prisma migrations and seed file
  • Ensure NextAuth handlers set token.role and token.familyId; session callback exposes role and familyId and user.id
  • Add minimal error handling and validations
  • Keep code simple and focused on UX; avoid heavy libraries beyond specified

Deliver the pull request with title: "MVP Web + App (Expo) — Finanças a Dois (initial implementation)" and include in the PR body a short checklist of what was added and how to run locally (mirroring README).

This pull request was created as a result of the following prompt from Copilot chat.

Implement an end-to-end MVP for “Finanças a Dois” with a pnpm monorepo containing Web (Next.js 14 + App Router + API routes + Prisma + NextAuth) and Mobile (Expo + React Navigation + React Query + offline queue/sync) apps, plus a Shared package with Zod schemas and utilities.

Requirements (implement everything below):

Monorepo structure

  • root: pnpm-workspace.yaml, package.json, tsconfig.base.json, .gitignore, README.md, .env.example
  • packages/shared: Zod schemas (DTOs), types, utils (currency/date/problem helpers)
  • apps/web: Next.js app (App Router) with Tailwind, React Query; API routes under /app/api/v1/* implementing REST contracts for categories, transactions, dashboard, invites, onboarding, me, auth wrappers; Prisma schema (SQLite) and seed; NextAuth Email provider (magic link) using PrismaAdapter; PWA manifest + service worker; pages: / (Dashboard), /new, /history, /onboarding
  • apps/mobile: Expo app (TypeScript) with bottom tabs (Dashboard, +Lançar, Histórico), React Query, AsyncStorage queue, NetInfo sync; base API URL configurable via EXPO_PUBLIC_API_BASE_URL or app.json extra

Database (Prisma)

  • Use provided Prisma schema: User (role OWNER|PARTNER, familyId optional), VerificationToken, Family, Setting, Category (unique familyId+name+kind), Transaction (Decimal(12,2), indices), Invite
  • Add migrations and seed script that creates Family "Rafael + Nine", OWNER user rafael@example.com, categories (income/expense) and transactions for current month as specified.

Auth & API

  • NextAuth Email provider (magic link) with JWT session and PrismaAdapter.
  • Implement POST /api/v1/auth/magic-link (thin wrapper to NextAuth email sign-in) returning 204.
  • Implement GET /api/v1/auth/callback passthrough to NextAuth email callback (302).
  • Implement GET /api/v1/me returning session user data.
  • Implement REST endpoints (/v1/) with contracts specified: categories, transactions (cursor pagination minimal), dashboard aggregates, invites, onboarding activation.
  • Use Idempotency-Key for POSTs, ETag/If-Match for PATCH/DELETE, RFC7807 minimal problem details for errors.
  • Enforce RBAC: OWNER can edit/delete any transaction; PARTNER only own.

Web UI

  • Dashboard: KPIs (Receitas, Despesas, Saldo), top categories (bars), recent 10 items, FAB + to /new
  • New: single-step form (valor, tipo toggle, categoria select, data default today, nota optional), POST /transactions with Idempotency-Key and redirect to /
  • History: list with Type filter; show category, note, amount, date
  • Onboarding: show seed summary and Activate Month button calling /api/v1/onboarding/activate to create family, categories and seed transactions and assign user as OWNER to family
  • Layout includes QueryClientProvider and registers service worker; Tailwind + globals

Mobile App

  • Expo app providing Dashboard/History/NewTransaction screens using React Query
  • Implement offline queue in AsyncStorage with tempId and payload; NetInfo listener to sync on reconnect using Idempotency-Key header
  • UI minimal but functional and mirroring Web flows

PWA

  • manifest.webmanifest and sw.js implementing static cache and network-first for /api

Scripts & README

  • Add pnpm scripts for dev and build, README with setup and .env.example and commands to run migrations and seed

Acceptance Criteria (to verify)

  1. Magic link login functional (web + mobile using API endpoints)
  2. Onboarding applies seed for current month
  3. Create transaction in 3 taps/clicks; dashboard updates
  4. Dashboard shows KPIs + top categories + recent
  5. History with filters and ability to edit/delete via API
  6. Mobile offline create and sync on reconnect
  7. PWA installable and app compilable via EAS

Notes for the coding agent

  • Keep microcopy in pt-BR
  • No telemetry and no automated tests
  • Make amounts strings with 2 decimals in API; Decimal(12,2) in DB
  • Use Inter/Roboto fonts, tabular-nums for monetary displays (CSS is optional)

Implementation instructions

  • Create branch mvp-web-app-expo if not present and commit files there
  • Add prisma migrations and seed file
  • Ensure NextAuth handlers set token.role and token.familyId; session callback exposes role and familyId and user.id
  • Add minimal error handling and validations
  • Keep code simple and focused on UX; avoid heavy libraries beyond specified

Deliver the pull request with title: "MVP Web + App (Expo) — Finanças a Dois (initial implementation)" and include in the PR body a short checklist of what was added and how to run locally (mirroring README).


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 5 commits November 8, 2025 00:13
Co-authored-by: rafaelgarbinatto <1371016+rafaelgarbinatto@users.noreply.github.com>
Co-authored-by: rafaelgarbinatto <1371016+rafaelgarbinatto@users.noreply.github.com>
Co-authored-by: rafaelgarbinatto <1371016+rafaelgarbinatto@users.noreply.github.com>
…compatibility

Co-authored-by: rafaelgarbinatto <1371016+rafaelgarbinatto@users.noreply.github.com>
Co-authored-by: rafaelgarbinatto <1371016+rafaelgarbinatto@users.noreply.github.com>
Copilot AI changed the title [WIP] Implement end-to-end MVP for Finanças a Dois MVP Web + App (Expo) — Finanças a Dois Nov 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants