Skip to content

Latest commit

 

History

History
229 lines (213 loc) · 9.13 KB

File metadata and controls

229 lines (213 loc) · 9.13 KB

Content Automation System

A powerful Flask-based backend service that automates the creation and distribution of digital content. This system leverages OpenAI's GPT models to generate blog posts and social media content based on specific criteria, then seamlessly publishes it to platforms like Instagram, Meta, and X at scheduled times.

Features

  • AI-Powered Content Generation: Utilizes ChatGPT and other LLMs to create high-quality blog posts and social media content.
  • Multi-Platform Publishing: Automatically publishes generated content to Instagram, Meta (Facebook), and X (Twitter).
  • Intelligent Scheduling: Full control over publication timing with a built-in scheduling system.
  • Cloud-Native Design: Built for scalability and deployed on Google Cloud Functions.
  • Robust Data Management: Uses Firestore for structured data storage and Google Cloud Storage for media assets.
  • Modular Architecture: Clean, maintainable codebase organized by feature for easy development and testing.

Technology Stack

  • Backend Framework: Flask (Python)
  • AI & LLM: OpenAI API (ChatGPT, Assistants, Threads, Messages)
  • Database: Firebase Firestore
  • File Storage: Google Cloud Storage
  • Deployment: Google Cloud Functions, Google Cloud Scheduler
  • Authentication: Firebase Auth

Navigate to

http://127.0.0.1:5000

Style guide for Python code

https://peps.python.org/pep-0008/

Project structure

