Ad Composer is a full-stack application for personalizing landing pages using AI. It uses Django with REST Framework for both the web interface and API, integrated with OpenAI and Temporal for workflow orchestration.
- Web & API: Django application with DRF API endpoints and OpenAI integration
- Database: PostgreSQL
- Workflow Engine: Temporal for asynchronous workflow orchestration
- Development/Production: Docker containerization
AD-COMPOSER/
├── assets/ # Asset files
├── db/ # Database files
│ └── init/ # Database initialization
├── web/ # Django web application
├── ad_composer/ # Main Django app
├── config/ # Django project configuration
├── myenv/ # Virtual environment
└── staticfiles/ # Static files
GET /api/account-names- Returns a list of available account names from the database
- Response: Array of account names
POST /api/personalize- Personalizes text content for a specific client using AI
- Request Body:
{ "client": "client_name", "texts": ["text1", "text2", ...] } - Response:
{ "client": "client_name", "originalTexts": ["text1", "text2", ...], "personalizedContent": ["personalized1", "personalized2", ...] }
GET /fetch-url/?url=https://example.com- Fetches a web page and returns its HTML content
- Response: HTML content of the requested page
- Docker and Docker Compose
- Python 3.9+ (for local development)
- PostgreSQL 16+ (for local development)
- Clone the repository:
git clone https://github.com/yourusername/ad-composer.git
cd ad-composer- Set up environment variables:
cp .env.example .env
# Edit .env with your configuration including OpenAI API key- Start the services:
docker-compose up --buildThe application will be available at:
- Web Application: http://localhost:8000
- Temporal UI: http://localhost:8080
- Test Temporal connection:
docker exec -it ad-composer-web-1 python test_temporal.py- Create and activate virtual environment:
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate- Install dependencies:
pip install -r requirements.txt- Run migrations:
python manage.py migrate- Start the development server:
python manage.py runserverThe database is automatically initialized with Docker. For local development:
- Create PostgreSQL database:
createdb addb- Run initialization scripts:
psql -d addb -f db/create-db.sql# Database Configuration
DB_USER=ad_user
DB_HOST=db
DB_DATABASE=addb
DB_PASSWORD=your_secure_password
DB_PORT=5432
# Django Configuration
SECRET_KEY=your_secure_django_secret
DEBUG=False
ALLOWED_HOSTS=localhost,127.0.0.1
# API Keys
OPENAI_API_KEY=your_openai_api_key
# Temporal Configuration
TEMPORAL_HOST=temporal:7233
This application uses Temporal as a workflow engine to orchestrate asynchronous ad generation processes. Temporal provides:
- Durable execution of workflows
- Automatic retries and error handling
- Scalable processing of multiple targets in parallel
- Visibility and monitoring through the Temporal UI
The Temporal UI is available at http://localhost:8080 when running with Docker. Use it to:
- Monitor workflow executions
- View workflow history and details
- Debug failed workflows
- Manually trigger workflows
To verify that Temporal is properly connected:
# When running with Docker
docker exec -it ad-composer-web-1 python test_temporal.py
# When running locally
python web/test_temporal.pyThe application is configured for deployment using Docker:
docker-compose up --buildThis project is licensed under the MIT License - see the LICENSE file for details.

