Professional audit planning made simple
Calculate audit man-days instantly based on international standards (IAF MD 5:2019 and ISO/TS 22003:2022)
A modern, professional web application designed for certification professionals to streamline audit planning and resource allocation. Calculate audit man-days with precision using internationally recognized standards with proper database backend and accurate calculation methodology.
- Node.js 18+
- PostgreSQL database (or use Supabase/Neon for free tier)
-
Clone the repository
git clone <repository-url> cd React-audit-man-day-calculator
-
Install dependencies
npm install
-
Set up environment variables
cp .env.example .env # Edit .env with your database URL and secrets -
Set up database
# Generate Prisma client npm run db:generate # Push schema to database npm run db:push # Seed with default configuration npm run db:seed
-
Start the development server
npm run dev
-
Open your browser Navigate to http://localhost:3000
- ✅ Accurate Calculations: Fixed calculation logic based on proper IAF MD 5:2019 standards
- 🗄️ Database Backend: PostgreSQL with Prisma ORM for reliable data persistence
- 📊 Multiple Standards: Support for QMS, EMS, EnMS, FSMS, and Cosmetics GMP
- 🔍 Audit Types: Initial certification, surveillance, and recertification audits
- 📈 Detailed Reports: Comprehensive calculation breakdowns with stage distribution
- 📚 History Tracking: Searchable calculation history with proper data persistence
- ⚙️ Admin Configuration: Customizable calculation parameters with database storage
- 🔒 Audit Logging: Complete audit trail of all actions
- 📤 Export Functionality: CSV export with filtering options
- 🌐 Production Ready: Deployed on Vercel with proper environment configuration
- 🔐 Authentication: Secure user authentication with NextAuth.js
- 🌓 Theme Support: Beautiful light/dark mode with system preference detection
- 🌓 Light/Dark Mode: Elegant theme switching with persistence
- 📱 Responsive Design: Works seamlessly on desktop, tablet, and mobile
- ⚡ Real-Time Calculations: Instant results with detailed breakdowns
- 🔍 Smart Search & Filtering: Find calculations quickly
- 📊 Statistics Dashboard: Overview of calculation history and metrics
- 📈 Calculation History: Save, view, and manage all calculations
- 📁 Export Functionality: Download history as CSV files
- 🔄 Auto-Save: Persistent storage with backend API
- 📋 Detailed Reports: Comprehensive calculation breakdowns
- 🗑️ Soft Delete: Archive calculations without permanent deletion
- 🔍 Advanced Filtering: Filter by standard, audit type, date range
- 🔌 REST API: Complete backend with CRUD operations
- 🎯 Type Safety: Full TypeScript implementation
- ⚡ Performance: Optimized for speed and reliability
- 🛡️ Error Handling: Graceful fallbacks and user feedback
- 🔒 Data Validation: Zod schemas for type-safe validation
- 🔐 Middleware Protection: Route-level authentication
- 📊 Database Optimization: Efficient queries with Prisma
- Next.js 14 - React framework with App Router
- TypeScript - Type-safe JavaScript
- Tailwind CSS - Utility-first CSS framework
- Radix UI - Accessible UI components
- next-themes - Theme management
- Lucide React - Beautiful icons
- Next.js API Routes - Serverless API endpoints
- PostgreSQL - Reliable database with Prisma ORM
- Prisma - Type-safe database access
- Zod - Schema validation
- TypeScript - End-to-end type safety
- ESLint - Code linting
- PostCSS - CSS processing
- Vercel Analytics - Performance monitoring
- Prisma Studio - Database management UI
-
Navigate to "New Calculation" in the sidebar
-
Fill in Client Details:
- Company name
- Scope/Industry sector
-
Configure Audit Parameters:
- Select management system standard (QMS, EMS, EnMS, FSMS, Cosmetics)
- Choose audit type (Initial, Surveillance, Recertification)
- Pick appropriate category (AI, AII, BI, etc.)
-
Enter Organization Details:
- Number of employees
- Number of sites
- Risk/complexity level
- HACCP studies (for FSMS only)
- Integrated standards (optional)
-
Calculate & Save: Get instant results with detailed breakdowns
- View All Calculations: Access complete history in the History section
- Search & Filter: Find specific calculations by company, standard, or audit type
- Export Data: Download filtered results as CSV
- Detailed View: Click to see full calculation details
- Archive/Restore: Soft delete calculations for better organization
audit-calculator/
├── app/ # Next.js App Router
│ ├── api/ # API routes
│ │ ├── calculations/ # Calculation CRUD operations
│ │ ├── export/ # CSV export endpoint
│ │ └── stats/ # Statistics endpoint
│ ├── calculate/ # Calculation form page
│ ├── history/ # History management page
│ ├── results/ # Results display page
│ ├── admin/ # Admin configuration page
│ ├── auth/ # Authentication pages
│ ├── dashboard/ # Analytics dashboard
│ ├── globals.css # Global styles
│ ├── layout.tsx # Root layout
│ └── page.tsx # Home page
├── components/ # React components
│ ├── ui/ # Reusable UI components
│ ├── dashboard/ # Dashboard-specific components
│ ├── calculation-form-fixed.tsx # Fixed calculation form
│ ├── results-display.tsx # Results presentation
│ ├── history-management.tsx # History interface
│ ├── theme-provider.tsx # Theme context
│ ├── theme-toggle.tsx # Theme switch button
│ ├── sidebar-nav.tsx # Navigation sidebar
│ ├── providers.tsx # Context providers wrapper
│ └── main-layout.tsx # Page layout wrapper
├── lib/ # Utility libraries
│ ├── api-client.ts # Backend API client
│ ├── audit-calculator-fixed.ts # Fixed calculation engine
│ ├── storage-db.ts # Database storage layer
│ ├── database.ts # Prisma client
│ ├── config.ts # Configuration management
│ └── utils.ts # Helper functions
├── prisma/ # Database schema and migrations
│ ├── schema.prisma # Database schema
│ └── seed.ts # Database seeding
├── middleware.ts # Next.js middleware for auth
├── public/ # Static assets
└── styles/ # Additional styles
| Method | Endpoint | Description |
|---|---|---|
GET |
/api/calculations |
Get all calculations |
POST |
/api/calculations |
Save new calculation |
GET |
/api/calculations/[id] |
Get specific calculation |
PUT |
/api/calculations/[id] |
Update calculation |
DELETE |
/api/calculations/[id] |
Delete calculation |
DELETE |
/api/calculations |
Clear all calculations |
| Method | Endpoint | Description |
|---|---|---|
POST |
/api/auth/signin |
Sign in user |
POST |
/api/auth/signout |
Sign out user |
GET |
/api/auth/session |
Get current session |
| Method | Endpoint | Description |
|---|---|---|
GET |
/api/stats |
Get calculation statistics |
| Method | Endpoint | Description |
|---|---|---|
POST |
/api/export |
Export calculations as CSV |
- QMS - Quality Management System (ISO 9001)
- EMS - Environmental Management System (ISO 14001)
- EnMS - Energy Management System (ISO 50001)
- FSMS - Food Safety Management System (ISO 22000)
- Cosmetics - Good Manufacturing Practice
- Base Man-Days: IAF MD 5:2019 compliant base values
- Employee Adjustments: Based on organization size
- Risk Multipliers: Low (0.8x), Medium (1.0x), High (1.2x)
- Multi-Site: Additional man-days for multiple locations
- HACCP Studies: FSMS-specific adjustments
- Integrated Systems: Reduction for multiple standards
- Initial Certification: Stage 1 (30%) + Stage 2 (70%)
- Surveillance: 33% of initial audit man-days
- Recertification: 67% of initial audit man-days
See DEPLOYMENT.md for detailed deployment instructions.
- Connect your GitHub repo to Vercel
- Set environment variables:
DATABASE_URL: Your PostgreSQL connection stringNEXTAUTH_SECRET: Random secret keyNEXTAUTH_URL: Your Vercel app URL
- Deploy and run database setup
- Run migrations:
npm run db:deploy - Seed database:
npm run db:seed
# Database operations
npm run db:generate # Generate Prisma client
npm run db:push # Push schema to database
npm run db:migrate # Create and run migrations
npm run db:deploy # Deploy migrations to production
npm run db:studio # Open Prisma Studio
npm run db:seed # Seed database with default data
npm run db:reset # Reset database (development only)
# Development
npm run dev # Start development server
npm run build # Build for production
npm run start # Start production server
npm run lint # Run ESLintCreate a .env file:
# Database
DATABASE_URL="postgresql://username:password@localhost:5432/audit_calculator"
# NextAuth.js
NEXTAUTH_SECRET="your-secret-key-here"
NEXTAUTH_URL="http://localhost:3000"
# Optional: Analytics
NEXT_PUBLIC_VERCEL_ANALYTICS_ID=your_analytics_idThe calculator implements the following international standards:
- IAF MD 5:2019: International Accreditation Forum Mandatory Document
- ISO/TS 22003:2022: Requirements for bodies providing audit and certification
- Base Man-Days: Determined by organization category (IAF MD 5:2019 compliant)
- Employee Adjustments: Scaling based on workforce size
- Multi-Site Factors: Additional time for multiple locations
- Risk Multipliers: Complexity adjustments (Low: 0.8x, Medium: 1.0x, High: 1.2x)
- Integrated System Efficiency: Reduction for multiple standards (10% savings per standard)
- Stage Distribution: 30% Stage 1, 70% Stage 2 (for initial audits)
- HACCP Studies: FSMS-specific adjustments (0.5 man-days per study)
- Data Validation: Zod schemas for input validation
- Audit Logging: Complete trail of all actions
- Database Security: Proper connection handling and SSL
- API Security: Input sanitization and error handling
- No External Tracking: Privacy-focused implementation
- Database Connection: Verify DATABASE_URL and SSL settings
- Build Failures: Ensure Prisma client is generated
- Calculation Errors: Check input validation and standards
- Check the DEPLOYMENT.md guide
- Migration Issues: Run
npm run db:resetin development
- Review Vercel function logs
- Verify database connectivity and schema
- Use
npm run db:studioto inspect database
This project is licensed under the MIT License - see the LICENSE file for details.
- Documentation: Check this README and DEPLOYMENT.md
- Issues: Report bugs via GitHub Issues
- Community: Join discussions in GitHub Discussions
- ✅ Fixed calculation methodology
- ✅ Database backend with Prisma
- ✅ Proper data validation
- ✅ Audit logging
- ✅ Production deployment
- ✅ User authentication system
- ✅ Theme system with persistence
- ✅ Advanced filtering and search
- PDF report generation
- Multi-language support
- Advanced analytics dashboard
- API rate limiting
- Email notifications
- Bulk import/export
- Custom branding options
Built with ❤️ for certification professionals worldwide
Streamline your audit planning process with precision and confidence.