Affiliate Hub is a fullstack application for Instagram automation and product management built with Next.js 15, TypeScript, and MySQL, now featuring S3-compatible file storage with MinIO.
- Automated Post Scheduling: Schedule Instagram posts with videos/photos
- Auto-DM Keyword Based: Automatic DM system based on comment keywords
- Repost Functionality: Repost feature with automatic video download
- Instagram Graph API Integration: Direct integration with Instagram
- Product Master Data: Manage products with ID, name, image, and URL
- Image Upload: Upload product images directly to secure cloud storage
- Product Linking: Connect posts with specific products
- Search & Filter: Search and filter products
- Modern Dashboard: Easy-to-use interface with better UX
- Secure Authentication: JWT-based authentication with session management
- Real-time Status: Monitor posting status and schedules
- File Upload: Upload videos/photos to secure MinIO storage
- Better Form Experience: Improved placeholder visibility and focus states
- Docker-based Storage: MinIO runs in Docker container for local development
- S3-Compatible API: Easy migration to AWS S3 or other S3-compatible services
- Automatic Bucket Management: Buckets are created and configured automatically
- Secure File URLs: Public URLs for uploaded files with proper access control
- Better Placeholder Visibility: Fixed placeholder text visibility in light mode
- Improved Focus States: Better visual feedback for form interactions
- Upload Progress Indicators: Loading states during file uploads
- Image Previews: Preview images before saving
- Frontend & Backend: Next.js 15 with App Router
- Language: TypeScript
- Styling: Tailwind CSS
- Database: MySQL with Prisma ORM
- File Storage: MinIO (S3-Compatible) with Docker
- Authentication: JWT with session cookies
- File Handling: MinIO client for uploads, Sharp for image processing
- Scheduling: Node-cron for scheduling
- API Integration: Axios for Instagram Graph API
affiliate-hub/
โโโ docker-compose.yml # MinIO and MySQL containers
โโโ prisma/
โ โโโ schema.prisma # Database schema
โโโ src/
โ โโโ app/
โ โ โโโ api/ # Backend API routes
โ โ โ โโโ auth/ # Authentication endpoints
โ โ โ โโโ products/ # Product management
โ โ โ โโโ posts/ # Post scheduling
โ โ โ โโโ upload/ # File upload to MinIO
โ โ โโโ dashboard/ # Dashboard page
โ โ โโโ login/ # Login page
โ โ โโโ page.tsx # Home page
โ โโโ lib/
โ โ โโโ minio.ts # MinIO configuration
โ โ โโโ prisma.ts # Database connection
โ โ โโโ auth.ts # Authentication utilities
โ โ โโโ instagram.ts # Instagram API client
โ โ โโโ scheduler.ts # Scheduling utilities
โโโ scripts/
โ โโโ scheduler.ts # Standalone scheduler script
โโโ SETUP.md # Detailed setup guide
For detailed setup instructions, see SETUP.md
git clone <repository-url>
cd affiliate-hubdocker-compose up -dnpm install
cp .env.example .env.local
npm run db:push
npm run db:seednpm run devVisit http://localhost:3000 and login with:
- Username:
admin - Password:
admin123
DATABASE_URL="mysql://username:password@localhost:3306/AutoIG"
NEXTAUTH_SECRET="your-secret-key-here"
NEXTAUTH_URL="http://localhost:3000"
INSTAGRAM_APP_ID="your-instagram-app-id"
INSTAGRAM_APP_SECRET="your-instagram-app-secret"
ADMIN_USERNAME="admin"
ADMIN_PASSWORD="password123"
JWT_SECRET="your-jwt-secret-here"# Generate Prisma client
npm run db:generate
# Push schema to database (untuk development)
npm run db:push
# Atau gunakan migrations (untuk production)
npm run db:migrate- Buat Facebook App di Facebook Developers
- Tambahkan Instagram Basic Display API
- Dapatkan Access Token dan Page ID
- Simpan di database melalui Instagram Config
npm run devnpm run scheduler- Buka browser:
http://localhost:3000 - Login dengan:
admin/password123
POST /api/auth/login- LoginPOST /api/auth/logout- LogoutGET /api/auth/check- Check auth status
GET /api/products- Get all productsPOST /api/products- Create productPUT /api/products/[id]- Update productDELETE /api/products/[id]- Delete product
GET /api/posts- Get all scheduled postsPOST /api/posts- Create scheduled post
POST /api/upload- Upload file
id(Int, Primary Key)name(String)picture(String)url(String)createdAt,updatedAt
id(Int, Primary Key)content(String) - File pathcontentType(String) - 'video' or 'photo'caption(Text)scheduledAt(DateTime)keywords(Text) - Comma-separatedproductId(Int, Foreign Key)isRepost(Boolean)repostUrl(String, Optional)status(String) - 'pending', 'posted', 'failed'postedAt(DateTime, Optional)
id(Int, Primary Key)username(String) - Instagram usernamekeyword(String)productId(Int)sentAt(DateTime)
id(Int, Primary Key)accessToken(String)pageId(String)isActive(Boolean)
- Tambah produk baru dengan nama, gambar, dan URL
- Edit dan hapus produk existing
- Search produk berdasarkan nama
- Grid view dengan preview gambar
- Upload video/foto untuk konten
- Pilih produk yang akan dipromosikan
- Set caption dan waktu posting
- Tambah keywords untuk auto-DM
- Support repost dari URL lain
- Monitor komentar di posting
- Deteksi keyword yang sudah ditentukan
- Kirim DM otomatis dengan link produk
- Log history DM yang terkirim
- Background process untuk eksekusi posting
- Cron job untuk monitoring komentar
- Retry mechanism untuk posting gagal
- Real-time status update
Edit di file .env:
ADMIN_USERNAME="your_username"
ADMIN_PASSWORD="your_password"- Login ke dashboard
- Tambah config melalui database
- Atau buat API endpoint untuk manage config
Edit di src/lib/scheduler.ts:
timezone: 'Asia/Jakarta' // Ganti sesuai timezone- Gunakan HTTPS di production
- Ganti semua secret keys
- Implement rate limiting
- Validate semua input
- Perlu approval untuk production
- Rate limits apply
- Access token bisa expire
- Saat ini file disimpan lokal di
/public/uploads - Untuk production, consider cloud storage (AWS S3, etc.)
- Fork repository
- Create feature branch
- Commit changes
- Push to branch
- Create Pull Request
This project is licensed under the MIT License.
Jika ada pertanyaan atau issue:
- Check dokumentasi ini
- Check Instagram Graph API docs
- Create issue di GitHub repository
Developed with โค๏ธ using Next.js & TypeScript