<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Maksim Pokhiliy</title>
    <description>The latest articles on Forem by Maksim Pokhiliy (@maksim_pokhiliy).</description>
    <link>https://forem.com/maksim_pokhiliy</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F2649261%2F64962b05-d0a2-4cbb-9153-c0b5aa211b5f.jpg</url>
      <title>Forem: Maksim Pokhiliy</title>
      <link>https://forem.com/maksim_pokhiliy</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/maksim_pokhiliy"/>
    <language>en</language>
    <item>
      <title>I built an open-source invoicing app with Next.js 16 — here's the architecture</title>
      <dc:creator>Maksim Pokhiliy</dc:creator>
      <pubDate>Mon, 09 Feb 2026 08:06:25 +0000</pubDate>
      <link>https://forem.com/maksim_pokhiliy/i-built-an-open-source-invoicing-app-with-nextjs-16-heres-the-architecture-3e3h</link>
      <guid>https://forem.com/maksim_pokhiliy/i-built-an-open-source-invoicing-app-with-nextjs-16-heres-the-architecture-3e3h</guid>
      <description>&lt;p&gt;As a freelancer, I've tried Wave, Zoho Invoice, and a bunch of others. They all had the same problem: too much. I don't need accounting, payroll, or inventory management. I need to send invoices and know when clients see them.&lt;/p&gt;

&lt;p&gt;So I built &lt;strong&gt;&lt;a href="https://github.com/maksim-pokhiliy/getpaid" rel="noopener noreferrer"&gt;GetPaid&lt;/a&gt;&lt;/strong&gt; — an open-source, self-hosted invoicing tool that does exactly that.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href="https://getpaid-community.vercel.app/" rel="noopener noreferrer"&gt;Live demo&lt;/a&gt;&lt;/strong&gt; | &lt;strong&gt;&lt;a href="https://github.com/maksim-pokhiliy/getpaid" rel="noopener noreferrer"&gt;GitHub&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What it does
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Invoices&lt;/strong&gt; — create, edit, and send with line items, taxes, discounts&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;View tracking&lt;/strong&gt; — know exactly when your client opens an invoice&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Recurring&lt;/strong&gt; — invoices that generate and send on a schedule&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Follow-ups&lt;/strong&gt; — automated payment reminders&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;PDF export&lt;/strong&gt; — clean PDFs your clients can download&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Dashboard&lt;/strong&gt; — revenue, outstanding amounts, payment trends&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Templates&lt;/strong&gt; — reusable invoice templates for repeat work&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Banking&lt;/strong&gt; &lt;em&gt;(optional)&lt;/em&gt; — connect bank accounts via Salt Edge for auto-matching payments&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Light &amp;amp; dark themes&lt;/strong&gt; out of the box&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Tech stack
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Layer&lt;/th&gt;
&lt;th&gt;Choice&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Framework&lt;/td&gt;
&lt;td&gt;Next.js 16 (App Router, standalone output)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;UI&lt;/td&gt;
&lt;td&gt;MUI 7 (Material UI)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Language&lt;/td&gt;
&lt;td&gt;TypeScript (strict mode)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Database&lt;/td&gt;
&lt;td&gt;PostgreSQL 16 + Prisma ORM&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Auth&lt;/td&gt;
&lt;td&gt;NextAuth (Auth.js)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Validation&lt;/td&gt;
&lt;td&gt;Zod 4&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Data fetching&lt;/td&gt;
&lt;td&gt;React Query&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Forms&lt;/td&gt;
&lt;td&gt;React Hook Form&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Email&lt;/td&gt;
&lt;td&gt;Resend&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Charts&lt;/td&gt;
&lt;td&gt;Recharts&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Deployment&lt;/td&gt;
&lt;td&gt;Docker (multi-stage build)&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  Architecture: Feature-Sliced Design
&lt;/h2&gt;

&lt;p&gt;The project follows &lt;a href="https://feature-sliced.design/" rel="noopener noreferrer"&gt;Feature-Sliced Design&lt;/a&gt; (FSD). Instead of grouping files by type (&lt;code&gt;components/&lt;/code&gt;, &lt;code&gt;hooks/&lt;/code&gt;, &lt;code&gt;utils/&lt;/code&gt;), every domain feature owns its full vertical slice:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;src/
├── app/           # Next.js routing only — pages, layouts, API routes
├── features/      # Domain slices
│   ├── invoices/
│   │   ├── api/         # fetch functions
│   │   ├── hooks/       # React Query hooks
│   │   ├── components/  # UI
│   │   ├── schemas/     # Zod validation
│   │   └── constants/
│   ├── clients/
│   ├── recurring/
│   ├── settings/
│   ├── banking/
│   └── dashboard/
├── shared/        # Cross-feature code (UI kit, config, utils)
├── server/        # Server-side services — sole Prisma consumer
└── providers/     # React context, theme
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Why FSD?&lt;/strong&gt; When I add a new feature, everything lives in one directory. When I delete a feature, I delete one directory. No scattered files across &lt;code&gt;components/&lt;/code&gt;, &lt;code&gt;hooks/&lt;/code&gt;, &lt;code&gt;services/&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Strict layer boundaries
&lt;/h3&gt;

