Overview
CEMAC is optimized for deployment on Vercel, a cloud platform for static sites and serverless functions. This guide covers deploying both the frontend application and understanding the backend API architecture.Architecture
CEMAC uses a split architecture:- Frontend: Static files (HTML, CSS, JS) served from the
/publicdirectory - Backend API: Deployed separately at
https://cemac-api.vercel.app - Proxy Server: Express server that routes requests and serves static files
Prerequisites
- GitHub account
- Vercel account (free tier available)
- Firebase project configured (see Firebase Setup)
- Git installed locally
Deploying to Vercel
Import project to Vercel
- Go to Vercel Dashboard
- Click Add New > Project
- Import your GitHub repository
- Select the repository from the list
Configure build settings
Vercel will detect the project type. Verify these settings:
- Framework Preset: Other
- Build Command:
echo 'No build needed' - Output Directory:
public - Install Command:
npm install
vercel.json configuration in your project.Add environment variables
In the Vercel project settings, add your environment variables:Navigate to Settings > Environment Variables and add:Select which environments (Production, Preview, Development) should use each variable.
Deploy
Click Deploy. Vercel will:
- Clone your repository
- Install dependencies (
npm install) - Run the build command
- Deploy the output directory
https://your-project.vercel.appVercel Configuration
CEMAC includes avercel.json file that configures deployment settings:
Security Headers
The configuration includes security headers:- X-Content-Type-Options: Prevents MIME type sniffing
- X-Frame-Options: Prevents clickjacking attacks
- X-XSS-Protection: Enables browser XSS filtering
Backend API
The CEMAC backend API is deployed separately and handles:- Authentication with Firebase
- Database operations with Firestore
- Business logic and data validation
The backend API is pre-deployed at
https://cemac-api.vercel.app. You don’t need to deploy it separately unless you’re customizing the backend.API Endpoints
The backend provides these endpoints:POST /auth/login- User authenticationPOST /auth/logout- User logoutGET /auth/verify- Verify authentication tokenPOST /auth/recover- Password recovery
Environment-Specific Behavior
CEMAC automatically detects the environment and adjusts API endpoints:Development (localhost)
Production (Vercel)
/public/js/services/authService.js:14-34
Custom Domains
To use a custom domain with Vercel:Add domain in Vercel
- Go to your project Settings > Domains
- Enter your custom domain (e.g.,
app.cemac.com) - Click Add
Configure DNS
Add the DNS records provided by Vercel to your domain registrar:For apex domain (cemac.com):For subdomain (app.cemac.com):
Continuous Deployment
Vercel automatically deploys when you push to your repository:- Production: Deploys from
mainormasterbranch - Preview: Deploys from all other branches and pull requests
Server Configuration
The Express server configuration inserver/server.js:69-80 includes:
- Uses
PORTfrom environment variables (defaults to 3000) - Serves static files from
/public - Proxies auth requests to external API
- Provides logging for all requests
Monitoring and Logs
Vercel Dashboard
Monitor your deployment:- Deployments: View deployment history and status
- Analytics: Track page views and performance (requires Pro plan)
- Logs: Real-time and historical logs
Accessing Logs
View runtime logs:Rollback
To rollback to a previous deployment:Performance Optimization
Caching
Static assets are automatically cached by Vercel’s CDN.Compression
Vercel automatically compresses responses with gzip/brotli.Geographic Distribution
Content is served from edge nodes closest to your users.Troubleshooting
Build fails
- Check build logs in Vercel dashboard
- Verify
package.jsondependencies - Ensure Node.js version compatibility
Environment variables not working
- Verify variables are set in correct environment (Production/Preview/Development)
- Redeploy after adding new variables
- Check for typos in variable names
Authentication fails in production
- Verify Firebase authorized domains include your Vercel domain
- Check that environment variables match Firebase console
- Review browser console for CORS errors
API connection errors
- Verify external API (
https://cemac-api.vercel.app) is accessible - Check network tab in browser DevTools
- Review CORS configuration
Security Best Practices
Alternative Deployment Options
While Vercel is recommended, you can deploy CEMAC to:- Heroku: Use the Procfile and set buildpack to Node.js
- DigitalOcean: Deploy as a Node.js application
- AWS EC2: Run the Express server on an EC2 instance
- Docker: Containerize the application
- Node.js runtime is available
- Environment variables are configured
- Port is configurable via
PORTenv var - Static files in
/publicare served correctly
Next Steps
- Configure Environment Variables
- Set up Firebase
- Review API Documentation
- Monitor your deployment in Vercel dashboard