How legions-developer/invoicely works
Project type and purpose
• This is a monorepo for a client-heavy Next.js 13 application (“Invoicely”) plus a set of shared packages (eslint-config, typescript-config, utilities).
• Purpose: A browser-based invoice generator that stores invoices in IndexedDB, renders them to PDF via a web worker, and ships as a static/SSR Next.js app.
File structure
• Top‐level:
• apps/web – the Next.js “app router” codebase (pages, layouts, components, hooks, providers, lib, content)
• packages – shared config and utility libraries
• turbo.json, yarn workspaces
• apps/web layers:
• src/app – routes (marketing + dashboard features)
• src/components – design system (ui, layout, pdf, sidebar)
• src/global + src/lib – state management (Jotai atoms), IndexedDB wrappers, PDF helpers
• src/providers – context providers for Jotai, PDF web worker, analytics
• Key config: next.config.ts, tsconfig.json, postcss, ESLint, Husky
Extract insights from README
• It’s a zero-backend, purely front-end invoicing app.
• Build uses yarn build via TurboRepo, runs Next.js build pipelines.
• Routes are pre-rendered or server-rendered for marketing and static-dynamic dashboards.
Main components
a. Monorepo orchestrator (TurboRepo + Yarn Workspaces)
b. Web Application (Next.js)
– UI Layer: React components & layouts
– Routing Layer: App Router (server + client components)
– Data Layer: Jotai state + hooks
– Persistence: IndexedDB (via src/global/indexdb + lib/indexdb-queries)
– PDF Engine: PDF web worker (via providers/pdf-worker-provider)
– Content Layer: MDX content + public assets
c. Shared Packages (eslint-config, tsconfig, utilities)
d. External Services
– Analytics (PostHog, OneDollarStats, OpenPanel)
– Fonts, CDN, static hosting
Relationships and interactions
• Developer triggers yarn dev|build at root → TurboRepo invokes Next.js build in apps/web and compiles shared packages
• End user → Browser → Next.js server/static page → React renders UI
• UI dispatches actions → Jotai atoms → persistence layer → IndexedDB
• “Export invoice” → UI calls PDF web worker → returns blob → browser download
• Throughout session → Analytics provider → external analytics endpoint
Architectural patterns & design principles
• Monorepo with code-sharing via workspaces
• Feature-based folder structure under src/app (marketing vs dashboard)
• UI components organized by domain (ui/, layout/, pdf/)
• Separation of concerns: UI vs state vs persistence vs side effects
• Use of web worker for CPU-intensive PDF generation
• App Router (server/client component split) for SSR/SSG optimization
• Clear component labels (e.g., “Next.js App Router”, “Jotai Store”, “PDF Web Worker”)
• Rectangles for code modules