Project Structure
Stanzo uses a dual-runtime architecture:- Next.js 16 - Frontend application with React 19
- Convex - Backend for real-time data, authentication, and serverless functions
Development Configuration
Package Scripts
Stanzo uses npm scripts defined inpackage.json for development and deployment:
| Script | Command | Description |
|---|---|---|
dev | npm run dev | Runs Next.js and Convex in parallel |
dev:next | npm run dev:next | Runs only Next.js dev server on port 3000 |
dev:convex | npm run dev:convex | Runs only Convex dev environment |
build | npm run build | Builds Next.js for production |
start | npm run start | Starts Next.js production server |
lint | npm run lint | Runs oxlint for code quality |
format | npm run format | Formats code with oxfmt |
Parallel Development Setup
Install dependencies
- Next.js 16.1.6
- Convex 1.32.0
- React 19.2.4
- Authentication (@convex-dev/auth)
- AI SDKs (Deepgram, Google Gemini, Perplexity)
Start development servers
Run both Next.js and Convex in parallel:This uses
npm-run-all --parallel to run:next devonhttp://localhost:3000convex devfor the Convex backend
The parallel execution ensures both the frontend and backend hot-reload during development. Changes to Convex functions are automatically deployed to your dev environment.
Next.js Configuration
next.config.ts
Stanzo uses a minimal Next.js configuration (next.config.ts):
- App Router - Modern routing with server and client components
- Tailwind CSS 4.2.1 - Styling with PostCSS
- TypeScript 5.9.3 - Full type safety
If you need to customize Next.js behavior (e.g., image domains, redirects, headers), add configuration options to the
config object.TypeScript Configuration
The project uses strict TypeScript settings. All.ts and .tsx files are type-checked during:
- Development (in your IDE)
- Build time (
npm run build) - Linting (
npm run lint)
Convex Configuration
Authentication Setup
Convex authentication is configured inconvex/auth.config.ts:
Convex Functions
Stanzo includes several Convex functions:-
Actions (
convex/factCheck.ts,convex/claimExtraction.ts,convex/deepgramToken.ts)- Call external APIs (Perplexity, Gemini, Deepgram)
- Run asynchronously and can be long-running
- Use Effect-TS for retry logic and error handling
- Mutations - Update database state
- Queries - Read database state
- Internal functions - Private functions not exposed to clients
Convex functions automatically get type-safe client bindings. Import from
convex/_generated/api to call functions with full TypeScript support.Building for Production
Build Next.js
.next/:- Minifies JavaScript and CSS
- Optimizes images and fonts
- Generates static pages where possible
- Creates server-side bundles
Test production build locally
http://localhost:3000. Test critical functionality before deploying.Deployment Platforms
Recommended: Vercel + Convex
Stanzo is optimized for deployment on Vercel with Convex:Deploy to Vercel
- Push your code to GitHub
- Import the repository in Vercel
- Add environment variable in Vercel dashboard:
NEXT_PUBLIC_CONVEX_URL= your Convex production URL
- Deploy
Vercel automatically detects Next.js and uses optimal build settings. No additional configuration needed.
Alternative Platforms
Stanzo can deploy to any Next.js-compatible platform:- Netlify - Similar to Vercel, with automatic Next.js detection
- Self-hosted - Use
npm run build && npm run startwith a Node.js server - Docker - Create a Dockerfile with Node.js 20+ and run the production build
- Node.js 20 or higher
NEXT_PUBLIC_CONVEX_URLenvironment variable- Convex backend deployed separately
Production Considerations
Environment Variables
Analytics and Monitoring
Stanzo includes Vercel Analytics and Speed Insights (package.json:20-21):
- Real-time traffic analytics
- Core Web Vitals monitoring
- Performance insights
Database Migrations
Convex handles schema migrations automatically. When deploying schema changes:- Validate the new schema
- Migrate existing data if compatible
- Warn about breaking changes
Scaling Considerations
- Next.js: Scales automatically on Vercel with serverless functions
- Convex: Scales automatically based on usage
- API Rate Limits: Monitor usage for Deepgram, Gemini, and Perplexity to avoid hitting rate limits
Troubleshooting
Build Failures
Ifnpm run build fails:
- Check TypeScript errors:
npx tsc --noEmit - Check for missing dependencies:
npm install - Verify environment variables are set
- Clear build cache:
rm -rf .next
Convex Deployment Issues
Ifnpx convex deploy fails:
- Verify you’re logged in:
npx convex login - Check schema validity:
npx convex dev(locally) - Review function errors in Convex dashboard
Runtime Errors
Common production issues:- “CONVEX_URL is not defined”: Set
NEXT_PUBLIC_CONVEX_URLin hosting platform - “API key not set” errors: Set API keys in Convex with
--prodflag - Authentication failures: Verify
CONVEX_SITE_URLmatches your deployed domain
Check the Convex dashboard logs for detailed error messages from actions and mutations.