Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
83 commits
Select commit Hold shift + click to select a range
9675347
Correct punctuation in README description
tanvishinde017 May 1, 2026
e580b81
Initial commit - PinFlow AI SaaS
tanvishinde017 May 4, 2026
6029782
Clean repo - removed venv
tanvishinde017 May 4, 2026
455f80b
Resolved merge conflicts
tanvishinde017 May 4, 2026
79dd900
Resolved merge conflicts
tanvishinde017 May 4, 2026
81e69ba
python version added
tanvishinde017 May 5, 2026
2f88f73
Celery Worker Entry Point
tanvishinde017 May 5, 2026
e811b07
Upgrade base layout with global loader and clean structure
tanvishinde017 May 5, 2026
366c88f
� Improved login UI with password toggle and cleaner UX
tanvishinde017 May 5, 2026
2adc20e
� Signup page with password strength indicator
tanvishinde017 May 5, 2026
c991e30
🎨 Added loader, password UI, and progress bar styles
tanvishinde017 May 5, 2026
10c1f76
⚡ Added loader control, animations, and progress tracking
tanvishinde017 May 5, 2026
b4ac31a
change in data
tanvishinde017 May 6, 2026
ca3cc23
change in data
tanvishinde017 May 7, 2026
1119651
Fix formatting and punctuation in README.md
tanvishinde017 May 7, 2026
b76d325
description formatting
tanvishinde017 May 7, 2026
78bae34
Fix formatting in README.md
tanvishinde017 May 7, 2026
8b5c08b
Fix formatting in README description
tanvishinde017 May 8, 2026
16bb45f
Add Python runtime version to runtime.txt
tanvishinde017 May 8, 2026
4972612
Update Python version to 3.11.9
tanvishinde017 May 8, 2026
6cd9f55
Repaced Global Loader
tanvishinde017 May 9, 2026
c9eb839
Repaced Global Loader
tanvishinde017 May 9, 2026
1156a76
Repaced Global Loader
tanvishinde017 May 9, 2026
8c7658e
python version added
tanvishinde017 May 9, 2026
0e80133
CLI command 'init-db included
tanvishinde017 May 9, 2026
d4172b4
CLI command 'init-db included
tanvishinde017 May 9, 2026
13f25e4
CLI command 'init-db included
tanvishinde017 May 9, 2026
ef1b006
CLI command 'init-db included
tanvishinde017 May 10, 2026
5462a8a
Flask-Migrate==4.0.7
tanvishinde017 May 10, 2026
40116f6
Flask-Migrate==4.0.7
tanvishinde017 May 10, 2026
80146ce
Edit .env
tanvishinde017 May 10, 2026
3d6e143
Improve maintainer documentation formatting
tanvishinde017 May 11, 2026
c577df8
Improve maintainer documentation formatting
tanvishinde017 May 11, 2026
b35d02c
Improve operations like auth, which may redirect away and back
tanvishinde017 May 11, 2026
e3c8e61
Update README for clarity and grammar fixes
tanvishinde017 May 11, 2026
c2e3407
Update README for database migration and app setup
tanvishinde017 May 11, 2026
19c1f6f
Fix formatting in README for Redis section
tanvishinde017 May 11, 2026
c2c8b63
Update pin history description in README
tanvishinde017 May 11, 2026
82831aa
Fix formatting issue in README description
tanvishinde017 May 11, 2026
0d04235
Update 'database' to 'db' in README
tanvishinde017 May 11, 2026
3ca8339
Correct 'db' to 'database' in README
tanvishinde017 May 11, 2026
16e72fd
Revise Local Setup and environment configuration
tanvishinde017 May 11, 2026
bc632b9
Fix punctuation in README description
tanvishinde017 May 12, 2026
a6f8128
Update README.md
tanvishinde017 May 12, 2026
82b7346
Fix typo in README regarding rate limits
tanvishinde017 May 12, 2026
228d37f
Fix formatting and punctuation in README.md
tanvishinde017 May 12, 2026
102355e
Revise README description for AI pin creator
tanvishinde017 May 12, 2026
d27072d
Correct README formatting and punctuation
tanvishinde017 May 12, 2026
ecb2e55
Update README.md
tanvishinde017 May 12, 2026
7bc0bf2
Update database creation instructions in README
tanvishinde017 May 12, 2026
97631c9
Update instructions for Background Worker service
tanvishinde017 May 12, 2026
5ea4bfd
Fix formatting of Python runtime version comment
tanvishinde017 May 12, 2026
da4694d
Merge pull request #5 from tanvishinde017/tanvishinde017-patch-4
tanvishinde017 May 12, 2026
78cc9a2
Fix README formatting and punctuation
tanvishinde017 May 12, 2026
343a71b
Enhance features section with trending marketing angles
tanvishinde017 May 12, 2026
59de777
Fix formatting issues in README.md
tanvishinde017 May 12, 2026
8393d4e
Merge pull request #6 from tanvishinde017/tanvishinde017-patch-4
tanvishinde017 May 12, 2026
8fbad0e
Revise README to enhance project clarity
tanvishinde017 May 12, 2026
359b0c4
Correct typos in project description
tanvishinde017 May 12, 2026
2e5336f
Merge pull request #7 from tanvishinde017/tanvishinde017-patch-4
tanvishinde017 May 12, 2026
7134360
Revert "Correct typos in project description"
tanvishinde017 May 12, 2026
afaad83
Merge pull request #8 from tanvishinde017/revert-7-tanvishinde017-pat…
tanvishinde017 May 12, 2026
468b824
Fix env in description
tanvishinde017 May 13, 2026
505ccb9
Clean up README.md by removing redundant text
tanvishinde017 Jun 14, 2026
de3bc97
Update README.md
tanvishinde017 Jun 14, 2026
43951cf
Update README.md
tanvishinde017 Jun 14, 2026
454fecd
Update README.md
tanvishinde017 Jun 14, 2026
2dac3c5
Update run.py
tanvishinde017 Jun 14, 2026
97c7fe9
Update run.py
tanvishinde017 Jun 14, 2026
69b99dd
Update requirements.txt
tanvishinde017 Jun 14, 2026
e6f0b6e
Update config.py
tanvishinde017 Jun 14, 2026
2992b63
Update README.md
tanvishinde017 Jun 14, 2026
e104525
Update README.md
tanvishinde017 Jun 14, 2026
c3b14ac
Fix typos and enhance README description
tanvishinde017 Jun 14, 2026
fe6e925
Update README.md
tanvishinde017 Jun 14, 2026
2db098a
Update README.md
tanvishinde017 Jun 14, 2026
9d41a99
Update README.md
tanvishinde017 Jun 14, 2026
48ad056
Update README.md
tanvishinde017 Jun 14, 2026
88f2fe7
Fix formatting in README.md for project structure
tanvishinde017 Jun 14, 2026
1e7de8e
Merge pull request #9 from tanvishinde017/tanvishinde017-patch-4
tanvishinde017 Jun 14, 2026
3a35cae
Merge branch 'tanvishinde017-patch-1' into main
tanvishinde017 Jun 14, 2026
5ebedbb
Merge pull request #11 from tanvishinde017/main
tanvishinde017 Jun 14, 2026
7ea26d7
Merge pull request #14 from tanvishinde017/tanvishinde017-patch-1
tanvishinde017 Jun 14, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,14 @@
.env
# Python
venv/
__pycache__/
*.pyc

