AI-powered session note generator for peer support agencies that automates documentation and compliance. The application generates HIPAA-compliant session narratives based on treatment plans and selected objectives, with full database integration and file export capabilities.
- JWT Authentication: Secure token-based authentication
- HIPAA Compliance: Built-in privacy protections and data encryption
- Session Timeout: Automatic logout after 15 minutes of inactivity
- Compliance Filters: Automatically removes non-compliant terminology
- Data Encryption: AES-256-CBC encryption for sensitive data
- Custom UI Components: Beautiful confirmation dialogs and toast notifications
- OpenAI GPT-4: Professional session note generation
- Treatment Plan Integration: Auto-extracts interventions from client treatment plans
- Dynamic Objectives: Auto-populates objectives based on client profile
- Peer Support Focus: Specifically designed for peer support specialists
- Customizable Prompts: Tailored for billing compliance
- PostgreSQL: Full database integration with connection pooling
- CRUD Operations: Complete session and client management
- Audit Logging: HIPAA-compliant audit trails
- Data Relationships: Proper foreign key relationships and constraints
- JSONB Support: Flexible storage for objectives and metadata
- Dashboard: Main application interface with session note generation
- Session History: View, edit, and manage previous sessions
- Admin Dashboard: Comprehensive management for users, clients, objectives, and locations
- Multi-Select Interface: Easy selection of objectives
- Responsive Design: Works on all device sizes
- Loading States: Proper loading and error handling
- Modern UI: Clean, professional design with Tailwind CSS v4
- Multiple Formats: Export to PDF, DOCX, and TXT
- Session Metadata: Optional metadata inclusion
- Secure Downloads: Direct download from browser
- Framework: Next.js 15.5.2 with App Router
- Language: TypeScript
- Styling: Tailwind CSS v4
- Database: PostgreSQL 17
- Authentication: JWT-based authentication
- AI Integration: OpenAI GPT-4
- Containerization: Docker & Docker Compose
- Node.js: 18+ (for local development)
- PostgreSQL: 12+ (for local development)
- Docker: 20.10+ and Docker Compose 2.0+ (for Docker deployment)
- OpenAI API Key: (optional, but recommended for production)
The easiest way to get started is using Docker Compose:
git clone <repository-url>
cd session-notes-appcp .env.example .env.localEdit .env.local and set your OPENAI_API_KEY:
OPENAI_API_KEY=your-openai-api-key-here# Build and start all services
npm run docker:up
# Or manually:
docker-compose up -d --buildThis will:
- Start PostgreSQL database container
- Initialize the database schema
- Build and start the Next.js application
- Set up networking between services
- Application: http://localhost:3000
- Database: localhost:5432 (internal Docker network)
npm run docker:logs
# Or manually:
docker-compose logs -fnpm run docker:down
# Or manually:
docker-compose downnpm run docker:build
# Or manually:
docker-compose up -d --buildgit clone <repository-url>
cd session-notes-app
npm installOption A: Using Docker (PostgreSQL only)
docker run -d \
--name session-notes-db \
-e POSTGRES_DB=session_notes_db \
-e POSTGRES_USER=session_notes_user \
-e POSTGRES_PASSWORD=your_secure_password \
-p 5432:5432 \
postgres:17-alpineOption B: Local PostgreSQL Installation
- Install PostgreSQL 12+ on your system
- Create database:
createdb session_notes_db - Create user:
createuser session_notes_user
# Set up database schema
npm run db:setup
# Or with sample data
npm run db:setup-with-dataIf running manually:
psql -U session_notes_user -d session_notes_db -f database/database.sqlcp .env.example .env.localUpdate .env.local with your values:
Required Variables:
# Database Connection
DATABASE_URL=postgresql://session_notes_user:your_secure_password@localhost:5432/session_notes_db
# Or individual variables:
DB_HOST=localhost
DB_PORT=5432
DB_NAME=session_notes_db
DB_USER=session_notes_user
DB_PASSWORD=your_secure_password
# Authentication
JWT_SECRET=your-super-secure-jwt-secret-key-change-this-in-production
# OpenAI (required for note generation)
OPENAI_API_KEY=your-openai-api-key-hereOptional Variables:
# Session Configuration
SESSION_TIMEOUT_MINUTES=15
# Application Settings
NODE_ENV=development
PORT=3000
NEXT_PUBLIC_API_URL=http://localhost:3000/api# Development mode
npm run dev
# Production build
npm run build
npm run startNavigate to http://localhost:3000
After initial database setup, you can log in with:
- Username:
admin - Password:
admin123
The docker-compose.yml file includes:
-
PostgreSQL Database (
postgres)- Image:
postgres:17-alpine - Port: 5432 (internal)
- Volume: Persistent data storage
- Auto-initialization: Database schema loaded on first run
- Image:
-
Next.js Application (
app)- Built from Dockerfile
- Port: 3000 (exposed to host)
- Health checks included
- Depends on PostgreSQL
postgres_data: Persistent PostgreSQL data storage
session-notes-network: Internal bridge network for service communication
The Docker Compose file uses these default values (override in .env.local):
DATABASE_URL=postgresql://session_user:session_password_123@postgres:5432/session_notes
JWT_SECRET=s3ssion-notes-super-secret-jwt-key-9a7f4c2d8b1eTo override Docker Compose settings, create a .env file:
OPENAI_API_KEY=your-key-here
JWT_SECRET=your-secret-here
POSTGRES_PASSWORD=your-password-heresession-notes-app/
βββ src/
β βββ app/ # Next.js app router
β β βββ api/ # API routes
β β β βββ auth/ # Authentication endpoints
β β β βββ clients/ # Client management
β β β βββ sessions/ # Session CRUD + exports
β β β βββ admin/ # Admin endpoints
β β β βββ lookup/ # Lookup data
β β β βββ openai/ # AI generation
β β βββ dashboard/ # Main application
β β β βββ admin/ # Admin dashboard
β β β βββ history/ # Session history
β β βββ layout.tsx # Root layout
β β βββ page.tsx # Login page
β βββ components/ # React components
β β βββ ui/ # Reusable UI components
β β βββ forms/ # Form components
β β βββ admin/ # Admin components
β β βββ auth/ # Authentication components
β βββ lib/ # Core utilities
β β βββ database.ts # PostgreSQL operations
β β βββ security.ts # Encryption & compliance
β β βββ api.ts # API client functions
β β βββ auth.ts # JWT utilities
β β βββ openai.ts # OpenAI integration
β β βββ treatmentPlanParser.ts # Treatment plan parsing
β βββ hooks/ # Custom React hooks
β βββ types/ # TypeScript definitions
β βββ context/ # React context providers
βββ database/
β βββ database.sql # Main database schema
β βββ migration.js # Database migration script
βββ docker-compose.yml # Docker Compose configuration
βββ Dockerfile # Docker image definition
βββ .env.example # Environment variables template
βββ package.json # Dependencies and scripts
POST /api/auth/login- User login
GET /api/clients- List all clientsPOST /api/clients- Create new clientGET /api/clients/[id]- Get client detailsPUT /api/clients/[id]- Update clientDELETE /api/clients/[id]- Delete client
GET /api/sessions- List user sessions (with pagination)POST /api/sessions- Create new sessionGET /api/sessions/[id]- Get session detailsPUT /api/sessions/[id]- Update sessionDELETE /api/sessions/[id]- Archive sessionGET /api/sessions/[id]/export- Export session (PDF/DOCX/TXT)
GET /api/admin/users- List all usersPOST /api/admin/users- Create userPUT /api/admin/users/[id]- Update userDELETE /api/admin/users/[id]- Delete userPOST /api/admin/users/[id]/reset-password- Reset user passwordGET /api/admin/objectives- List objectivesPOST /api/admin/objectives- Create objectivePUT /api/admin/objectives/[id]- Update objectiveDELETE /api/admin/objectives/[id]- Delete objective- Similar endpoints for
locations
GET /api/lookup- Get locations, objectives, clients
POST /api/openai/generate- Generate session note
GET /api/health- Application health status
The application uses a comprehensive PostgreSQL schema with:
- users: Authentication and role management
- clients: HIPAA-compliant client records (first name + last initial only)
objectives_selected: JSONB array of selected objective IDstreatment_plan: Text field for treatment plan
- session_notes: Generated notes with metadata
- session_objectives: Junction table for session objectives
- treatment_objectives: Lookup table for objectives
- session_locations: Lookup table for session locations
- audit_logs: HIPAA compliance audit trails
- Triggers: Automatic audit logging and timestamp updates
- Session Timeout: 15-minute automatic logout
- Data Encryption: AES-256-CBC for sensitive data
- Minimal Data Storage: Only first name + last initial
- Compliance Filters: Remove clinical/therapeutic terminology
- Audit Logging: Database-level audit triggers
- Secure Authentication: JWT with proper expiration
- Role-Based Access: User role management (admin/peer_support)
- Data Retention: Archive functionality for soft deletes
- SQL Injection Protection: Parameterized queries
- XSS Protection: Proper input sanitization
- CSRF Protection: SameSite cookies and CSRF tokens
- Environment Isolation: Separate dev/prod configurations
- Secure Headers: Next.js security headers
# Development
npm run dev # Start development server with Turbopack
npm run build # Build for production
npm run start # Start production server
npm run lint # Run ESLint
# Database
npm run db:setup # Set up database schema
npm run db:setup-with-data # Set up with sample data
npm run db:reset # Reset database with sample data
# Docker
npm run docker:up # Start Docker services
npm run docker:down # Stop Docker services
npm run docker:logs # View Docker logs
npm run docker:build # Rebuild and restart services-
Set Production Environment Variables
# Create .env.production OPENAI_API_KEY=your-production-key JWT_SECRET=your-production-secret POSTGRES_PASSWORD=your-secure-password -
Update docker-compose.yml
- Change default passwords
- Update JWT_SECRET
- Set production database credentials
-
Build and Deploy
docker-compose -f docker-compose.yml up -d --build
-
Set Up Reverse Proxy (Optional)
- Use Nginx or Traefik for SSL termination
- Configure domain name and SSL certificates
- Set up PostgreSQL database on your server
- Run database migrations:
npm run db:setup
- Build the application:
npm run build
- Start production server:
npm run start
- Use a process manager like PM2:
npm install -g pm2 pm2 start npm --name "session-notes" -- start
- Change default admin password
- Set strong JWT_SECRET
- Set secure database password
- Configure OpenAI API key
- Set NODE_ENV=production
- Enable HTTPS/SSL
- Set up database backups
- Configure firewall rules
- Set up monitoring/logging
- Review and update security settings
- Login: Test with default admin credentials
- Create Client: Add a new client with objectives
- Generate Session Note: Create a session and generate note
- Export Session: Test PDF, DOCX, and TXT exports
- Admin Dashboard: Test user, client, objective, and location management
- Session History: View, edit, and archive sessions
Database not connecting:
- Check if PostgreSQL container is running:
docker ps - Verify DATABASE_URL in docker-compose.yml
- Check database logs:
docker-compose logs postgres
Application won't start:
- Check application logs:
docker-compose logs app - Verify environment variables are set
- Ensure database is healthy before app starts
Port already in use:
- Change port in docker-compose.yml:
ports: - "3001:3000" # Use port 3001 instead
Database connection errors:
- Verify PostgreSQL is running:
pg_isready - Check DATABASE_URL format
- Ensure database and user exist
Build errors:
- Clear Next.js cache:
rm -rf .next - Reinstall dependencies:
rm -rf node_modules && npm install - Check Node.js version:
node --version(should be 18+)
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Make your changes
- Run tests and linting (
npm run lint) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
For support, please create an issue in the GitHub repository or contact the development team.
Made with β€οΈ for peer support agencies