logoalt Hacker News

Show HN: I open-sourced my Go and Next B2B SaaS Starter (deploy anywhere, MIT)

62 pointsby moh_quztoday at 11:34 AM32 commentsview on HN

Hi HN, I'm Mohammed, a technical founder who loves shipping and giving back to the community. I'm open-sourcing the full-stack engine that powers my B2B product, apflow.co.

What it is: A production B2B starter with a Go backend and Next.js frontend. Both are fully Dockerized with separate containers. No Vercel. No Supabase. Deploy the whole thing on a $6 VPS, or split frontend and backend across different providers. You own the infrastructure.

The problem I was solving:

Every SaaS starter I evaluated had the same issue: they locked me into someone else's platform. Vercel for hosting. PlanetScale for the database. Serverless functions billing per invocation. Fine for prototypes, but costs become unpredictable at scale and migrating away is painful.

I wanted something I could deploy on any Linux box with docker-compose up. Something where I could host the frontend on Cloudflare Pages and the backend on a Hetzner VPS if I wanted. No vendor-specific APIs buried in my code.

Why Go for the backend:

Go gives me exactly what I need for a SaaS backend:

Tiny footprint. The backend idles at ~50MB RAM. On a cheap VPS, that headroom lets me run more services without upgrading. Concurrency without complexity. Billing webhooks, file uploads, and AI calls run concurrently without callback hell. Compile-time type safety. Using SQLC, my SQL compiles to type-safe Go. If the query is wrong, it fails at build time, not in production. Predictable performance. No garbage collection pauses that surprise you under load. The architecture (Modular Monolith):

I didn't want microservices complexity for a small team, but I needed clean separation. I built a Modular Monolith: features like Auth, Billing, and AI are isolated Go modules with explicit interfaces, but they deploy as a single binary.

This structure also made AI coding tools (Cursor, Claude Code) dramatically more effective. Because every module has strict boundaries, the AI knows exactly where new code belongs and doesn't break other modules.

Full-stack, not just backend:

Backend: Go 1.25 + Gin + SQLC (type-safe SQL, no ORM) + PostgreSQL with pgvector Frontend: Next.js 16 + React 19 + Tailwind + shadcn/ui Communication: The frontend consumes a clean REST API. You can swap Next.js for any framework that speaks HTTP. Infrastructure: Separate Dockerfiles for frontend and backend. Deploy together or apart. What's pre-built:

The boring infrastructure is solved so you can focus on your actual product:

Auth + RBAC: Stytch B2B integration with Organizations, Teams, and Roles. Multi-tenant data isolation enforced at the query level. Billing: Polar.sh as Merchant of Record. Handles subscriptions, invoices, and global tax/VAT. No Stripe webhook edge cases. AI Pipeline: OpenAI RAG using pgvector. The retrieval service enforces strict context boundaries to minimize hallucinations. OCR: Mistral integration for document extraction. File Storage: Cloudflare R2 integration. Each feature is a separate module. Don't need OCR? Remove it. Want Stripe instead of Polar? The billing interface is abstracted.

Real-world proof:

This isn't a template I made for GitHub stars. It's the exact code running apflow.co in production. When I added document OCR, I built it as a new module without touching Auth or Billing. The architecture held.

How to try it:

Clone the repo, read setup.md to check the prerequisite, run ./setup.sh, and you have a working B2B environment locally in minutes.

Feedback I want:

I'd appreciate feedback from Go developers on the module boundaries and cross-module interfaces. Also curious if anyone has suggestions for the Docker setup in production deployments.

GitHub: https://github.com/moasq/production-saas-starter

Live: https://apflow.co


Comments

zaphodiastoday at 12:52 PM

This is great - thanks for sharing. I am actually building something very similar myself as I started building a couple SaaS and though it would be nice to extract the common pieces in a template.

My stack is similar, with a few differences:

- Go backend with sqlc, but using ConnectRPC[1]. I chose this as it allows me to define a proper API scheme and generate a decent-quality Typescript client.

- Nuxt (Vue) instead of Next.js (React). I chose this even though I'm new to vue cause I saw the open source components and templates here [2] (especially the dashboard template: [3]) and was convinced.

I'll definitely check out your repo as inspiration.

[1]: https://connectrpc.com/

[2]: https://ui.nuxt.com/

[3]: https://dashboard-template.nuxt.dev/

show 2 replies
MadsRCtoday at 12:32 PM

This is cool - Whenever I have a new idea for a thing I spend too much time writing boilerplate IAM and backend stuff, taking away time that could be spend on actual business logic. Thought about packaging the boilerplate stuff up before, never gotten around to it. Glad you did!

A thing to consider would be to make it easier (or perhaps bake it in) to separate out parts of the app into a separate origin. Something that would be good for pretty much any SaaS app would be to separate the IAM out (could still embed it with an iframe) - this allows you to keep a fairly tight security policy for the IAM stuff and a more lax one for the rest of the app. Kinda how Google separates out accounts.google.com.

show 1 reply
leetrouttoday at 1:04 PM

Have you tried Echo instead of Gin? I find it to be much more friendly and approachable with its docs compared to Gin.

show 2 replies
epsilonictoday at 4:25 PM

This is really good, thank you for sharing!

show 1 reply
adlpztoday at 12:02 PM

Cool project! Will surely copy ideas from it :)

A general question for the room: where's the tipping point where you need a "proper" backend, in a different language, with all the inconveniences of possible type safety issues and impedance mismatches?

Because I feel like for 90% of small-medium projects it's just good enough with all the backend stuff within the same Next.js process as the front-end. I just do "separation of concerns"-ish with the code organization and funnel all communication with something structured and type safe like tRPC.

Feels separate enough but very pleasant to work anyway.

Am I doing it wrong?

show 1 reply
krsoninikhiltoday at 1:36 PM

This seems helpful. If you're writing new applications frequently, have something like this really helps.

I created a simple start kit set of packages for my projects, not as exhaustive as yours though -- https://github.com/krsoninikhil/go-rest-kit

show 1 reply
CalRoberttoday at 2:07 PM

Can I ask why Next? I’ve been suffering with it for ages and desperately missing Vite.

show 2 replies
sallveburrpitoday at 11:59 AM

Thanks for sharing!

One question though: What made you avoid lock-in via platforms like supabase but then choose to be locked in on the AuthN/Z side with a proprietary solution?

show 1 reply
miroljubtoday at 11:52 AM

Nice one. Good to learn about polar.sh as a MoR alternative to Paddle.

I would prefer if it had a more leightweight htmx approach, but I guess it would be useful to some people.

show 1 reply
icedrifttoday at 12:09 PM

Oh boy another template shipped in a single commit; complete with "For now, do this" and "In production you would do this" comments

show 1 reply
rvztoday at 12:34 PM

Nice project and great idea and a reasonable selection of technologies that optimize for low cost deployment.

However, my biggest concern is the glaringly lack of comprehensive tests whatsoever. I have to even question if this project is production ready at all.

Until that is in place, I really do not think this is "production" quality I'm afraid.

show 1 reply
user20251219today at 12:24 PM

Awesome project - thanks for sharing

show 1 reply