A React-based chat interface for Heroku's Managed Inference and Agents service.
- Modern React 18 and React Router v7 application with TypeScript
- Real-time chat interface with streaming responses
- Fastify server for production deployment
- Fully configured for Heroku deployment
- Enhanced Security Features:
- Session-based CSRF protection with secure cookies
- Strict CORS same-origin policy
- Content Security Policy and comprehensive security headers
- Rate limiting with IP and user agent tracking
- Automatic security initialization on app startup
.
├── app.json # Heroku application configuration
├── client/ # React frontend application
│ ├── src/ # Source code
│ └── dist/ # Build output
└── server/ # Fastify server for serving the React app
├── src/ # Server source code
└── dist/ # Server build output
- Node.js 22 or later
- pnpm 10 or later
- Heroku CLI (for deployment)
-
Install dependencies:
# Install all dependencies using pnpm workspaces pnpm install
-
Set up environment variables:
# Create your .env file with the required variables # SESSION_SECRET: A secure random key for session encryption (generate with: openssl rand -hex 32) # CSRF_SECRET: A secure random key for CSRF token signing (generate with: openssl rand -hex 32) # Example .env file: SESSION_SECRET=your-very-secure-session-secret-here CSRF_SECRET=your-very-secure-csrf-secret-here
-
Start the development server:
# Start both client and server in development mode pnpm dev
The application will be available at
http://localhost:3000
Make sure to set secure values for these environment variables:
SESSION_SECRET
: A cryptographically secure random key for session encryption (minimum 32 characters)CSRF_SECRET
: A cryptographically secure random key for CSRF token signing (minimum 32 characters)NODE_ENV
: Set to 'production' to enable secure cookies and HTTPS-only mode
Generate secure keys using: openssl rand -hex 32
-
Build all packages:
pnpm build
-
Start the production server:
pnpm start
-
Install the Heroku CLI AI plugin
heroku plugins:install @heroku/plugin-ai
-
Create a new Heroku app:
heroku create your-app-name
-
Provision the Heroku Managed Inference and Agents models
heroku addons:create heroku-inference:claude-4-sonnet --as INFERENCE_4 heroku addons:create heroku-inference:claude-3-7-sonnet --as INFERENCE_3_7 heroku addons:create heroku-inference:claude-3-5-sonnet-latest --as INFERENCE_3_5 heroku addons:create heroku-inference:nova-lite --as INFERENCE_NOVA_LITE heroku addons:create heroku-inference:nova-pro --as INFERENCE_NOVA_PRO heroku addons:create heroku-inference:gpt-oss-120b --as INFERENCE_GPT_OSS heroku addons:create heroku-inference:stable-image-ultra --as DIFFUSION
-
Deploy to Heroku:
git push heroku main
- Fork or clone this repository
- Connect your GitHub repository to Heroku
- Enable automatic deploys or deploy manually from the Heroku Dashboard
pnpm dev
: Start development servers for both client and serverpnpm build
: Build both client and server for productionpnpm start
: Start the production serverpnpm test
: Run testspnpm lint
: Run lintingpnpm format
: Format code using Prettier
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
Apache 2.0