How avee1000/pr works
1. Purpose and Runtime
PriceRight & QuoteEasy is a Next.js 16 / React 19 TypeScript application for sole traders to calculate prices from costs and profit targets, issue quotes, manage orders through delivery, and view cash flow. It runs on Node.js 20+ and deploys to Vercel. Core persistence and identity are Supabase PostgreSQL and Supabase Auth.
Entry shell and global styling: src/app/layout.tsx, src/app/page.tsx, src/app/globals.css.
2. Route Partitioning and Access Control
The App Router separates public marketing, authentication, authenticated operations, and public quote viewing. The dashboard route group has its own layout and is guarded by the proxy layer; quote links intentionally remain accessible without a session.
Key boundaries:
• Auth pages: src/app/(auth)/login/page.tsx, src/app/(auth)/signup/page.tsx
• Protected dashboard: src/app/(dashboard)/layout.tsx, src/app/(dashboard)/dashboard/page.tsx
• Public capability-link quote page: src/app/quote/[token]/page.tsx
• Session/access proxy: src/proxy.ts
3. Supabase Data and Server Boundary
Supabase clients distinguish browser and server use, while feature server actions encapsulate mutations and revalidation-oriented application logic. PostgreSQL owns customer, order, quote, material, labor, profit-target, and testimonial records. Database RLS is a material security boundary, although cost catalogs are currently globally shared rather than user-scoped.
Paths: src/lib/supabase/client.ts, src/lib/supabase/server.ts, src/lib/supabase/types.ts; schema/RPC artifacts: supabase/orders_quotes_rls.sql, supabase/quote_rpc.sql.
4. Cost-to-Price Configuration
Users maintain reusable material costs, labor costs, and target-profit settings. These inputs feed order/quote pricing rather than being a separate accounting service. Feature forms invoke cost actions against Supabase.
Paths: src/app/(dashboard)/dashboard/costs/materials/page.tsx, src/components/dashboard/costs/materials/MaterialCostsForm.tsx, src/lib/costs/action.ts.
5. Customer and Order Lifecycle
Customers are created and edited before/during order creation. Orders bind a customer, description, price, due date, fulfillment status, and payment status; material line items support pricing composition. The workflow stages are quote sent, approved, in progress, and delivered. The board provides visual stage transitions, with a selector fallback.
Paths: src/app/(dashboard)/dashboard/orders/create/page.tsx, src/components/dashboard/orders/create/OrderForm.tsx, src/components/dashboard/orders/board/OrderBoard.tsx; actions: src/lib/orders/action.ts.
6. Quotes and External Approval
A quote can be shared through a tokenized public URL. The external recipient views quote information and approves it without authentication. Approval crosses a deliberate public-to-database boundary: the route handler passes the token to the approve_quote_by_token database function, rather than accepting a caller-supplied order identity.
Paths: src/app/quote/[token]/page.tsx, src/components/orders/QuoteView.tsx, src/app/api/quotes/[token]/approve/route.ts.
7. APIs, Cash Flow, and Notifications
Most reads/writes use Server Components and server actions. REST handlers exist where client invocation or public quote approval requires HTTP. POST /api/orders derives user_id from the authenticated Supabase session and stamps paid_at for paid orders. Cash flow aggregates paid orders by payment timestamp; notification UI/API supports workflow alerts.
Paths: src/app/api/orders/route.ts, src/lib/dashboard/cashflow.ts, src/app/api/notifications/route.ts.
8. Operational Constraints
Hosting is Vercel with environment-provided public Supabase URL and anon key. Production deploys from master; PRs receive previews. Database evolution is currently manual and therefore prone to schema drift; only partial SQL artifacts are repository-managed. Key security debt: shared unscoped cost tables and broad testimonial write permissions.
Paths: .env.example, supabase/testimonials.sql, sql/2026-07-31-costs-registration.sql.
Main entry points: (dashboard)/layout.tsx Protected dashboard · server.ts Supabase clients · app/layout.tsx App shell · action.ts Order actions
Components 19
Next.js application
- App shell · Global layout, landing page, and styles.
src/app/layout.tsx - Auth pages
src/app/(auth)/login/page.tsx - Protected dashboard · Authenticated operational UI.
src/app/(dashboard)/layout.tsx - Session proxy · Guards dashboard routes while leaving quote links public.
src/proxy.ts - Public quote link · Unauthenticated token-based quote viewing.
src/app/quote/[token]/page.tsx - Orders API · Derives user identity from the session and stamps paid orders.
src/app/api/orders/route.ts - Quote approval API · Approves only through the supplied quote token.
src/app/api/quotes/[token]/approve/route.ts - Notifications API · Supports workflow alerts.
src/app/api/notifications/route.ts
Business workflows
- Cost configuration · Reusable material, labor, and profit-target inputs.
src/app/(dashboard)/dashboard/costs/materials/page.tsx - Cost actions
src/lib/costs/action.ts - Order creation · Binds customers, pricing inputs, due dates, and payment state.
src/components/dashboard/orders/create/OrderForm.tsx - Order workflow board · Moves work through quote, approval, progress, and delivery.
src/components/dashboard/orders/board/OrderBoard.tsx - Order actions
src/lib/orders/action.ts - Cash flow · Aggregates paid orders by payment timestamp.
src/lib/dashboard/cashflow.ts
Supabase boundary
- Supabase clients · Separates browser and server database access.
src/lib/supabase/server.ts - Supabase Auth
- Supabase PostgreSQL · Stores customers, orders, quotes, costs, profit targets, and testimonials.
supabase/orders_quotes_rls.sql - RLS and quote RPC · RLS enforces access; token approval uses approve_quote_by_token.
supabase/quote_rpc.sql
Other components
- Vercel · Deploys master production and PR previews.
Connections 23
- App shell → Auth pages
- App shell → Protected dashboard
- App shell → Public quote link
- Session proxy → Protected dashboard: guards
- Session proxy → Supabase Auth: validates session
- Protected dashboard → Cost configuration
- Protected dashboard → Order creation
- Protected dashboard → Order workflow board
- Protected dashboard → Cash flow
- Cost configuration → Cost actions: updates costs
- Order creation → Order actions: creates orders
- Order workflow board → Order actions: changes stage
- Cost actions → Supabase clients
- Order actions → Supabase clients
- Cash flow → Supabase clients: reads paid orders
- Orders API → Supabase Auth: derives user
- Orders API → Supabase clients: writes orders
- Public quote link → Quote approval API: approves quote
- Quote approval API → RLS and quote RPC: passes token
- Notifications API → Supabase clients
- Supabase clients → Supabase PostgreSQL: queries
- RLS and quote RPC → Supabase PostgreSQL: enforces and executes
- Vercel → App shell: hosts