project-root/
│
├── app/
│   ├── __init__.py
│   ├── core/
│   │   ├── __init__.py
│   │   ├── assets/
│   │   │   ├── fonts
│   │   │   └── images
│   │   │       ├── blog_post
│   │   │       └── logo.png
│   │   ├── auth/
│   │   │   ├── __init__.py
│   │   │   ├── auth_service.py          # Business logic and services of the code
│   │   │   └── auth_route.py Defines    # Defines routes for APIs
│   │   │   ├── auth_model.py            # Define data models (database)
│   │   │   └── auth_schema.py           # Define schema for the data (request body data)
│   │   │   ├── tests/
│   │   │   │   ├── test_auth_service.py
│   │   │   │   ├── test_auth_route.py
│   │   │   │   ├── test_auth_model.py
│   │   ├── data/
│   │   │   └── dataset.csv
│   │   ├── shared/
│   │   │   └── shared_route.py
│   │   │   └── shared_service.py
│   │   ├── utils/
│   │   │   └── error_messages.py
│   │   │   └── helpers.py
│   │   ├── validators/
│   │   │   └── link_validators.py
│   │   │   └── string_validators.py
│   ├── modules/
│   │   └── openai/
│   │   │   ├── chatgpt/
│   │   │   │   ├── service/
│   │   │   │   │   └── chatgpt_service.py
│   │   │   │   ├── schema/
│   │   │   │   │   ├── chatgpt_schema.py
│   │   │   │   │   └── plog_post_schema.py
│   │   │   │   └── route/
│   │   │   │       └── chatgpt_route.py
│   │   │   ├── assistant/
│   │   │   │   ├── service/
│   │   │   │   │   └── assistant_service.py
│   │   │   │   ├── schema/
│   │   │   │   │   └── assistant_schema.py
│   │   │   │   └── route/
│   │   │   │       └── assistant_route.py
│   │   │   ├── thread/
│   │   │   │   ├── service/
│   │   │   │   │   └── thread_service.py
│   │   │   │   ├── schema/
│   │   │   │   │   └── thread_schema.py
│   │   │   │   └── route/
│   │   │   │       └── thread_route.py
│   │   │   ├── run/
│   │   │   │   ├── service/
│   │   │   │   │   └── run_service.py
│   │   │   │   ├── schema/
│   │   │   │   │   └── run_schema.py
│   │   │   │   └── route/
│   │   │   │       └── run_route.py
│   │   │   └── message/
│   │   │       ├── service/
│   │   │       │   └── message_service.py
│   │   │       ├── schema/
│   │   │       │   └── message_schema.py
│   │   │       └── route/
│   │   │           └── message_route.py
│   │   │   └── image/
│   │   │       ├── service/
│   │   │       │   └── image_service.py
│   │   │       ├── schema/
│   │   │       │   └── image_schema.py
│   │   │       └── route/
│   │   │           └── image_route.py
│   │   ├── blog_post/
│   │   │   ├── service/
│   │   │   │   └── blog_post_service.py
│   │   │   ├── schema/
│   │   │   │   └── blog_post_schema.py
│   │   │   └── route/
│   │   │       └── blog_post_route.py
│   │   │   └── model/
│   │   │       └── blog_post_model.py
│   │   ├── google_services/
│   │   │   ├── firebase/
│   │   │   │   ├── service_accounts
│   │   │   │   │   └── ai.json
│   │   │   │   ├── firebase_auth.py
│   │   │   │   └── firebase_messaging.py
│   │   │   ├── firestore/
│   │   │   │   ├── service
│   │   │   │   │   └── firestore_service.py
│   │   │   │   ├── schema
│   │   │   │   │   └── firestore_schema.py
│   │   │   │   ├── route
│   │   │   │   │   └── firestore_route.py
│   │   │   │   ├── model
│   │   │   │   │   └── firestore_model.py
│   │   │   ├── storage/
│   │   │   │   ├── service
│   │   │   │   │   └── storage_service.py
│   │   │   │   ├── schema
│   │   │   │   │   └── storage_schema.py
│   │   │   │   ├── route
│   │   │   │   │   └── storage_route.py
│   │   │   │   ├── model
│   │   │   │   │   └── storage_model.py
│   │   ├── social_media/
│   │   │   ├── instagram/
│   │   │   │   ├── service
│   │   │   │   │   └── instagram_service.py
│   │   │   │   ├── schema
│   │   │   │   │   └── instagram_schema.py
│   │   │   │   ├── route
│   │   │   │   │   └── instagram_route.py
│   │   │   │   ├── model
│   │   │   │   │   └── instagram_model.py
│   │   │   ├── meta/
│   │   │   │   ├── service
│   │   │   │   │   └── meta_service.py
│   │   │   │   ├── schema
│   │   │   │   │   └── meta_schema.py
│   │   │   │   ├── route
│   │   │   │   │   └── meta_route.py
│   │   │   │   ├── model
│   │   │   │   │   └── meta_model.py
│   │   │   ├── x/
│   │   │   │   ├── service
│   │   │   │   │   └── x_service.py
│   │   │   │   ├── schema1w
│   │   │   │   │   └── x_schema.py
│   │   │   │   ├── route
│   │   │   │   │   └── x_route.py
│   │   │   │   ├── model
│   │   │   │   │   └── x_model.py
│   │   │   ├── storage/
│   │   │   │   ├── service
│   │   │   │   │   └── storage_service.py
│   │   │   │   ├── schema
│   │   │   │   │   └── storage_schema.py
│   │   │   │   ├── route
│   │   │   │   │   └── storage_route.py
│   │   │   │   ├── model
│   │   │   │   │   └── storage_model.py
│   └── venv/  (virtual environment)│
├── config.py
├── main.py
├── app.yaml
├── .gcloudignore
├── .gitignore
├── requirements.txt
├── .env
└── README.md

Installation

  1. Install Python 3.11.7:

  2. Clone the repository:

    git clone <repository-url>
    cd <project-directory>
  3. Create and activate a virtual environment (recommended):

    python -m venv venv
    # On Windows:
    .\venv\Scripts\activate
    # On Unix or MacOS:
    source venv/bin/activate
  4. Install dependencies:

    pip install -r requirements.txt
  5. Set up environment variables: Create a .env file based on the provided example and add your API keys:

    • OpenAI API Key
    • Google Service Account JSON credentials
    • Social Media Platform API tokens

Running the Application Locally

Run the development server:

flask run