Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
c3a3a58
feat: add organization features with Better Auth UI
jacksonkasi1 Jan 17, 2026
16f7482
chore: merge dev with organization features
jacksonkasi1 Jan 17, 2026
f50fe5e
feat: Implement organization-centric signup flow with dedicated navig…
jacksonkasi1 Jan 18, 2026
20ca5ab
feat: implement user metadata management for custom sign-up fields an…
jacksonkasi1 Jan 18, 2026
0b363bf
refactor(db): replace organizationName with metadata JSONB field
jacksonkasi1 Jan 18, 2026
b135710
feat(shared): add centralized user metadata and organization config
jacksonkasi1 Jan 18, 2026
95587b3
refactor(apps): simplify organization config using shared package
jacksonkasi1 Jan 18, 2026
ab15221
fix(db): add missing createdAt field to invitation table
jacksonkasi1 Jan 18, 2026
79dc695
feat: add created_at column to invitation, metadata column to user, a…
jacksonkasi1 Jan 18, 2026
a1090c8
fix(auth): remove additionalFields - better-auth requires real columns
jacksonkasi1 Jan 18, 2026
9792a9a
feat(auth): capture organization name in metadata via hooks.before
jacksonkasi1 Jan 18, 2026
ac09838
feat(auth): add signupMetadataStore to capture signup fields in metadata
jacksonkasi1 Jan 18, 2026
27103cd
refactor: upgrade Drizzle ORM and Neon dependencies, and migrate to `…
jacksonkasi1 Jan 18, 2026
8feedf0
feat(auth): integrate onboarding plugin for org creation
jacksonkasi1 Jan 18, 2026
34bca9e
wip(frontend): add onboarding integration (web app)
jacksonkasi1 Jan 18, 2026
07039e7
feat(web): complete onboarding integration
jacksonkasi1 Jan 18, 2026
b668396
fix(auth): export auth as type only, upgrade better-auth to 1.4.15
jacksonkasi1 Jan 18, 2026
fb37daa
feat(web): add configurable onboarding guard
jacksonkasi1 Jan 18, 2026
dedaff4
refactor(web): follow architecture patterns for onboarding
jacksonkasi1 Jan 18, 2026
9ade627
fix(web): use authClient.onboarding methods per official docs
jacksonkasi1 Jan 18, 2026
dab1cac
feat(db): add onboarding fields to user schema
jacksonkasi1 Jan 18, 2026
c8a197a
fix(web): remove onboardingClient auto-redirect to prevent loop
jacksonkasi1 Jan 18, 2026
380e1a8
fix(web): add disableOrganization option to prevent crash
jacksonkasi1 Jan 18, 2026
5e39794
fix: change invitation URL from path param to query param
jacksonkasi1 Jan 18, 2026
2c5a970
feat: add auth-aware invitation acceptance flow
jacksonkasi1 Jan 18, 2026
5e30b0e
feat: add configurable organization requirement setting
jacksonkasi1 Jan 18, 2026
b52ec79
feat: enforce organization membership requirement
jacksonkasi1 Jan 18, 2026
6790dd2
feat: add custom onboarding plugin package
jacksonkasi1 Jan 18, 2026
2d1883b
feat: add onboarding fields to user schema
jacksonkasi1 Jan 18, 2026
5042b40
feat: add centralized storage handlers package
jacksonkasi1 Jan 18, 2026
fc6001b
feat: integrate onboarding plugin into auth package
jacksonkasi1 Jan 18, 2026
e27294e
feat: implement multi-step onboarding UI
jacksonkasi1 Jan 18, 2026
fb51f65
refactor: remove old onboarding REST API endpoints
jacksonkasi1 Jan 18, 2026
204a55e
feat: add email verification banner and UI components
jacksonkasi1 Jan 18, 2026
64b6fcb
chore: update dependencies and configurations
jacksonkasi1 Jan 18, 2026
2c27166
docs: add organization invitations and configuration guide
jacksonkasi1 Jan 18, 2026
5b7b74f
feat: Implement marketplace features, update UI components, enhance p…
jacksonkasi1 Jan 18, 2026
8b828fd
docs: add comprehensive onboarding system guide
jacksonkasi1 Jan 18, 2026
ac3d8a1
feat(tanstack): sync invitation flow and org enforcement with web app
jacksonkasi1 Jan 18, 2026
ee746dc
docs: restructure documentation with progressive learning paths
jacksonkasi1 Jan 29, 2026
062abaf
docs: fix broken Better Auth external links
jacksonkasi1 Jan 29, 2026
5a28485
feat(auth-ui): implement Clerk-like configurable guards with full pat…
jacksonkasi1 Jan 29, 2026
7cd42f3
feat(auth): add auth mode configuration and documentation
jacksonkasi1 Jan 29, 2026
a2a5d4f
fix(auth): wire up centralized auth mode config to all packages
jacksonkasi1 Jan 29, 2026
024b9b4
update
jacksonkasi1 Jan 29, 2026
c1d825b
trigger deploy
jacksonkasi1 Feb 3, 2026
08a7ab4
Refactor: Improve routing and onboarding flow
jacksonkasi1 Feb 4, 2026
533207e
chore: update Zod dependency to v4.3.5 and adjust package scripts
jacksonkasi1 Feb 7, 2026
24570b1
Fix auth onboarding redirect loop and guard typings
jacksonkasi1 Feb 7, 2026
da87b75
Add configurable email verification policy in auth-ui guards
jacksonkasi1 Feb 7, 2026
d399b8a
Wire web routes and layout for email verification enforcement
jacksonkasi1 Feb 7, 2026
351d6ab
Document email verification policy modes for auth
jacksonkasi1 Feb 7, 2026
32d5770
Add TanStack email verification guard, banner, and hook
jacksonkasi1 Feb 7, 2026
0fe7d29
Wire TanStack app email verification config, layout banner, and verif…
jacksonkasi1 Feb 7, 2026
b38405d
Add TanStack onboarding routes and update route tree
jacksonkasi1 Feb 7, 2026
847f255
Standardize full-page loading states for onboarding flows
jacksonkasi1 Mar 23, 2026
fc93446
Restore visible fallback loaders in onboarding guards
jacksonkasi1 Mar 23, 2026
53ae65b
Merge remote-tracking branch 'origin/main' into dev
Sep 6, 2026
b3e3459
fix(auth): resolve onboarding redirect loop without disabling cookieC…
jacksonkasi1 May 1, 2026
23fc251
refactor(logging): demote hot-path get-session logs to debug, remove …
jacksonkasi1 May 1, 2026
3dc47fc
feat: unify starter presets and update the shared foundation
Sep 6, 2026
c30cee9
test: verify TanStack runtime responses and remove duplicate notifica…
Sep 6, 2026
c8c3420
docs: record live Neon tenant verification
Sep 6, 2026
451e77b
style: simplify email verification pages
Sep 6, 2026
ebf6b4e
feat: configure invitation signup and multiple organizations
Sep 6, 2026
1c43ca8
style: center invitation flow layout
Sep 6, 2026
28973c6
style: balance invitation actions
Sep 6, 2026
1422ee6
style: align account verification layout
Sep 6, 2026
793db30
fix: polish auth password controls
Sep 6, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .explorer/better-auth-extended
Submodule better-auth-extended added at 6e299b
47 changes: 47 additions & 0 deletions .github/workflows/verify.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Verify templates
on:
pull_request:
push:
branches: [dev]
workflow_dispatch:
permissions:
contents: read
jobs:
shared:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: actions/setup-node@v7
with:
node-version: "24"
- uses: oven-sh/setup-bun@v2
with:
bun-version: "1.3.14"
- run: bun install --frozen-lockfile
- run: bun run lint
- run: bun run check-types
- run: bun run test
- run: bun audit
presets:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
mode: [personal, organization]
frontend: [react, tanstack]
steps:
- uses: actions/checkout@v7
- uses: actions/setup-node@v7
with:
node-version: "24"
- uses: oven-sh/setup-bun@v2
with:
bun-version: "1.3.14"
- run: bun run setup --mode ${{ matrix.mode }} --frontend ${{ matrix.frontend }}
- run: bun install --frozen-lockfile
- run: bun run check-types
- run: bun run test
- run: bun run build
- if: matrix.frontend == 'tanstack'
run: node scripts/verify-tanstack-runtime.mjs
- run: bun audit
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ build

# Environment
.env
.env.*
!.env.example
.env.local
.env.*.local
.env.prod
Expand Down Expand Up @@ -43,6 +45,8 @@ ehthumbs.db

# Turbo
.turbo
.tanstack
.nitro

# Logs
*.log
Expand All @@ -53,3 +57,5 @@ yarn-error.log*
*.tsbuildinfo

.sisyphus
.explorer/better-auth-ui
opencode.json
243 changes: 68 additions & 175 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,197 +1,90 @@
# FlowStack

**FlowStack** is a production-grade SaaS foundation focused on **clean architecture, clear boundaries, and long-term maintainability**.
A shared SaaS starter with two account models and two frontend choices.
Maintain the foundation once, then configure it when starting a project.

It is not a framework.
It is not a boilerplate with magic.
## Quick start

FlowStack is a **base repository** designed to help you build scalable products without losing control of your codebase.
Install Node.js 24 LTS and Bun 1.3.14, then:

---

## Why FlowStack?

Most starters focus on **tech stack choices**.

FlowStack focuses on **flow**:

- how identity flows
- how permissions flow
- how responsibility flows
- how code grows without becoming messy

The goal is simple:

> **Make the architecture obvious, boring, and easy to evolve.**

---

## Core Principles

### 1. One Responsibility per File

- One action per file
- One API per file
- One schema per file

No large "god files".

---

### 2. One Responsibility per Folder

Folders represent **domains**, not features.

Examples:

- `auth` → identity (who are you?)
- `access` → permissions (what can you do?)
- `impersonation` → temporary identity
- `platform` → operator / super-admin logic

If a folder exists, the feature exists.
No runtime feature flags.

---

### 3. No Runtime Branching for Product Shape

There are **no** `if (config.xxx)` checks inside business logic.

All variability is resolved at **generation time**:

- modules are included or excluded
- unused folders are removed
- runtime code stays clean and predictable

---

### 4. Apps Compose, Packages Own Logic

- `apps/` contain routing and wiring
- `packages/` contain real logic

Apps never own business rules.

---

### 5. Boring Code > Clever Code

FlowStack prefers:

- explicit files
- explicit imports
- explicit boundaries

Over abstraction is avoided on purpose.

---

## Core Stack (Defaults, Not Lock-in)

FlowStack is **stack-aware**, but not stack-locked.

See **[docs/stack.md](./docs/stack.md)** for the default technologies and design philosophy.

These are tools FlowStack is built and tested with. You can replace parts of the stack if you know what you're doing.

---

## Authentication

FlowStack uses [Better Auth](https://www.better-auth.com/) for identity management with support for:

- Email/password authentication
- Magic link authentication
- OAuth providers (Google, GitHub, etc.)
- Session management
- Account settings and security

For detailed setup, configuration, and troubleshooting guides, see **[docs/auth/README.md](./docs/auth/README.md)**.

---

## High-Level Structure

```
apps/
web/ # Customer frontend
server/ # Customer API
super-admin/ # Operator panel (optional)

