Overview
The Equestrian School Management System uses environment variables to configure different aspects of the application. This guide covers both development and production environment setup.Environment Variables
Required Variables
Base URL for the backend API endpointExample:
https://your-api.com/api/v1Environment Files
Create the appropriate environment file for your setup:Development Environment
Local Development Setup
Step 1: Create Environment File.env and set your local backend URL:
- Local:
http://localhost:5173 - Network:
http://[your-ip]:5173
Development Server Configuration
The dev server is configured invite.config.ts:8-11:
- Hot Module Replacement (HMR)
- Fast Refresh with SWC
- IPv6 support
- Network access for mobile testing
Development Tools
React DevTools- Install browser extension for debugging
- Inspect component hierarchy
- Profile performance
- Module graph visualization
- HMR debugging
- Build analysis
Production Environment
Building for Production
Step 1: Configure Production Variables Create.env.production:
- Optimized JavaScript bundles
- Minified CSS
- Compressed assets
- Output directory:
dist/
Production Optimizations
The production build includes (vite.config.ts:20-25):
Backend API Configuration
API Endpoints
The application expects the following API structure: Authentication Endpoints (src/services/authService.ts:3)
Authentication Method
The system uses Basic Authentication with Base64 encoding:- Credentials stored in
sessionStorage - Automatically cleared on browser close
- 15-minute idle timeout
CORS Configuration
Ensure your backend API allows requests from your frontend domain:Deployment Environments
Vercel Deployment
1. Install Vercel CLINetlify Deployment
1. Install Netlify CLIDocker Deployment
Dockerfile Example:Environment-Specific Features
Development Mode Features
- Component tagging with
lovable-tagger - Hot Module Replacement
- Detailed error messages
- Source maps enabled
- Console logs preserved
Production Mode Features
- Optimized bundle size
- No source maps (
sourcemap: false) - Console logs removed
- Debug statements stripped
- Aggressive minification
Security Considerations
Environment Variables
Environment Variables
- Never commit
.envfiles with sensitive data - Use
.env.exampleas a template - Store secrets in deployment platform’s secret management
- Rotate credentials regularly
API Security
API Security
- Always use HTTPS in production
- Implement rate limiting on API endpoints
- Validate all user inputs
- Use secure session storage
Authentication
Authentication
- 15-minute idle timeout (
src/components/auth/IdleHandler.tsx:21) - Session credentials cleared on logout
- Email whitelist for registration
- Strong password requirements (min 8 characters)
Monitoring and Debugging
Development Debugging
Browser Console:- View network requests
- Check authentication headers
- Monitor state changes
- Inspect component props
- Track state updates
- Profile performance
Production Monitoring
Consider integrating:- Sentry - Error tracking
- LogRocket - Session replay
- Google Analytics - Usage analytics
- Datadog - Performance monitoring
Troubleshooting
Environment variables not loading
Environment variables not loading
- Ensure variable names start with
VITE_ - Restart the dev server after changes
- Check file is named exactly
.env - Verify file is in project root
API connection failed
API connection failed
- Verify
VITE_API_BASE_URLis correct - Check backend is running
- Verify CORS configuration
- Check network tab for errors
- Ensure authentication headers are present
Production build fails
Production build fails
- Clear node_modules and reinstall
- Check for TypeScript errors:
npx tsc --noEmit - Verify all environment variables are set
- Check ESLint warnings:
npm run lint
Next Steps
User Management
Configure user authentication and roles
Data Backup
Set up backup and recovery procedures