Stytch B2B 魔法链接认证,HttpOnly Web Cookie 与 Bearer JWT 契约并存
go-nextjs-ai-saas-starter — Next.js SaaS模板
作者 azerturk
基于 Go 与 Next.js 的多租户 AI 文档处理开发预览模板,涵盖文档摄取、权限感知检索、引用式问答、抽取审核与订阅计费边界。
看看你的网站会是什么样
浏览真实页面截图,比较内容排版与手机效果。点击下方缩略图切换,放大查看整页细节。
目前有 1 张原始预览,可打开完整图片查看设计细节。
截图用于了解视觉与布局,交互效果请以实际项目为准。
值得关注的模板亮点
从已有项目资料中,快速了解它的特点。
Go 侧强制组织上下文、租户隔离、admin/manager/member 角色与订阅校验
PostgreSQL 按模块 schema 所有权、强制租户 RLS、SQLC 与三类数据库角色
PDF 上传、ClamAV 扫描、S3 兼容存储、OCR、嵌入、混合检索与权限感知 RAG 引用
类型化抽取模板、持久化运行、人工审批与签名 HTTPS webhook 投递
Polar 计费适配器与本地目录、权益、用量、配额、结账及门户边界
模板详细介绍
该模板是一个面向多租户 AI 文档操作的开发预览基础项目,后端为 Go 模块化单体,前端为 Next.js 的 UI/SSR 层,直接调用版本化的 Go API。仓库当前以 development 为唯一默认分支,定位为本地开发与架构研究用途,作者明确说明尚未达到生产就绪状态,真实供应商验收、生产部署、CI/CD 与发布自动化仍属路线图工作。
已实现的能力覆盖认证与租户隔离、文档处理与检索、抽取审核、订阅计费边界以及后台任务与可观测性。认证使用 Stytch B2B 魔法链接,配合 HttpOnly Web Cookie 与面向未来移动/API 客户端的 Bearer JWT 约定;Go 侧强制组织上下文、租户隔离、admin/manager/member 角色、权限、新鲜会话检查与订阅校验。数据层采用 PostgreSQL 按模块划分 schema 所有权、强制租户 RLS、SQLC,以及请求、worker、迁移三类显式数据库角色。文档链路包括 PDF 上传、ClamAV 扫描、S3 兼容本地对象存储、文档版本、OCR、嵌入、混合检索、权限感知 RAG 与逐字节引用。抽取部分提供类型化模板与持久化运行、不可变结果、人工批准/拒绝、已批准输出发布/导出与签名 HTTPS webhook 投递。计费侧包含 Polar 适配器以及本地目录、权益、用量、预留、配额、结账、门户与 webhook 边界。此外还有产品 SMTP 通知、不可变审计证据、事务性 outbox、Redis Streams、重试、DLQ 与白名单重放工具,以及 OpenTelemetry 追踪、私有 Prometheus 指标、结构化脱敏日志、就绪检查、架构适应度测试与合成 RAG 评估。
限制方面:外部业务供应商不会被运行时假实现替代,供应商要么显式禁用,要么以完整配置选中,配置不完整会导致启动失败。无凭证的本地测试无法证明真实 R2、Polar、Mistral、OpenAI、SMTP、Stytch 生产域名、公共 webhook 接收方、已认证浏览器或原生移动端行为。数据库迁移是可重置的规范开发基线,schema 变更后贡献者可能需要重建本地数据。本地开发依赖 Docker Compose、Go、Node.js 与 pnpm,并需要 Stytch B2B 测试项目。
适合你的项目吗?
适用场景
- 在本地搭建多租户 AI 文档问答与检索流程的开发环境
- 研究 Go 模块化单体与 Next.js 前后端分离的架构组织方式
- 验证文档上传、扫描、OCR、嵌入与引用式回答的端到端链路
- 试验类型化抽取、人工审核与已批准结果导出的工作流
- 评估订阅权益、配额与用量边界在 SaaS 场景中的落地方式
适合人群
- 希望研究多租户 AI 文档处理架构的 Go 与 Next.js 开发者
- 需要本地开发预览而非生产部署的团队或个人
- 对权限感知 RAG、审计证据与后台任务模式感兴趣的工程师
- 计划基于 MIT 许可代码进行二次开发与扩展的贡献者
上手与定制指南
结合仓库当前版本的说明,按下面的资料检查内容、配置与运行要求。
- 1
需要 Docker Desktop 与 Docker Compose、Go、Node.js 与 pnpm,并准备 Stytch B2B 测试项目。
- 2
先安装前端依赖并运行 setup.sh 生成本地配置,再将 Stytch 测试凭证填入被忽略的 backend/app.env。
- 3
使用 make dev 启动 API、worker 与前端;本地 Web、Go API、Swagger UI 与 Mailpit 分别监听各自端口。
- 4
数据库迁移为可重置的开发基线,schema 变更后可能需要重建本地数据。
- 5
无凭证的本地测试不能覆盖真实 R2、Polar、Mistral、OpenAI、SMTP、Stytch 生产域名与公共 webhook 行为。
授权与来源资料
使用条件与限制
免费使用 · 保留许可声明本次收录的是公开仓库中采用 MIT 许可的免费版本;免费范围为该版本代码,不代表外部服务或第三方素材免费。
使用时需要遵守
- 允许免费使用、修改、商用和分发该版本代码。
- 分发代码副本或实质性部分时,保留原作者版权声明和完整 MIT 许可声明。
- 代码按现状提供;担保与责任限制以原许可证及适用法律为准。
额外费用与待核对事项
- 本地运行需要自行创建 Stytch B2B 测试项目并提供凭证,认证与魔法链接邮件依赖 Stytch 外部服务。
- 必须将 Stytch 测试凭证填入 backend/app.env 才能启动,缺少凭证无法完成认证流程。
- 无凭证测试无法验证真实 R2、Polar、Mistral、OpenAI、SMTP、Stytch 生产域名、公共 webhook、已认证浏览器与原生移动端行为。
- 外部业务供应商不可用运行时假实现替代;选中供应商必须提供完整配置,否则启动失败。
- 数据库迁移为可重置的开发基线,schema 变更后贡献者可能需要重建本地数据。
- 项目明确非生产就绪,仅适用于本地开发与架构研究。
- 生产部署、CI/CD、发布自动化与运维认证仍属路线图工作,尚未实现。
- 真实供应商验收尚未记录,不能据此认为已通过生产级验证。
- 演示图片、字体、图标及其他第三方素材需按各自许可核对,不能仅凭代码的 MIT 许可判断。
- 域名、托管、数据库、支付或 AI 等外部服务可能另外收费。
查看原文依据
Permission is hereby granted, free of charge
许可证原文
a Stytch B2B test project for authentication
README 原文
Add your Stytch test credentials to ignored `backend/app.env`
README 原文
Credential-free local tests do not prove real R2, Polar, Mistral, OpenAI, SMTP, Stytch production-domain, public webhook-recipient, authenticated-browser, or native-mobile behavior.
README 原文
External business providers are never replaced by runtime fakes. A provider is either explicitly disabled or selected with complete configuration; incomplete selected providers fail startup.
README 原文
database migrations are a resettable canonical development baseline and may require contributors to recreate local data after a schema change
README 原文
it is not production-ready
README 原文
Production deployment, CI/CD, release automation, and operational certification remain roadmap work.
README 原文
https://github.com/azerturk/go-nextjs-ai-saas-starter/blob/development/LICENSEhttps://github.com/azerturk/go-nextjs-ai-saas-starter/blob/development/README.mdReal-provider acceptance is not yet recorded for this local-development system.
README 原文
DeepSeek 根据仓库许可证和 README 整理 ·2026-10-01。结果仅覆盖已读取资料,依赖、图片、字体及后续条款变更以各自原文为准。
项目核对记录与介绍依据
模板资料
- 来源平台
- GitHub
- 资料与维护参考分
- 资料一般 · 73 / 100
- 技术栈
- Next.js · React
- 网站类型
- SaaS · 启动器
这个分数如何计算
本站按许可资料(最高30分)、演示链接(12分)、预览图(10分)、Star数(15分)、记录的维护时间(15分)、描述完整度(8分)、功能记录(5分)和分类资料(5分)计算。它不是代码、安全或性能测试,也不是 Google 评分;有链接不代表已实测可用。
这个项目需要核对什么
- 记录的仓库更新时间
- 2026-08-18
- 截图检查日期
- 2026-10-01
目前没有记录演示链接。请依据仓库说明在本地评估;仅凭截图无法确认交互行为。
目录记录的主要技术栈是 Next.js。请通过依赖清单和锁文件核对实际版本与托管要求。这些说明基于收录资料,不代表代码审计或部署实测。
查看具体选型方法 →介绍的制作与核对状态
介绍由 AI 辅助整理目录与仓库资料。仓库作者不等于这篇介绍的审核者。
已完成服务器许可规则与 AI 来源核对;未经过人工编辑审核。
查看当时使用的来源资料
SHA-256: 7116132c5b395561a179a6ac305ae305570f1925bd59ef19920daebfff2ea23c
2026-10-01T01:10:23.529Z
来源文件 / 仓库# Go + Next.js AI SaaS Starter A development-preview foundation for building multi-tenant AI document operations with Go and Next.js. It combines secure document ingestion, permission-aware retrieval, cited AI answers, typed extraction and review workflows, commercial entitlement boundaries, durable background processing, and audit evidence in one pragmatic modular monolith. > **Status:** Experimental hobby project currently in active development. This repository is designed for local development and architecture study; it is not production-ready. Real-provider acceptance is not yet recorded for this local-development system. Production deployment, CI/CD, release automation, and operational certification remain roadmap work. The initial public repository uses `development` as its only/default branch. A stable `main` branch will be created only when the production track is explicitly promoted. Until then, database migrations are a resettable canonical development baseline and may require contributors to recreate local data after a schema change.  ## What is implemented - Stytch B2B magic-link authentication with HttpOnly web cookies and a Bearer JWT contract for future mobile/API clients. - Go-enforced organization context, tenant isolation, canonical `admin`/`manager`/`member` roles, permissions, fresh-session checks, and subscription enforcement. - PostgreSQL schema-per-module ownership, forced tenant RLS, SQLC, and explicit request/worker/migration database roles. - PDF upload, ClamAV scanning, S3-compatible local object storage, document versions, OCR, embeddings, hybrid retrieval, permission-aware RAG, and byte-exact citations. - Typed extraction templates and durable runs, immutable results, human approval/rejection, approved-output publication/export, and signed HTTPS webhook delivery. - Polar adapters plus local catalog, entitlement, usage, reservation, quota, checkout, portal, and webhook boundaries. - Product SMTP notifications, immutable audit evidence, transactional outbox, Redis Streams, retry, DLQ, and allowlisted replay tooling. - OpenTelemetry traces, private Prometheus metrics, structured redacted logs, readiness checks, architecture fitness tests, and synthetic RAG evaluation. External business providers are never replaced by runtime fakes. A provider is either explicitly disabled or selected with complete configuration; incomplete selected providers fail startup. ## Architecture The backend is one Go modular-monolith codebase with coordinated API, worker, and bounded operator runtime roles. The architecture is intentionally pragmatic: - module roots expose public contracts; private application, domain, transport, repository, worker, and provider code stays behind each owner boundary; - ports and adapters are introduced where ownership, substitution, or external infrastructure requires them, not for every function; - lifecycle, authorization, provenance, quota, replay, and publication invariants use focused domain types, while straightforward orchestration remains layered application code; - use cases may be organized as vertical slices inside a module without bypassing the module and layer rules; - synchronous invariants use direct public contracts, while durable jobs and integration facts use transactional outbox plus Redis Streams; - Next.js is the UI/SSR layer and calls the versioned Go API directly; it is not a business BFF. See the [current-system documentation](docs/current-system/README.md) and [architecture overview](docs/architecture/overview.md). ## Technology - Go 1.26.6, Gin, SQLC, PostgreSQL 17, pgvector, Redis 8 Streams - Next.js 16.3.0, React 19.2.8, TypeScript, Tailwind CSS 4, TanStack Query - MinIO for local S3-compatible storage, Mailpit for local product email, ClamAV for upload scanning - Stytch, Cloudflare R2, Mistral OCR, OpenAI, Polar, generic SMTP, and hardened HTTPS webhooks behind explicit adapters ## Local quick start Prerequisites: - Docker Desktop with Docker Compose - Go 1.26.6 - Node.js 24.19.0 and pnpm 11.20.0 - a Stytch B2B test project for authentication Select the pinned Node.js and package-manager versions: ```bash nvm install 24.19.0 nvm use 24.19.0 corepack enable corepack prepare [email protected] --activate ``` Install frontend dependencies, create local configuration, and start local infrastructure: ```bash cd frontend pnpm install --frozen-lockfile cd .. chmod +x setup.sh ./setup.sh ``` Add your Stytch test credentials to ignored `backend/app.env`, then start the API, worker, and frontend: ```bash make dev ``` Local endpoints: - web: [http://localhost:3000](http://localhost:3000) - Go API: [http://localhost:8080](http://localhost:8080) - Swagger UI: [http://localhost:8080/swagger/index.html](http://localhost:8080/swagger/index.html) - Mailpit product-email UI: [http://localhost:8025](http://localhost:8025) Mailpit captures only product SMTP messages. Stytch sends authentication and magic-link email through Stytch infrastructure. ## Verification ```bash make test make test-integration make test-e2e ``` Specialist backend gates are available under `backend/`, including `make test-worker`, `make test-race`, `make test-fuzz`, `make rag-eval`, `make sqlc`, `make swagger`, `make lint`, and `make build`. Frontend gates include `pnpm test`, `pnpm lint`, `pnpm typecheck`, `pnpm build`, and `pnpm api:contracts:check`. Credential-free local tests do not prove real R2, Polar, Mistral, OpenAI, SMTP, Stytch production-domain, public webhook-recipient, authenticated-browser, or native-mobile behavior. See [testing](docs/testing.md) for the exact boundary. ## Documentation - [Setup](SETUP.md) - [Development guide](DEVELOPMENT.md) - [Configuration](docs/configuration.md) - [Current system](docs/current-system/README.md) - [Architecture](docs/architecture/overview.md) - [Backend developer guides](backend/docs/README.md) - [Frontend developer guides](frontend/docs/README.md) - [Database ownership](docs/database/schema-ownership-baseline.md) - [Testing](docs/testing.md) - [Security](SECURITY.md) - [Roadmap](docs/roadmap.md) ## License [MIT License](LICENSE) ## Acknowledgements This project was originally based on `moasq/production-saas-starter` by Mohammed Salim and has since been substantially modified and extended. The original project is licensed under the MIT License.
看看同类模板
对比同技术栈与用途的模板,找到更适合的视觉与内容结构。

ai-website-cloner-template
Clone any website with one command using AI coding agents
Next.js · 启动器

Next.js SaaS Starter
Next.js SaaS Starter 是 Next.js 官方维护的 SaaS 起点模板,定位介于学习资源和可直接部署的脚手架之间。
Next.js · SaaS

Next.js Commerce
Next.js Commerce 是 Vercel 团队维护的电商启动模板,基于 Next.js App Router 构建,采用服务端渲染、React Server Components、Server Actions …
Next.js · 电商

Next-js-Boilerplate
Next-js-Boilerplate 是一个面向 Next.js 16、Tailwind CSS 4 和 TypeScript 的启动器,核心定位是开发者体验优先。
Next.js · 启动器

tailwind-nextjs-starter-blog
tailwind-nextjs-starter-blog 是一个面向个人技术博客的 Next.js 与 Tailwind CSS 启动模板,其 v2 版本基于 App Router 与 React Server Comp…
Next.js · 博客

next-forge
Production-grade Turborepo template for Next.js apps.
Next.js · 启动器