# Env
.env

# Database
*.db

# OS
.DS_Store
Thumbs.db
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.11.9
2 changes: 2 additions & 0 deletions Procfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
web: gunicorn -c gunicorn.conf.py "app:create_app('production')"
worker: celery -A celery_worker.celery worker --loglevel=info --concurrency=2
291 changes: 171 additions & 120 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,160 +1,211 @@
# 🚀 PinFlow – Pinterest Content Automation System

PinFlow is a web-based application designed to **automate Pinterest content creation** from product links .

It streamlines affiliate marketing workflows by generating **ready-to-use titles, descriptions, hashtags, and visuals** — all in one place .
# PinFlow📌
> AI-powered Pinterest pin creator for Amazon affiliate marketers in which they can automate there task of findind trendy titles and captions.
> Paste a link → pick an image → get 5 AI titles generated + 5 descriptions→ post to Pinterest directly.

---

## Tech Stack

| Layer | Technology |
|-------|-----------|
| Backend | Flask 3, Flask-Login, Flask-Bcrypt, Flask-Limiter |
| Database | PostgreSQL + SQLAlchemy |
| Jobs | Celery + Redis |
| AI | Anthropic Claude (Sonnet 4) |
| Pinterest | Pinterest API v5 (OAuth 2.0) |
| Frontend | Vanilla JS, CSS custom properties, Syne + Inter fonts |

---

## 📌 Introduction

