AI Blog Generator is a Django-based web application that allows users to generate, edit, and manage blogs using AI assistance. The app provides a smooth and modern user experience with Tailwind CSS styling, a TinyMCE rich text editor, and Django’s built-in authentication and message frameworks.
-
USER AUTHENTICATION
- Secure login and signup pages
- CSRF protection enabled across all forms
- Password reset and email verification support (via Mailtrap)
-
BLOG MANAGEMENT
- Create, view, edit, and delete blogs
- Rich text editing with TinyMCE integration
- Auto-sanitized HTML content using Django’s safe filter
- Pagination and sorting on “My Blogs” page
-
AI INTEGRATION
- Blog content generation using AI APIs (configured in utils.py)
- Ability to modify or regenerate content before saving
-
UI/UX DESIGN
- Responsive and modern layout built with Tailwind CSS
- Global message component (success, error, warning, info)
- Auto-fading toast messages for smooth user feedback
- Modular templates (base.html + partials for navbar, footer, messages)
-
SECURITY
- CSRF tokens included in all forms
- User-specific blog access control
- Secure session handling and proper redirect logic
- BACKEND: Django (Python)
- FRONTEND: HTML, Tailwind CSS, Alpine.js
- RICH TEXT EDITOR: TinyMCE
- DATABASE: PostgreSQL
- EMAIL SERVICE: Mailtrap (for testing)
- DEPLOYMENT: Docker, Render, Vercel, or traditional VPS setups
Before running the project, ensure you have the following installed:
- Docker Engine: https://docs.docker.com/get-docker/
- Docker Compose: https://docs.docker.com/compose/install/
- Git: https://git-scm.com/
- (Optional) Python 3.10+ and virtual environment if running locally
AI_BLOG_APP/ │ ├── ai_blog_app/ # Main project folder (Django settings) ├── blog_generator/ # Main app │ ├── migrations/ │ ├── templates/ │ ├── utils/ │ ├── static/ │ ├── media/ │ ├── likes/ │ ├── admin.py │ ├── apps.py │ ├── models.py │ ├── urls.py │ ├── views.py │ ├── signals.py │ ├── tests.py ├── .env # Environment variables ├── Dockerfile # Docker setup ├── docker-compose.yml # Docker Compose configuration ├── requirements.txt ├── manage.py ├── venv/ # Local virtual environment (ignored) └── README.md
The Docker setup includes two services: web (Django) and db (PostgreSQL).
Example docker-compose.yml:
version: "3.9"
services:
db:
image: postgres:15-alpine
container_name: ai_blog_db
environment:
POSTGRES_DB: ai_blog_db
POSTGRES_USER: avnadmin
POSTGRES_PASSWORD: your_password
ports:
- "5432:5432"
volumes:
- postgres_data:/var/lib/postgresql/data
networks:
- ai_blog_network
web:
build: .
container_name: ai_blog_web
command: >
sh -c "python manage.py migrate &&
python manage.py runserver 0.0.0.0:8000"
volumes:
- .:/app
ports:
- "8000:8000"
environment:
- GEMINI_API_KEY=your_gemini_api_key
- ASSEMBLYAI_API_KEY=your_assemblyai_api_key
- POSTGRES_DB=ai_blog_db
- POSTGRES_USER=avnadmin
- POSTGRES_PASSWORD=your_password
- POSTGRES_HOST=db
- POSTGRES_PORT=5432
depends_on:
- db
networks:
- ai_blog_network
volumes:
postgres_data:
networks:
ai_blog_network:Example Dockerfile:
# Use Python base image
FROM python:3.10-slim
# Set working directory
WORKDIR /app
# Copy requirements and install dependencies
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# Copy the rest of the project
COPY . .
# Prevent Python from buffering output
ENV PYTHONUNBUFFERED=1
# Expose port
EXPOSE 8000-
Clone the repository:
git clone https://github.com/Macowen14/ai_blog_generator.git cd ai_blog_generator -
Create a
.envfile in the project root with your API keys and database credentials:GEMINI_API_KEY=your_gemini_api_key ASSEMBLYAI_API_KEY=your_assemblyai_api_key POSTGRES_DB=ai_blog_db POSTGRES_USER=avnadmin POSTGRES_PASSWORD=your_password -
Build and start containers:
docker compose up --build
-
Apply Django migrations (inside the web container):
docker compose exec web python manage.py migrate -
(Optional) Create a superuser:
docker compose exec web python manage.py createsuperuser -
Open your browser and visit:
http://localhost:8000/ -
To stop the containers:
docker compose down
If running without Docker:
-
Create a virtual environment:
python3 -m venv venv source venv/bin/activate # Linux/macOS venv\Scripts\activate # Windows
-
Install dependencies:
pip install -r requirements.txt
-
Configure
.envandsettings.pywith PostgreSQL credentials -
Apply migrations:
python manage.py migrate
-
Run the development server:
python manage.py runserver
-
Visit
http://127.0.0.1:8000/in your browser
-
All templates extend
base.html -
Do NOT push
.vscode/orvenv/folders to GitHub -
Ensure
.gitignoreincludes:venv/ .vscode/ *.pyc .env
- CSRF tokens must be present in all POST forms to avoid “CSRF token missing” errors
- TinyMCE requires a stable internet connection to load via CDN
- PostgreSQL must be running locally or via Docker for migrations and queries to work
- For testing emails, resend is recommended
-
Fork the repository
-
Create a new branch:
git checkout -b feature-name
-
Commit your changes:
git commit -m "Add new feature" -
Push to the branch:
git push origin feature-name
-
Create a pull request
This project is open source and available under the MIT License.
Developed by: Macowen Keru Email: macowenkeru@gmail.com
- Django Team (for the web framework)
- TinyMCE (for rich text editing)
- TailwindCSS (for styling)
- Gemini API (for AI blog generation)
- AssemblyAI (for transcription)