packages/
auth/ # Identity
access/ # Authorization (RBAC)
impersonation/ # Temporary identity
platform/ # Operator-level control
db/ # Database schema & migrations
env/ # Typed environment
email/ # Email providers & templates
storage/ # File storage
workflows/ # Background jobs
```sh
git clone --branch dev https://github.com/jacksonkasi1/FlowStack.git my-app
cd my-app
bun run setup
```

Each package is **independently understandable**.
Setup asks only:

---
1. **Personal or Organization** — individual accounts, or team workspaces with
onboarding, invitations and membership.
2. **React Router or TanStack Start** — both use React; the backend is Hono on Node.js.

## Configuration
The auth, database, email and storage packages are included automatically. Setup
installs dependencies and creates missing environment files from examples. Fill
in your credentials, run migrations, then start your chosen frontend and API:

All feature decisions live in one place:

```ts
flow.config.ts;
```sh
bun run --cwd packages/db db:migrate
bun run dev
```

This file answers **what exists**, not **how it works**.

Example:

- auth mode
- super-admin enabled or not
- impersonation enabled or not
- deployment targets

Runtime code assumes the decision is already made.

---

## What This Repo Is (and Isn't)

✅ A clean, extensible foundation
✅ A reference architecture
✅ A long-term base for real products

❌ Not a "plug and play" SaaS
❌ Not opinionated about UI design
❌ Not a low-code framework
See [the setup guide](docs/getting-started/template-setup.md) for environment
configuration, optional cleanup and deployment details.

You are expected to **build on top of it**.
## Separate starter copies

---

## Current Status

FlowStack is an **active base repository**.

Features will be added incrementally:

- more auth flows
- more workflow primitives
- more deployment helpers

Breaking changes may happen early while the foundation is being refined.
```sh
bun run setup --mode personal --frontend react --output ../my-app
bun run setup --mode organization --frontend tanstack --output ../team-app
```

---
Generated copies exclude Git history, environment files, dependencies and build
output. The destination must be empty. Omit `--output` to configure the current
clone, or add `--no-install` to prepare files only.

Setup retains source for both frontends and selects one workspace. You may remove
the unselected frontend manually afterward. Personal mode disables organization
and onboarding server plugins and UI. Both presets retain a shared database schema
and migration history. Configuration lives in
`packages/config/src/config/preset.ts`, with auth policy in `auth-mode.ts`.

## Structure

- `apps/web`: React + React Router frontend.
- `apps/tanstack`: TanStack Start frontend.
- `apps/server`: Hono API with a Node.js entry point.
- `packages/auth`, `auth-ui`, `onboarding`: authentication, guards and onboarding.
- `packages/config`, `db`, `email`, `email-templates`, `storage`, `logs`: shared foundation.
- `scripts/setup.mjs`: interactive and scripted setup.
- `tests`: setup, validation, guard and database-backed auth tests.

## Verification and maintenance

```sh
bun run lint
bun run check-types
bun run test
bun run build
bun audit
bun run verify:presets
```

## Philosophy
The auth integration suite uses embedded PostgreSQL and a stubbed email transport;
it does not contact your database or send real email. CI checks both account models
with both frontends. See [upgrade notes](docs/advanced/unified-template-upgrade.md)
for dependency compatibility, migrations and the new storage ownership rules.

> Scale is not about features.
> Scale is about clarity.
Development is on `dev`; releases are reviewed through PRs to `main`. Historical
backups are preserved. Existing customized projects do not update automatically:
use their `.flowstack.json` source commit and release notes to apply fixes.

FlowStack exists to keep that clarity intact as products grow.
## Documentation

---
- [Setup and presets](docs/getting-started/template-setup.md)
- [Authentication](docs/auth/README.md)
- [Architecture](docs/concepts/architecture.md)
- [Upgrade notes](docs/advanced/unified-template-upgrade.md)
- [Documentation index](docs/README.md)

## License

Expand Down
6 changes: 6 additions & 0 deletions apps/server/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,9 @@ R2_PUBLIC_URL=https://your-public-domain.com

# Skip validation during build (optional)
# SKIP_ENV_VALIDATION=true

# Invitation flow and multi-organization policy (keep server/frontend values aligned)
VITE_INVITE_DIRECT_SIGNUP=true
VITE_INVITE_LOCK_EMAIL=true
VITE_INVITE_SKIP_ORGANIZATION_ONBOARDING=true
VITE_ALLOW_MULTIPLE_ORGANIZATIONS=false
1 change: 1 addition & 0 deletions apps/server/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.vercel
15 changes: 10 additions & 5 deletions apps/server/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,19 +1,24 @@
FROM oven/bun:1
FROM oven/bun:1.3.14 AS build
WORKDIR /app

# Copy root workspace config
COPY package.json bun.lock turbo.json ./

# Copy packages and app source
COPY packages ./packages
COPY apps/server ./apps/server
COPY apps ./apps

# Install dependencies
RUN bun install
RUN bun install --frozen-lockfile

# Build the server
WORKDIR /app/apps/server
RUN bun run build

# Start the server
CMD ["bun", "run", "dist/index.js"]
FROM node:24-alpine AS runtime
WORKDIR /app
ENV NODE_ENV=production
COPY --from=build /app/apps/server/dist ./dist
USER node
EXPOSE 8080
CMD ["node", "dist/index.js"]
Loading
Loading