Creating Pinterest content manually is repetitive and time-consuming .
Each post typically requires:
## Project Structure

```
pinflow/
├── app/
│ ├── __init__.py # App factory, extension init
│ ├── models.py # User, Pin, BoardCache models
│ ├── tasks.py # Celery async tasks
│ ├── routes/
│ │ ├── auth.py # /auth/login, /auth/signup, /auth/logout
│ │ ├── api.py # /api/fetch, /api/generate, /api/post-pin, /api/boards, /api/history
│ │ ├── pinterest.py # /pinterest/connect, /pinterest/callback, /pinterest/disconnect
│ │ └── main.py # / and /dashboard
│ ├── services/
│ │ ├── ai_service.py # Claude API — generates 5 titles + 5 descriptions
│ │ ├── scraper.py # Amazon product scraper
│ │ ├── pinterest_service.py # Pinterest OAuth + API calls
│ │ └── image_service.py # Image download + local storage
│ ├── templates/
│ │ ├── base.html
│ │ ├── login.html
│ │ ├── signup.html
│ │ └── dashboard.html
│ └── static/
│ ├── style.css # Dark Pinterest UI
│ └── script.js # Dashboard UI interactions
├── config.py # Dev / Prod / Test config classes
├── run.py # Dev server entry point
├── celery_worker.py # Celery worker entry point
├── gunicorn.conf.py # Production Gunicorn config
├── Procfile # Render/Railway process definitions
├── requirements.txt
└── .env.example
```

- Finding relevant images
- Writing engaging titles
- Creating descriptions
- Adding hashtags
It streamlines affiliate marketing workflows by generating **ready-to-use titles, descriptions, hashtags, and visuals** — all in one place .

**PinFlow automates this entire workflow**, helping creators focus on scaling instead of manual work.

---

## 🧠 Problem Statement
## Local Setup

Content creators and affiliate marketers often struggle with:
### Prerequisites

- ⏳ Time-consuming manual processes
- 🔁 Repetitive tasks for every product
- 📉 Inconsistent content quality
- 🚫 Lack of automation tools
- Python 3.11+
- PostgreSQL running locally
- Redis running locally on web (`redis-server`)

These challenges reduce productivity and make scaling difficult.
### 1. Clone & install

---
```bash
git clone https://github.com/yourname/pinflow.git
cd pinflow
python -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
pip install -r requirements.txt
```

## 💡 Solution
### 2. Configure environment in .env

PinFlow provides a simple and efficient pipeline:
```bash
cp .env.example .env
# Edit .env — fill in your keys (see below)
```

- 🔗 Accepts a product link
- 🧾 Extracts product information
- 🖼️ Fetches relevant images
- ✍️ Generates structured content
- 👀 Displays a ready-to-use preview
**Required keys:**

✅ Result: Faster workflow, better consistency, and improved efficiency.
| Variable | Where to get it |
|----------|----------------|
| `SECRET_KEY` | Generate: `python -c "import secrets; print(secrets.token_hex(32))"` |
| `DATABASE_URL` | Your local Postgres URL |
| `REDIS_URL` | `redis://localhost:6379/0` |
| `ANTHROPIC_API_KEY` | https://console.anthropic.com |
| `PINTEREST_CLIENT_ID` | https://developers.pinterest.com/apps/ |
| `PINTEREST_CLIENT_SECRET` | Same Pinterest app |
| `PINTEREST_REDIRECT_URI` | Set to `http://localhost:5000/pinterest/callback` |

---
### 3. Create the database in psql

## ⚙️ System Architecture
```bash
# Create the DB in psql:
createdb pinflow_dev

### 🔹 Frontend
- Built with **HTML + CSS**
- Handles user input and UI rendering
# Then initialise tables:
python run.py # tables auto-created on first run
# OR use the CLI command:
flask --app run init-db
```

### 🔹 Backend
- Built with **Python + Flask**
- Handles routing, logic, and processing
### 4. Run the development server

### 🔹 Data Layer
- **BeautifulSoup** → HTML parsing
- **Requests** → HTTP handling
**Terminal 1 — Flask:**
```bash
python run.py
```

---
**Terminal 2 — Celery worker (required for Pinterest posting):**
```bash
celery -A celery_worker.celery worker --loglevel=info
```

## 🔄 Workflow
Open http://localhost:5000 → sign up → connect Pinterest → start creating pins.

1. User enters product link
2. Application extracts product title
3. Keywords are generated
4. Images are fetched
5. User selects an image
6. Content is generated
7. Final preview is displayed
---

