Skip to content

Emmanuel10701/django_redis_celerybeat_application

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cat > README.md << 'EOF'

🧠 AI Blog Generation Platform

A comprehensive and scalable AI-powered blog generation platform built with a modern web architecture. This project allows users to schedule and automatically generate blog posts using OpenAI's GPT model, combining the power of Django on the backend and Next.js on the frontend. Real-time updates, scheduled tasks, and an intuitive user interface make it a production-ready solution for automated content creation.

🚀 Tech Stack

🔧 Backend (Django)

  • Django: A high-level Python web framework used to build the core of the backend, handle routing, models, and authentication.
  • Django REST Framework (DRF): Simplifies the creation of RESTful APIs, enabling the frontend to interact with backend data seamlessly.
  • SimpleJWT: Implements secure user authentication and authorization using JSON Web Tokens.
  • Celery: Handles background tasks asynchronously, especially for scheduling AI-generated blogs.
  • Celery Beat: Adds periodic task scheduling capabilities, used to check and generate blogs at scheduled times.
  • Redis: Acts as the message broker for Celery and can be used for caching and speeding up performance.
  • Django Channels: Enables asynchronous support in Django, powering WebSockets for real-time blog updates.
  • django-celery-beat: Integrated with the Django admin panel for managing periodic tasks via the UI.
  • OpenAI Python SDK: Connects to the GPT model for AI-generated blog content.

🌐 Frontend (Next.js)

  • Next.js: Combines server-side rendering with the power of React to create a fast, SEO-friendly UI.
  • React: Component-based JavaScript library for building responsive and interactive UIs.
  • Axios: Used to make HTTP requests from the frontend to the backend APIs.
  • Material UI (MUI): Delivers pre-built, accessible components that follow Google's Material Design.
  • Tailwind CSS (optional): Can be used for utility-first styling and rapid UI development.
  • next/navigation: Enables dynamic routing and client-side transitions in Next.js.

⚙️ Infrastructure & Workflow

  • Celery Worker: Continuously runs in the background, listening for tasks such as blog generation and executing them outside the request-response cycle.
  • Redis Server: Acts as a fast, in-memory broker that queues tasks for Celery.
  • Docker (optional): For containerizing and deploying the app seamlessly across environments.
  • PostgreSQL/MySQL: Backend SQL database used for storing user data, blog metadata, and scheduling info.

💡 Key Features

🔐 Authentication & Authorization

  • Register and log in users securely using JWT tokens.
  • Protect sensitive endpoints and WebSocket connections using JWT.

✍️ AI-Powered Blog Creation

  • Generate long-form blog articles using OpenAI's GPT API.
  • Users can select a category and length, or write a custom prompt.
  • AI-generated blogs are automatically saved and associated with the user.

⏰ Blog Scheduling

  • Schedule blog posts for future generation using Celery Beat.
  • Automatically triggers blog creation at the specified time.
  • Scheduled tasks are managed in the admin dashboard or via API.

📡 Real-Time Notifications (WebSocket)

  • Get notified in real-time when your blog is generated.
  • Uses Django Channels and WebSocket endpoints to broadcast messages.

📊 Admin Dashboard

  • Built-in Django Admin to manage users, scheduled stories, and AI logs.
  • Control and monitor task executions using django-celery-beat UI.

🛠 Extensible API

  • RESTful API endpoints for:
    • User registration and login
    • Scheduling blog posts
    • Fetching user-generated blogs
    • WebSocket authentication
  • Can be extended to integrate with other AI providers or data sources.

🏗 Architecture Overview

```plaintext Client (Next.js/React) | |-- Axios Requests v Backend (Django + DRF) | |-- Auth (SimpleJWT) |-- API for scheduling/blog management |-- OpenAI API integration | |-- Celery (async tasks) | | | --> Redis (task broker) | --> OpenAI for blog generation | |-- Channels (WebSockets) | --> Real-time notifications | Database (PostgreSQL/MySQL) | --> Stores users, blog posts, schedules ```

🧪 Testing

  • Manual API testing can be done using:
    • REST Client (VSCode extension)
    • Postman
    • Thunder Client
  • WebSocket endpoints can be tested using:
    • Postman WebSocket feature
    • `wscat` command-line tool

📦 Installation (Dev)

```bash

Clone the repository

git clone https://github.com/your-username/ai-blog-platform.git cd ai-blog-platform

Backend setup

cd backend python -m venv venv source venv/bin/activate pip install -r requirements.txt python manage.py migrate python manage.py runserver

Start Redis server (make sure Redis is installed)

redis-server

Start Celery worker and beat

celery -A config worker --loglevel=info celery -A config beat --loglevel=info

Frontend setup

cd ../frontend npm install npm run dev ```

🧑‍💻 Contributing

  1. Fork the repo.
  2. Create your feature branch: `git checkout -b feature/blog-scheduler`.
  3. Commit your changes: `git commit -am 'Add new blog scheduling feature'`.
  4. Push to the branch: `git push origin feature/blog-scheduler`.
  5. Open a pull request 🚀

🛡 License

This project is licensed under the MIT License. See `LICENSE` for more information.

🙋‍♂️ About the Author

Emmanuel Makau
Backend Developer Intern & Full-stack Enthusiast
📧 [email protected]
🔗 GitHubreplace with your GitHub profile EOF

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published