&lt;p&gt;These aren't guidelines — they're enforced by ESLint:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;src/app/&lt;/code&gt; contains &lt;strong&gt;only&lt;/strong&gt; routing files (&lt;code&gt;page.tsx&lt;/code&gt;, &lt;code&gt;layout.tsx&lt;/code&gt;, &lt;code&gt;route.ts&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;Features &lt;strong&gt;never&lt;/strong&gt; import from other features&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;shared/&lt;/code&gt; &lt;strong&gt;never&lt;/strong&gt; imports from &lt;code&gt;features/&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Only &lt;code&gt;src/server/&lt;/code&gt; can access Prisma — UI components can't touch the database&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Centralized environment variables
&lt;/h2&gt;

&lt;p&gt;One pattern I'm particularly happy with: a single &lt;code&gt;env.ts&lt;/code&gt; file that validates all environment variables through Zod.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// src/shared/config/env.ts&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;z&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;zod&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;serverSchema&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;z&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;object&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;DATABASE_URL&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;z&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;string&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;min&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
  &lt;span class="na"&gt;NEXTAUTH_SECRET&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;z&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;string&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;min&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
  &lt;span class="na"&gt;APP_URL&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;z&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;string&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;min&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="k"&gt;default&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;http://localhost:3000&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
  &lt;span class="na"&gt;NODE_ENV&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;z&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;enum&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;development&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;production&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;test&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]).&lt;/span&gt;&lt;span class="k"&gt;default&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;development&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
  &lt;span class="na"&gt;RESEND_API_KEY&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;z&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;string&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;min&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;optional&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt;
  &lt;span class="c1"&gt;// ...&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The validated env is exported as a lazy Proxy singleton. Server variables throw if accessed on the client. The app crashes immediately with a clear message if a required variable is missing:&lt;/p&gt;

&lt;p&gt;Error: Invalid server environment variables:&lt;br&gt;
  DATABASE_URL: String must contain at least 1 character(s)&lt;br&gt;
  NEXTAUTH_SECRET: String must contain at least 1 character(s)&lt;/p&gt;

&lt;p&gt;An ESLint rule bans process.env everywhere except this one file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="err"&gt;//&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;eslint.config.mjs&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="err"&gt;files:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"src/**/*.ts"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"src/**/*.tsx"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="err"&gt;ignores:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"src/shared/config/env.ts"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="err"&gt;rules:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"no-restricted-syntax"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="s2"&gt;"error"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="err"&gt;selector:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"MemberExpression[object.name='process'][property.name='env']"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="err"&gt;message:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Use `env` from '@app/shared/config/env' instead of process.env."&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;No more typos in env variable names. No more missing variables discovered at runtime in production.&lt;/p&gt;

&lt;h2&gt;
  
  
  Self-hosting with Docker
&lt;/h2&gt;

&lt;p&gt;The entire app runs with a single command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git clone https://github.com/maksim-pokhiliy/getpaid.git
cd getpaid
echo "NEXTAUTH_SECRET=$(openssl rand -base64 32)" &amp;gt; .env
docker compose up -d
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The docker-compose.yml spins up PostgreSQL and the app. The Dockerfile uses a multi-stage build (deps → build → run) with Next.js standalone output, keeping the final image small. Prisma migrations run automatically on startup.&lt;/p&gt;

&lt;h2&gt;
  
  
  Optional banking integration
&lt;/h2&gt;

&lt;p&gt;Banking is entirely optional. If you set &lt;code&gt;SALT_EDGE_APP_ID&lt;/code&gt; and &lt;code&gt;SALT_EDGE_SECRET&lt;/code&gt;, the banking tab appears in settings and you get automatic payment matching. If you don't — the UI adapts and hides everything banking-related. No dead buttons, no error messages.&lt;/p&gt;

&lt;p&gt;This is handled at build time through next.config.ts:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;env: {
  NEXT_PUBLIC_BANKING_ENABLED: process.env.SALT_EDGE_APP_ID ? "true" : "",
},
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  What I'd do differently
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Tests. There are none. For an MVP this was fine, but before accepting contributions I need at least integration tests for the API layer.&lt;/li&gt;
&lt;li&gt;i18n. The app is English-only. For a tool targeting freelancers globally, localization should have been considered from the start.&lt;/li&gt;
&lt;li&gt;Email provider abstraction. Right now it's tightly coupled to Resend. A simple adapter pattern would make it swappable.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Try it
&lt;/h2&gt;

&lt;p&gt;Live demo: &lt;a href="https://getpaid-community.vercel.app/" rel="noopener noreferrer"&gt;https://getpaid-community.vercel.app/&lt;/a&gt;&lt;br&gt;
GitHub: &lt;a href="https://github.com/maksim-pokhiliy/getpaid" rel="noopener noreferrer"&gt;https://github.com/maksim-pokhiliy/getpaid&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;MIT licensed. If you're a freelancer — I'd love to hear what's missing. If you're a developer — PRs are welcome.&lt;/p&gt;

</description>
      <category>nextjs</category>
      <category>typescript</category>
      <category>opensource</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
