This is a Next.js (full stack) app designed to help construction teams track tools and materials, reduce shrinkage, and save money.
- Getting Started
- Tech Stack Docs
- Required Software
- About the env file
- Connecting to Supabase
- Backend and Data Boundaries
- API Routes
- Storage
- Useful Commands
This app is designed to run locally for development. You’ll need Node.js and a Supabase project.
For the current stack overview and the project documentation map, see docs/tech-stack.md.
For app-level rules around organizations, projects, materials, tools, and invites, see docs/business-logic.md.
- Node.js (v20 or higher recommended) Download from https://nodejs.org/ Verify installation:
node -v- Supabase Account Sign up at https://supabase.com/ and create a project.
You must create your own .env.local file based on the provided .env.example.
The .env.local file contains sensitive configuration values that must never be committed or pushed to any repository under any circumstances.
Set the following variables in .env.local:
NEXT_PUBLIC_SUPABASE_URL=your-supabase-url
NEXT_PUBLIC_SUPABASE_ANON_KEY=your-supabase-anon-key
SUPABASE_SERVICE_ROLE_KEY=your-service-role-key
RESEND_API_KEY=your-resend-api-key
RESEND_FROM_EMAIL="TrakFlow <[email protected]>"
SUPABASE_PROJECT_ID=your-project-id
TRAKFLOW_BOOTSTRAP_TEST_PASSWORD=your-shared-test-password
NEXT_PUBLIC_APP_URL=http://localhost:3000Minimum required to run the app:
NEXT_PUBLIC_SUPABASE_URLNEXT_PUBLIC_SUPABASE_ANON_KEY
Required only for the hosted bootstrap flow:
SUPABASE_SERVICE_ROLE_KEYTRAKFLOW_BOOTSTRAP_TEST_PASSWORD
Required only for foreman invite emails:
RESEND_API_KEYRESEND_FROM_EMAILNEXT_PUBLIC_APP_URL
Optional:
SUPABASE_PROJECT_ID
Get the Supabase values from your Supabase project dashboard. Keep the shared
bootstrap password only in .env.local.
NEXT_PUBLIC_SUPABASE_URLshould match your Supabase project’s API URL.NEXT_PUBLIC_SUPABASE_ANON_KEYis your project’s anon/public key.SUPABASE_SERVICE_ROLE_KEYis required for the shared hosted dev bootstrap flow.TRAKFLOW_BOOTSTRAP_TEST_PASSWORDis the shared password reset onto the seeded test accounts during bootstrap reruns.RESEND_API_KEYandRESEND_FROM_EMAILare used by Resend for foreman invite emails.NEXT_PUBLIC_APP_URLis used to build absolute invite links.
See docs/repo-bootstrap.md for:
- the hosted Supabase workflow for teammates
- the local Supabase + Docker workflow for migration work
- the shared hosted bootstrap script and test accounts
- the local seed strategy
TrakFlow uses Next.js Server Components, server actions, and Supabase as the backend. Keep backend code readable by preserving these boundaries:
lib/dal/*is the data access layer. Use it for focused database reads, safe row mapping, and reusable query helpers.app/services/*owns business workflows. Use it for server actions, mutations, permission checks, cache invalidation, storage coordination, and Supabase RPC orchestration.supabase/migrations/*owns schema, RLS, indexes, triggers, and database functions.- Supabase functions should be reserved for atomic, security-sensitive, or concurrency-sensitive workflows such as checkout, return, invite claiming, material usage logging, and generated counters.
- Avoid putting UI behavior, page-specific copy, component state, or workflow decisions in DAL helpers or Supabase functions.
- Add production database changes as new migrations. Do not edit old migrations after they may have been applied to a shared or hosted project.
When optimizing data loading, remove request waterfalls first, then narrow selected columns, add focused indexes for real query paths, and verify the query plan in Supabase.
This app uses Next.js API routes for backend logic.
You can add new endpoints under the app/api/ directory.
All commands are run from the project root.
- Install dependencies:
npm install- Start the development server:
npm run devOpen http://localhost:3000 in your browser.
- Build for production:
npm run build- Start production server:
npm run start- Lint the code:
npm run lint- Bootstrap the shared hosted dev project:
npm run db:bootstrap:hosted -- --confirm-hosted-devTo learn more about Next.js, take a look at the following resources:
- Next.js Documentation - learn about Next.js features and API.
- Learn Next.js - an interactive Next.js tutorial.
You can check out the Next.js GitHub repository - your feedback and contributions are welcome!
The easiest way to deploy your Next.js app is to use the Vercel Platform from the creators of Next.js.
Check out our Next.js deployment documentation for more details.