## API Reference

| Method | Endpoint | Auth | Description |
|--------|----------|------|-------------|
| POST | `/api/fetch` | ✅ | Scrape Amazon link |
| POST | `/api/generate` | ✅ | Generate 5 titles + 5 descriptions |
| POST | `/api/post-pin` | ✅ | Queue pin for posting |
| GET | `/api/boards` | ✅ | List Pinterest boards (cached) |
| POST | `/api/boards/refresh` | ✅ | Clear board cache |
| GET | `/api/history` | ✅ | Last 50 pins |
| DELETE | `/api/history/<id>` | ✅ | Delete a pin |
| GET | `/pinterest/connect` | ✅ | Start OAuth flow |
| GET | `/pinterest/callback` | ✅ | OAuth callback |
| POST | `/pinterest/disconnect` | ✅ | Remove Pinterest tokens |

---

## 🧩 Features
## Deployment (Render)

- ✅ Product link input
- 🧾 Product title extraction
- 🖼️ Dynamic image generation
- 🎯 Image selection system
- ✍️ Content generation (title, description, tags)
- 📌 Pinterest-style preview UI
### Services to create

---
1. **Web Service** — Python, runs Flask
2. **Background Worker** — Python, runs Celery
3. **PostgreSQL** — Render managed DB
4. **Redis** — Render managed Redis

### Steps

1. Push code to GitHub
2. In Render dashboard → New → Web Service → connect repo
3. Build command: `pip install -r requirements.txt`
4. Start command: `gunicorn -c gunicorn.conf.py "app:create_app('production')"`
5. Add all environment variables from `.env.example`
6. Set `FLASK_ENV=production`
7. Create a second Render service (Background Worker) with start command in render:
```
celery -A celery_worker.celery worker --loglevel=info --concurrency=2
```
8. Set `PINTEREST_REDIRECT_URI` to your Render domain:
```
https://your-app.onrender.com/pinterest/callback
```
9. Update this URL in your Pinterest app settings too.

## 🧱 Tech Stack
### Database migration on deploy and see usage

### Backend
- Python
- Flask
In Render shell or as a one-off job :
```bash
flask --app run init-db
```

### Frontend
- HTML
- CSS
---

### Libraries
- BeautifulSoup
- Requests
## Pinterest App Setup on pinflow with api connection

### Tools
- Git
- GitHub
1. Go to https://developers.pinterest.com/apps/
2. Create a new app
3. Add OAuth redirect URI: `https://yourdomain.com/pinterest/callback`
4. Request scopes: `boards:read`, `pins:write`, `user_accounts:read`
5. Copy Client ID and Client Secret to your `.env`

---

## Rate Limits

- `/api/fetch` — 30 requests/minute per user
- `/api/generate` — 20 requests/minute per user
- `/api/post-pin` — 10 requests/minute per user
- Global default — 200/day, 50/hour

Limits are enforced via Flask-Limiter backed by Redis on web.

---

🚀 Future Roadmap
Phase 4
Pinterest API integration
User authentication
Board selection
Direct pin publishing
Phase 5
AI content generation
SEO optimization
Smart hashtag suggestions
Phase 6
Post scheduling
Analytics dashboard
Multi-platform support
Phase 7
Docker containerization
CI/CD pipeline
Cloud deployment
🧠 Learning Outcomes

Through this project, I am learning:

Flask-based web development
Web scraping techniques
System design fundamentals
Automation workflows
Version control using Git
🤝 Contributing

Contributions are welcome!

Fork the repository
Create a branch
Make your changes
Submit a Pull Request
💸 Support

If you find this project useful:

⭐ Star the repository
📢 Share it
💖 Sponsor development

👉 https://github.com/sponsors/tanvishinde017

👩‍💻 Author

Tanavi Shinde
BSc IT Student
Aspiring Developer & DevOps Engineer
## Features

- **5 AI titles + 5 descriptions** per generation with different marketing angles which are trending
- **4 content tones**: Viral 🔥 / Luxury ✨ / Casual 💬 / Affiliate 💰
- **Image selection** from product images + lifestyle grid
- **Pinterest board selector** with 1-hour caching
- **Async posting** via Celery with auto-retry (3 attempts)
- **Pin history** — last 50 pins per user with status badges for user
- **Toast notifications** for all actions
- **Live pin preview** updates as you edit
- **Rate limiting** per user via Redis
- **Token refresh** — Pinterest access tokens auto-refreshed
Loading