A production-ready SaaS application for managing and optimizing global advertising campaigns across Google Ads, Microsoft Ads, and YouTube Ads platforms.
- Multi-Platform Support: Google Ads, Microsoft Ads, YouTube Ads
- Campaign Management: Create, launch, pause, and optimize campaigns
- Advanced Analytics: Real-time reporting with ROAS tracking
- Auto Optimization: Intelligent rules for campaign optimization
- B2B Audience Wizard: Custom audience targeting
- Stripe Integration: Subscription billing and feature gating
- Enterprise Security: OAuth integration and role-based access
- cPanel Ready: Optimized for shared hosting deployment
- Next.js 14 with App Router
- TailwindCSS for styling
- shadcn/ui component library
- Static Export ready for cPanel hosting
- TypeScript for type safety
- Express.js with TypeScript
- Prisma ORM with PostgreSQL
- Redis for caching and job queues
- JWT authentication
- Modular architecture for scalability
- PostgreSQL for primary data storage
- Redis for caching and background jobs
- Prisma for type-safe database operations
- Node.js 18+
- PostgreSQL 13+
- Redis 6+
- Docker & Docker Compose (optional)
# Clone the repository
git clone <repository-url>
cd global-ads-launch-optimization
# Install root dependencies
npm install
# Install frontend dependencies
cd frontend
npm install
# Install backend dependencies
cd ../backend
npm install# Copy environment template
cp env.example .env
# Edit .env with your configuration
nano .envRequired Environment Variables:
# Database
DATABASE_URL=postgresql://postgres:password@localhost:5432/global_ads_db
REDIS_URL=redis://localhost:6379
# JWT Secrets (generate secure keys for production)
JWT_SECRET=your-super-secret-jwt-key-here
JWT_REFRESH_SECRET=your-super-secret-refresh-key-here
# API URLs
FRONTEND_URL=http://localhost:3000
API_URL=http://localhost:5000/api# Start PostgreSQL and Redis (using Docker)
docker-compose up -d postgres redis
# Or start them manually
# PostgreSQL: Start your PostgreSQL service
# Redis: Start your Redis service
# Run database migrations
cd backend
npm run db:migrate
# Generate Prisma client
npm run db:generate
# Seed database (optional)
npm run db:seed# Start both frontend and backend (from root directory)
npm run dev
# Or start them separately:
# Terminal 1 - Backend
cd backend
npm run dev
# Terminal 2 - Frontend
cd frontend
npm run dev- Frontend: http://localhost:3000
- Backend API: http://localhost:5000/api
- API Documentation: http://localhost:5000/api
- Health Check: http://localhost:5000/health
# Start all services
docker-compose up -d
# View logs
docker-compose logs -f
# Stop all services
docker-compose down
# Rebuild and start
docker-compose up --build -d- Frontend: http://localhost:3000
- Backend: http://localhost:5000
- PostgreSQL: localhost:5432
- Redis: localhost:6379
- pgAdmin: http://localhost:5050 (development profile)
- Redis Commander: http://localhost:8081 (development profile)
- cPanel hosting with Node.js support
- PostgreSQL database (shared or dedicated)
- Redis (if available, or use alternative caching)
- SSL certificate for HTTPS
- Build the frontend for static export:
cd frontend
npm run build
npm run export-
Upload to cPanel:
- Upload the
out/folder contents to your domain'spublic_html/directory - Ensure
index.htmlis in the root ofpublic_html/
- Upload the
-
Configure .htaccess (if needed):
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.html [L]- Build the backend:
cd backend
npm run build- Create backend directory structure in cPanel:
public_html/
├── api/ # Backend API
│ ├── dist/ # Compiled JavaScript
│ ├── node_modules/ # Dependencies
│ ├── package.json # Backend package.json
│ └── server.js # Entry point
└── index.html # Frontend
- Upload backend files:
- Upload
dist/folder contents topublic_html/api/dist/ - Upload
package.jsontopublic_html/api/ - Create
server.jsinpublic_html/api/:
- Upload
// public_html/api/server.js
require('dotenv').config();
const app = require('./dist/server.js');
const port = process.env.PORT || 5000;
app.listen(port, () => {
console.log(`Server running on port ${port}`);
});- Install backend dependencies:
cd public_html/api
npm install --production-
Configure environment variables:
- Create
.envfile inpublic_html/api/ - Set production database and API URLs
- Create
-
Set up Node.js application in cPanel:
- Go to "Node.js" in cPanel
- Create new application
- Set application root to
public_html/api - Set application URL to
https://yourdomain.com/api - Set startup file to
server.js - Start the application
- Create PostgreSQL database in cPanel
- Run migrations:
cd public_html/api
npx prisma migrate deploy
npx prisma generate- Enable SSL for your domain
- Update CORS settings in backend to include your production domain
- Update environment variables with production URLs
npm run dev # Start both frontend and backend
npm run build # Build both frontend and backend
npm run start # Start both in production mode
npm run docker:up # Start all services with Docker
npm run docker:down # Stop all Docker servicesnpm run dev # Start development server
npm run build # Build for production
npm run start # Start production server
npm run export # Export static files for cPanel
npm run lint # Run ESLint
npm run type-check # Run TypeScript type checkingnpm run dev # Start development server with nodemon
npm run build # Build TypeScript to JavaScript
npm run start # Start production server
npm run db:migrate # Run database migrations
npm run db:generate # Generate Prisma client
npm run db:seed # Seed database with sample data
npm run db:reset # Reset database (WARNING: deletes all data)
npm run db:studio # Open Prisma Studio
npm run test # Run tests
npm run lint # Run ESLintPOST /api/auth/register- Register new userPOST /api/auth/login- Login userPOST /api/auth/logout- Logout userPOST /api/auth/refresh- Refresh access tokenPOST /api/auth/forgot-password- Send password reset emailPOST /api/auth/reset-password- Reset password
GET /api/users/profile- Get user profilePUT /api/users/profile- Update user profilePUT /api/users/change-password- Change passwordGET /api/users/stats- Get user statisticsPUT /api/users/subscription- Update subscriptionDELETE /api/users/account- Delete account
POST /api/campaigns- Create campaignGET /api/campaigns- Get all campaignsGET /api/campaigns/:id- Get campaign by IDPUT /api/campaigns/:id- Update campaignDELETE /api/campaigns/:id- Delete campaignPOST /api/campaigns/:id/launch- Launch campaignPOST /api/campaigns/:id/pause- Pause campaignPOST /api/campaigns/:id/resume- Resume campaignGET /api/campaigns/:id/performance- Get campaign performance
GET /api/analytics/dashboard- Get dashboard statsGET /api/analytics/campaigns- Get campaign analyticsGET /api/analytics/platforms- Get platform analyticsGET /api/analytics/conversions- Get conversion analyticsGET /api/analytics/keywords- Get keyword performanceGET /api/analytics/audience- Get audience insightsGET /api/analytics/export- Export analytics data
POST /api/webhooks/stripe- Stripe webhooksPOST /api/webhooks/google-ads- Google Ads webhooksPOST /api/webhooks/microsoft-ads- Microsoft Ads webhooksPOST /api/webhooks/youtube- YouTube webhooks
- JWT Authentication with refresh tokens
- Password hashing with bcrypt
- Rate limiting on API endpoints
- CORS protection with configurable origins
- Helmet.js for security headers
- Input validation with express-validator
- SQL injection protection with Prisma ORM
- XSS protection with proper sanitization
# Run all tests
npm run test
# Run tests in watch mode
npm run test:watch
# Run specific test file
npm test -- campaigns.test.tsSee env.example for complete list of environment variables.
DATABASE_URL- PostgreSQL connection stringREDIS_URL- Redis connection stringJWT_SECRET- JWT signing secretJWT_REFRESH_SECRET- JWT refresh token secret
STRIPE_SECRET_KEY- Stripe API secret keyGOOGLE_ADS_CLIENT_ID- Google Ads API client IDGOOGLE_ADS_CLIENT_SECRET- Google Ads API client secretMICROSOFT_ADS_CLIENT_ID- Microsoft Ads API client IDMICROSOFT_ADS_CLIENT_SECRET- Microsoft Ads API client secret
-
Database Connection Error
- Check PostgreSQL is running
- Verify DATABASE_URL is correct
- Ensure database exists
-
Redis Connection Error
- Check Redis is running
- Verify REDIS_URL is correct
-
Build Errors
- Clear node_modules and reinstall
- Check Node.js version (18+)
- Verify TypeScript configuration
-
cPanel Deployment Issues
- Check Node.js version in cPanel
- Verify file permissions
- Check application logs in cPanel
- Backend logs: Check
logs/directory - Docker logs:
docker-compose logs -f [service-name] - cPanel logs: Check application logs in cPanel Node.js section
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new functionality
- Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
For support and questions:
- Create an issue in the repository
- Check the documentation
- Review the troubleshooting section