Skip to content

Taha2053/Linkedin-automation

Repository files navigation

LinkedIn Automation Engine

A powerful automation system that transforms topics into professional LinkedIn posts with AI-generated visuals, and publishes them automatically. Manage topics directly in the web interface - no external tools needed!

🎯 Core Purpose

Remove the "manual" from content creation. This app manages topics directly in the web interface, generates high-quality LinkedIn posts with AI, creates professional images, and publishes them automatically to your LinkedIn feed. If no topics are available, it automatically generates random tech-related topics.


🛠️ Installation & Setup Guide

We have made running this project as easy as possible with automated startup scripts for both Windows and Linux.

1. Prerequisites

Before you start, ensure you have the following installed:

Note for Windows Users: Make sure to check "Add Python to PATH" during installation.

2. Quick Start (Recommended)

Linux / macOS:

# 1. Clone the repository
git clone https://github.com/YOUR_USERNAME/Linkedin-automation.git
cd Linkedin-automation

# 2. Make the script executable
chmod +x start.sh

# 3. Run the automated setup & start script
./start.sh

Windows:

  1. Clone or download the repository.
  2. Double-click start.bat.
  3. The script will automatically:
    • Check for Python and Node.js
    • Create a virtual environment
    • Install all dependencies
    • Start the Backend and Frontend servers

3. Manual Installation (Alternative)

If you prefer to set everything up manually:

Backend Setup:

cd backend
python -m venv venv           # Create virtual environment
source venv/bin/activate      # Linux/Mac
# venv\Scripts\activate       # Windows

pip install -e .              # Install dependencies (run in root directory)

Frontend Setup:

cd frontend
npm install                   # Install dependencies

Database (PostgreSQL): Ensure PostgreSQL is running and you have a database created (default is linkedin_bot).

🐘 How to Create the Database Manually

If the automated script cannot create the database (usually due to permissions), follow these steps:

For Linux / macOS:

  1. Switch to the postgres user:

    sudo -i -u postgres
  2. Access the PostgreSQL shell:

    psql
  3. Run the following SQL commands:

    -- Create the database
    CREATE DATABASE linkedin_bot;
    
    -- Create a user with a password
    CREATE USER bot_user WITH PASSWORD 'your_password';
    
    -- Grant privileges
    GRANT ALL PRIVILEGES ON DATABASE linkedin_bot TO bot_user;
    
    -- (Optional) If using PostgreSQL 15+
    \c linkedin_bot
    GRANT ALL ON SCHEMA public TO bot_user;
  4. Exit: Type \q to exit psql, then exit to logout of the postgres user.

For Windows:

  1. Open the "SQL Shell (psql)" application from your Start Menu.
  2. Press Enter through the defaults (Server, Database, Port, Username) until it asks for your password.
  3. Enter the password you set during installation.
  4. Run the same SQL commands as above:
    CREATE DATABASE linkedin_bot;
    CREATE USER bot_user WITH PASSWORD 'your_password';
    GRANT ALL PRIVILEGES ON DATABASE linkedin_bot TO bot_user;
  5. Note: By default, Windows PostgreSQL usually installs with the user postgres and the password you selected. You can use that directly in your .env file if you prefer not to create a new user:
    DATABASE_URL=postgresql://postgres:YOUR_INSTALL_PASSWORD@localhost/linkedin_bot

⚙️ Configuration

The project uses a .env file for configuration. The startup scripts will create a default one for you from .env.example.

Required API Keys

Once the app is running, go to the Settings Tab in the dashboard (http://localhost:5173) to configure:

  1. Google Gemini API Key: Get Key (For text generation)
  2. Flux.1 (Fal.ai) API Key: Get Key (For image generation)
  3. LinkedIn OAuth: Create App
    • Redirect URL: http://localhost:8000/api/linkedin/callback
    • Permissions: w_member_social, openid, profile

Database Configuration (Optional)

If you want to use a custom database user/password, edit the .env file:

DATABASE_URL=postgresql://your_user:your_password@localhost/your_db_name

🏗️ Architecture

Component Role Description
The Library (Web App) Input Source Built-in topic management system. Add topics directly in the dashboard.
The Brain (FastAPI) Orchestrator Python backend that manages the schedule, connects APIs, and processes data logic.
The Writer (Gemini) Content Engine Google's AI that reads your topic and crafts a LinkedIn post.
The Artist (Flux.1) Visual Engine High-speed image generator that takes a visual prompt from Gemini.
The PR Officer (LinkedIn) Publisher Final stage where text and image are combined and posted to your live feed.
The Archive (PostgreSQL) Persistent Memory Local database storing topics, API keys, OAuth tokens, and history.

🎮 Using the Dashboard

  1. Topics Tab: Add ideas for posts. The bot picks "Not Done" topics automatically.
  2. Settings Tab: Configure your API keys and connect your LinkedIn account.
  3. Schedule Tab: Set how often the bot should post (e.g., every 4 hours).
  4. Live Feed: View the history of generated and published posts.

🔄 Workflow

Every time the scheduler runs:

  1. Query Database: Finds next topic. If empty, generates a random tech topic.
  2. Generate Content: Gemini creates post text & image prompt.
  3. Generate Image: Flux.1 creates the visual.
  4. Post: Uploads to LinkedIn via API.
  5. Save: Records result in database.

🔒 Security

  • API keys are encrypted before storage.
  • .encryption_key protects your secrets (do not commit this file!).
  • OAuth tokens are managed securely.

🐛 Troubleshooting

  • PostgreSQL Error: Ensure the service is running (sudo service postgresql start or checking Services in Windows).
  • LinkedIn Auth Error: Verify you added http://localhost:8000/api/linkedin/callback to your LinkedIn App Redirect URIs.
  • Dependencies: If start.sh fails, try running the manual installation steps.

📁 Project Structure

Linkedin-automation/
├── backend/          # FastAPI app
├── frontend/         # React + Vite app
├── start.sh          # Linux/Mac startup script
├── start.bat         # Windows startup script
└── pyproject.toml    # Python dependencies

📄 License

This project is for personal use. Ensure compliance with LinkedIn's Terms of Service.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors