Frontend Setup Guide¶
Self-Hosting Not Recommended
This guide is for advanced users who want to self-host Ministry Mapper. We don't encourage self-hosting due to the technical complexity, maintenance burden, and security responsibilities involved.
Most users should: Use our hosted service at ministry-mapper.com
Looking for User Documentation?
If you're a regular user trying to learn how to use Ministry Mapper, see the Getting Started or User Guide instead.
Overview¶
The Ministry Mapper frontend (ministry-mapper-v2) is a React-based web application that provides:
- User authentication and account management
- Interactive territory management interface
- Interactive mapping functionality
- Real-time data synchronization
- Mobile-responsive design
- Multi-language support (8 languages)
- Progressive Web App capabilities
This guide assumes you have: - Experience with Node.js and npm - Understanding of environment variables - Familiarity with static site deployment - Knowledge of web application security
For complete self-hosting instructions, see the Self-Hosting Guide.
Quick Reference¶
This page provides a quick reference for frontend configuration. For complete setup instructions, see the Self-Hosting Guide.
Quick Reference¶
This page provides a quick reference for frontend configuration. For complete setup instructions, see the Self-Hosting Guide.
Technology Stack¶
- React 19: Modern UI library
- TypeScript: Type-safe JavaScript
- Vite 7: Fast build tool and dev server
- Bootstrap 5: Responsive CSS framework
- Leaflet: Interactive mapping
- PocketBase SDK: Backend connection
- Sentry: Error tracking
- i18next: Multi-language support
- Vite PWA: Progressive Web App features
Complete Setup Instructions
The sections below provide a technical reference for frontend configuration. For step-by-step setup instructions with deployment options and troubleshooting, please see the Self-Hosting Guide.
Environment Variables¶
Create a .env file in the root directory with these settings:
Required Variables¶
# System Environment - specifies the deployment environment
VITE_SYSTEM_ENVIRONMENT=production
# Version - automatically uses package.json version
VITE_VERSION=$npm_package_version
# PocketBase Backend URL - no trailing slash
VITE_POCKETBASE_URL=https://your-backend-url.com
# Legal Pages - required for production
VITE_PRIVACY_URL=https://your-site.com/privacy
VITE_TERMS_URL=https://your-site.com/terms
VITE_ABOUT_URL=https://your-site.com/about
Optional Variables¶
# Error Tracking (Sentry) - recommended for production
VITE_SENTRY_DSN=https://[email protected]/123456
# Build-time Sentry tokens for source map upload
SENTRY_AUTH_TOKEN=your_sentry_auth_token
SENTRY_ORG=your_sentry_org_slug
SENTRY_PROJECT=your_sentry_project_slug
# Routing & Geocoding
VITE_OPENROUTE_API_KEY=your_openrouteservice_api_key
VITE_LOCATIONIQ_API_KEY=your_locationiq_api_key
# Maintenance Mode - show a maintenance banner to users
VITE_MAINTENANCE_MODE=false
Variable Details¶
VITE_SYSTEM_ENVIRONMENT¶
- Purpose: Determines which environment the app is running in
- Values:
local- Development on your local machineproduction- Live deployment- Effect: Affects Sentry error tracking configuration and logging
VITE_VERSION¶
- Purpose: Tracks application version in error reports
- Value:
$npm_package_version(automatically reads from package.json) - Current Version: 1.9.1 (as of package.json)
- Effect: Shown in Sentry reports and helps track which version has issues
VITE_POCKETBASE_URL¶
- Purpose: URL of your PocketBase backend server
- Format: Full URL without trailing slash
- Example:
https://api.ministry-mapper.comorhttp://localhost:8090for local - Important: Must be accessible from wherever the frontend is deployed
VITE_PRIVACY_URL¶
- Purpose: Link to your privacy policy page
- Required: Yes, for legal compliance (GDPR, CCPA, etc.)
- Example:
https://ministry-mapper.com/privacy
VITE_TERMS_URL¶
- Purpose: Link to your terms of service page
- Required: Yes, for legal compliance
- Example:
https://ministry-mapper.com/terms
VITE_ABOUT_URL¶
- Purpose: Link to information about your Ministry Mapper instance
- Required: No, but recommended
- Example:
https://ministry-mapper.com/about
VITE_SENTRY_DSN¶
- Purpose: Sends JavaScript errors to Sentry for monitoring
- Get It From: sentry.io (free tier available)
- Required: No, but highly recommended for production
- Benefits: Track errors, monitor performance, get notified of issues
- Note: Only active when VITE_SYSTEM_ENVIRONMENT is "production"
SENTRY_AUTH_TOKEN / SENTRY_ORG / SENTRY_PROJECT¶
- Purpose: Used during
npm run buildto upload source maps to Sentry so that minified stack traces can be resolved back to your original source code - Required: No — source maps are generated locally if these are absent, but uploading them to Sentry greatly improves error debugging in production
- How to Get: Create an auth token in your Sentry organisation settings under Settings → Auth Tokens
VITE_OPENROUTE_API_KEY¶
- Purpose: Powers turn-by-turn routing and directions on the interactive map
- Get It From: openrouteservice.org (free tier available)
- Required: No — map navigation works without it, but directions will be unavailable
VITE_LOCATIONIQ_API_KEY¶
- Purpose: Geocoding (convert addresses to coordinates) and reverse geocoding (coordinates to addresses)
- Get It From: locationiq.com (free tier available)
- Required: No — the app works without it, but address search and auto-fill will be unavailable
VITE_MAINTENANCE_MODE¶
- Purpose: When set to
true, shows a maintenance banner to users - Values:
trueorfalse - Default:
false - Use Case: Set to
truetemporarily during backend upgrades or planned downtime
Local Development Setup¶
Prerequisites¶
You need Node.js version 24 or higher:
If you don't have Node.js 24+, download it from: nodejs.org
Setup Steps¶
1. Clone the Repository¶
2. Install Dependencies¶
This downloads all required packages. May take a few minutes depending on your internet connection.
3. Create Environment File¶
Edit .env with your settings:
VITE_SYSTEM_ENVIRONMENT=local
VITE_VERSION=$npm_package_version
VITE_POCKETBASE_URL=http://localhost:8090
VITE_PRIVACY_URL=http://localhost:3000/privacy
VITE_TERMS_URL=http://localhost:3000/terms
VITE_ABOUT_URL=http://localhost:3000/about
VITE_SENTRY_DSN=
VITE_OPENROUTE_API_KEY=
VITE_LOCATIONIQ_API_KEY=
VITE_MAINTENANCE_MODE=false
Note: You'll need a PocketBase backend running on port 8090. See the ministry-mapper-be repository for backend setup.
4. Start Development Server¶
The app will open at http://localhost:3000 (port 3000 is configured in vite.config.js).
Development Features¶
- Hot Module Replacement (HMR): Changes appear instantly without full page reload
- TypeScript Checking: Errors show in terminal and browser console
- Source Maps: Debugging is easier with original source code references
- Fast Refresh: React components update without losing state
Development Commands¶
# Start development server (port 3000)
npm start
# Run tests with Vitest
npm test
# Check code formatting
npm run prettier
# Auto-fix formatting issues
npm run prettier:fix
# Build for production
npm run build
# Preview production build locally
npm run serve
Code Quality Tools¶
Prettier (code formatting):
- Configured in
.prettierrc - Automatically formats on commit via Husky
- Run manually with
npm run prettier:fix
ESLint (code linting):
- Configured in
eslint.config.mjs - React and TypeScript rules enabled
- Checks for common errors and code quality issues
Husky (git hooks):
- Runs Prettier on staged files before commit
- Ensures consistent code formatting
- Validates commit messages with commitlint
Production Deployment¶
Building for Production¶
What happens during build:
- TypeScript compiles to JavaScript
- React code is optimized and minified
- CSS is processed and minified
- Source maps are generated
- Code is split into chunks for faster loading
- Output goes to
build/directory - Service worker is generated for PWA support
Build Output:
build/index.html- Main HTML filebuild/assets/- JavaScript, CSS, and other assets- Filenames include content hashes for caching
- Total size typically under 1MB (excluding external dependencies)
Deployment Options¶
Ministry Mapper frontend is a static web application. You can deploy it to any static hosting service.
Option 1: Vercel (Recommended)¶
Fast, free tier, automatic deployments.
Setup:
- Create account at vercel.com
- Click "New Project"
- Import your GitHub repository
- Configure:
- Framework Preset: Vite
- Build Command:
npm run build - Output Directory:
build - Install Command:
npm install - Add environment variables in Vercel dashboard
- Deploy
Vercel Features:
- Automatic deployments on git push
- Preview deployments for pull requests
- Custom domains
- HTTPS by default
- Global CDN
- Free for personal projects
Option 2: Netlify¶
Simple deployment with great features.
Setup:
- Create account at netlify.com
- "Add new site" → "Import an existing project"
- Connect GitHub repository
- Build settings:
- Build Command:
npm run build - Publish Directory:
build - Add environment variables
- Deploy
Netlify Features:
- Automatic deployments
- Form handling
- Serverless functions (if needed)
- Custom domains
- HTTPS by default
Option 3: Cloudflare Pages¶
Fast CDN with generous free tier.
Setup:
- Create account at cloudflare.com
- Go to Pages → "Create a project"
- Connect GitHub repository
- Build settings:
- Framework preset: Vite
- Build command:
npm run build - Build output directory:
build - Add environment variables
- Deploy
Cloudflare Features:
- Global CDN network
- DDoS protection
- Analytics
- Web Analytics without client-side tracking
Option 4: AWS S3 + CloudFront¶
More control, good for large deployments.
Setup:
- Create S3 bucket
- Enable static website hosting
- Upload
build/contents - Create CloudFront distribution
- Configure custom domain
- Set up SSL certificate
AWS Considerations:
- More complex setup
- Pay per usage (usually very cheap)
- More configuration options
- Good for enterprise deployments
Option 5: Self-Hosted¶
Host on your own server.
Using Nginx:
server {
listen 80;
server_name your-domain.com;
root /var/www/ministry-mapper/build;
index index.html;
location / {
try_files $uri $uri/ /index.html;
}
# Enable gzip compression
gzip on;
gzip_types text/plain text/css application/json application/javascript text/xml application/xml;
# Cache static assets
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2)$ {
expires 1y;
add_header Cache-Control "public, immutable";
}
}
Using Apache:
<VirtualHost *:80>
ServerName your-domain.com
DocumentRoot /var/www/ministry-mapper/build
<Directory /var/www/ministry-mapper/build>
Options -Indexes +FollowSymLinks
AllowOverride All
Require all granted
# Enable React Router
RewriteEngine On
RewriteBase /
RewriteRule ^index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.html [L]
</Directory>
</VirtualHost>
Important for Self-Hosting:
- Serve over HTTPS (required for PWA features)
- Configure proper CORS headers if backend is on different domain
- Set up proper caching headers for static assets
- Ensure SPA routing works (all routes serve index.html)
Environment Variables in Deployment¶
Important: Environment variables must be set during build time, not runtime, because Vite injects them at build time.
For Vercel/Netlify/Cloudflare:
- Add environment variables in the platform's dashboard
- They'll be available during the build process
For Self-Hosted:
- Set environment variables before running
npm run build - Or create
.env.productionfile with your settings
Setting Up Sentry (Optional but Recommended)¶
Sentry monitors JavaScript errors and performance.
1. Create Sentry Account¶
- Go to sentry.io
- Sign up (generous free tier available)
- Create a new project
- Choose platform: "React"
2. Get Your DSN¶
- After creating project, you'll see the DSN
- Or go to Settings → Projects → [Your Project] → Client Keys (DSN)
- Copy the DSN URL
3. Add to Environment¶
Note: Sentry is only active when VITE_SYSTEM_ENVIRONMENT is set to production.
4. Configure Sentry (Optional)¶
Source Maps: The build process automatically generates source maps, which help debug minified production code.
Alerts: Set up in Sentry dashboard:
- Email notifications for new issues
- Slack/Discord integration
- Custom alert rules for critical errors
- Release tracking
Multi-Language Support¶
Ministry Mapper includes 8 languages out of the box.
Supported Languages¶
- English (
en) - Spanish (
es- Español) - Japanese (
ja- 日本語) - Korean (
ko- 한국어) - Chinese (
zh- 中文) - Indonesian (
id- Bahasa Indonesia) - Malay (
ms- Bahasa Melayu) - Tamil (
ta- தமிழ்)
How Language Detection Works¶
- Uses
i18next-browser-languagedetector - Automatically detects from browser settings on first visit
- Users can manually switch language via the language selector in the navigation bar
- Selection is persisted in
localStorageand takes priority over browser settings - Falls back to English if the selected language is not supported
Adding a New Language¶
-
Create Translation File
-
Go to
src/i18n/locales/ - Create new file:
[language-code].json(e.g.,fr.jsonfor French) -
Copy structure from
en.json -
Translate All Strings
-
Translate all key-value pairs
- Keep the same JSON structure
-
Maintain placeholder variables like
{{variable}} -
Register Language
- Edit
src/i18n/index.ts - Import your translation file
- Add to resources object
Example for French:
import fr from './locales/fr.json';
resources: {
en: { translation: en },
fr: { translation: fr },
// ... other languages
}
Progressive Web App (PWA)¶
Ministry Mapper includes PWA support via Vite PWA plugin.
PWA Features¶
- Installable: Can be installed on mobile/desktop home screen
- Offline Assets: Static files are cached for faster loading
- Service Worker: Automatically generated and registered
- Cache Strategy: StaleWhileRevalidate for external assets, CacheFirst for fonts
PWA Configuration¶
Configuration in vite.config.js:
VitePWA({
registerType: "autoUpdate", // Auto-update service worker
manifest: false, // No manifest (can be added if needed)
workbox: {
globPatterns: ["**/*.{js,css,html,ico,png,svg,woff2}"],
skipWaiting: true, // Activate new service worker immediately
clientsClaim: true, // Take control of clients immediately
cleanupOutdatedCaches: true, // Remove old caches
},
});
Caching Strategy¶
External Assets (e.g., from assets.ministry-mapper.com):
- Strategy: StaleWhileRevalidate
- Cache name: "external-assets"
- Expiration: 7 days, max 50 entries
Fonts:
- Strategy: CacheFirst
- Cache name: "fonts"
- Expiration: 30 days, max 30 entries
Note: The app requires internet for data operations (PocketBase connection). Only static assets are cached offline.
Testing Your Deployment¶
Functionality Checklist¶
- [ ] Homepage loads correctly
- [ ] Sign up page works
- [ ] Email verification works
- [ ] Login page works
- [ ] OTP authentication works (if enabled)
- [ ] Password reset works
- [ ] Territory selector displays (for conductors/admins)
- [ ] Maps load and display correctly
- [ ] Can view territories
- [ ] Can update address status
- [ ] Assignment links work
- [ ] Links expire correctly
- [ ] Mobile view is responsive
- [ ] Language detection works
- [ ] All modals open and close properly
Performance Checks¶
- [ ] Initial page load under 3 seconds
- [ ] Lighthouse score > 90
- [ ] No console errors
- [ ] Images load quickly
- [ ] Maps are responsive
- [ ] Smooth scrolling and navigation
Security Checks¶
- [ ] HTTPS is enforced (no HTTP access)
- [ ] Privacy policy link works
- [ ] Terms of service link works
- [ ] API keys not exposed in browser code
- [ ] CORS configured correctly for backend
- [ ] PocketBase connection is secure
Browser Testing¶
Test on multiple browsers:
- [ ] Chrome/Chromium
- [ ] Firefox
- [ ] Safari (macOS/iOS)
- [ ] Edge
- [ ] Mobile browsers
Troubleshooting¶
Backend Connection Failed¶
Problem: "Cannot connect to server" or "Network Error"
Solutions:
- Verify
VITE_POCKETBASE_URLis correct (no trailing slash) - Check if PocketBase backend is running
- Test backend URL directly in browser
- Check CORS settings in PocketBase (must allow your frontend domain)
- Open browser DevTools → Network tab to see exact error
- Ensure backend is accessible from your deployment location
Build Errors¶
Problem: npm run build fails
Solutions:
- Ensure all environment variables are set correctly
- Run
npm installto refresh dependencies - Delete
node_modulesand reinstall:rm -rf node_modules && npm install - Check Node.js version:
node --version(needs 24+) - Check for TypeScript errors: Look at specific error messages
- Try
npm run prettier:fixto fix formatting issues - Clear Vite cache:
rm -rf node_modules/.vite
TypeScript Errors¶
Problem: Type errors during build
Solutions:
- Check
src/utils/interface.tsfor type definitions - Ensure imports are correct
- Run
npx tsc --noEmitto see all type errors - Verify all dependencies are installed
Slow Performance¶
Problem: App is slow or laggy
Solutions:
- Check internet connection speed
- Clear browser cache and reload
- Ensure PocketBase backend is responding quickly
- Check browser console for JavaScript errors
- Test on different device/browser to isolate issue
- Check Lighthouse performance score
- Verify service worker is working: DevTools → Application → Service Workers
PWA Installation Issues¶
Problem: "Add to Home Screen" doesn't appear
Solutions:
- Must be served over HTTPS
- Check service worker registration in DevTools
- Verify PWA requirements met (manifest, service worker, etc.)
- Try different browser (Safari, Chrome have different PWA support)
Real-time Updates Not Working¶
Problem: Changes don't appear for other users
Solutions:
- Verify PocketBase realtime subscriptions are working
- Check browser console for SSE (Server-Sent Events) errors
- Ensure backend SSE endpoint is accessible
- Check if multiple users are actually viewing the same territory
- Refresh the page to force reconnection
Maintenance¶
Keeping Dependencies Updated¶
# Pull latest changes from repository
git pull origin main
# Install updated dependencies
npm install
# Check for security vulnerabilities
npm audit
# Automatically fix security issues (when possible)
npm audit fix
# Check for outdated packages
npm outdated
# Update specific package
npm update package-name
Monitoring¶
Sentry Dashboard:
- Check weekly for new errors
- Review error trends
- Fix critical issues promptly
- Set up alerts for high-priority errors
Google Cloud Console:
- Monitor API usage to stay within quota
- Check for unusual spikes in usage
- Review billing alerts
- Ensure APIs remain enabled
Performance:
- Run Lighthouse audits periodically
- Monitor page load times
- Check Core Web Vitals
- Test on slow connections
User Feedback:
- Listen to congregation members
- Track common issues
- Document solutions
- Update documentation as needed
Version Updates¶
Ministry Mapper uses semantic versioning:
- Major version (x.0.0): Breaking changes
- Minor version (1.x.0): New features
- Patch version (1.9.x): Bug fixes
Next Steps¶
For Users:
- Read the User Guide to learn how to use the application
For Administrators:
- Set up the PocketBase backend (see ministry-mapper-be repository)
- Configure congregation settings
- Invite users and assign roles
- Create territories and add addresses