Skip to content

Phase 1: Foundation #6

Description

@bmfischer3

Foundation — Initial Scaffold

Status: ✅ Complete

Completed

  • Move existing files into src/ structure (app/, shared/, features/)
  • Install Drizzle ORM + Neon serverless driver + Drizzle Kit
  • Create tenants table schema (status enum, soft delete)
  • Create tasks table schema (FK to tenants)
  • Create audit_logs + access_logs table schemas
  • Schema barrel (shared/db/schema.ts) re-exporting all feature schemas
  • Drizzle connection (shared/db/index.ts)
  • drizzle.config.ts with .env.local support
  • Push schema to Neon (npm run db:push)
  • Permission constants (shared/lib/permissions.ts)
  • Subdomain middleware (src/middleware.ts)
  • Tenant resolution helpers (shared/lib/tenant.ts)
  • API auth helpers (shared/api/auth.ts)
  • Account-locked page (frozen/suspended/deactivated)
  • Updated .env.local.example, tsconfig.json, components.json, tailwind.config.ts

Architecture

  • Feature-sliced: app/ → features/* → shared/* (one-way deps)
  • Schema barrel pattern: features define tables, shared/db/schema.ts re-exports all
  • Subdomain routing: acme.localhost:3000 → rewrite to /tenant/* with x-tenant-slug header
  • 4-tier RBAC: admin > manager > member > viewer (via Stack Auth team permissions)

Key Files

  • src/middleware.ts — subdomain routing
  • src/shared/db/schema.ts — barrel schema
  • src/shared/lib/permissions.ts — role/permission constants
  • src/shared/api/auth.ts — resolveRequestContext, requireSuperAdmin
  • drizzle.config.ts — Drizzle Kit config

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions