Skip to content

About

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

πŸ“ˆ Creator Growth Tool

A full-stack Instagram analytics platform built with Next.js that helps content creators track engagement metrics, analyze growth trends, and get AI-powered recommendations to optimize their content strategy.

Next.js React PostgreSQL TypeScript License

🎯 Overview

Creator Growth Tool connects to Instagram via OAuth 2.0 and analyzes up to 10,000+ posts to provide actionable insights. It calculates engagement rates, tracks posting trends, identifies top-performing content, and delivers personalized growth recommendations.

Built as a scalable SaaS solution with production-grade security (JWT authentication, rate limiting, secure token storage) and automated token refresh for long-lived Instagram access.

✨ Features

πŸ“Š Analytics Dashboard

  • Real-time Metrics: Track total posts, likes, comments, and engagement
  • Trend Analysis: Compare current performance vs. previous periods with percentage changes
  • Best Post Identification: Automatically identifies your top-performing content
  • Engagement Rates: Calculate average likes and comments per post

πŸ” Authentication & Security

  • JWT-based authentication with secure token storage
  • Instagram OAuth 2.0 integration
  • Rate limiting to prevent brute force attacks
  • Long-lived token management with automatic refresh (60-day tokens)
  • Password hashing with bcrypt

πŸ“ˆ Growth Intelligence

  • AI-powered growth messages based on engagement trends
  • Posting frequency tracking (weekly/monthly)
  • Period-based comparison analytics (30/60/90 day views)
  • Hashtag extraction and analysis

πŸ”„ Data Management

  • Automated post synchronization from Instagram
  • Background jobs for token refresh
  • Database-backed analytics with PostgreSQL
  • Efficient data upserts to prevent duplicates

πŸ› οΈ Tech Stack

Full Stack

  • Framework: Next.js 15 (App Router)
  • Language: TypeScript
  • UI: React 19 + Tailwind CSS
  • Database: PostgreSQL (via pg / Vercel Postgres)
  • Authentication: JWT (jsonwebtoken)
  • OAuth: Instagram Graph API
  • Email: Resend API
  • Deployment: Vercel

πŸš€ Getting Started

Prerequisites

  • Node.js 18+
  • PostgreSQL database (local Docker or Vercel Postgres)
  • Instagram App credentials (Facebook Developer Console)

Installation

  1. Clone the repository

    git clone <your-repo-url>
    cd creator-growth-api
  2. Install dependencies

    npm install
  3. Set up environment variables

    Create .env.local in the root directory:

    # Database
    POSTGRES_URL=postgresql://username:password@localhost:5432/dbname
    
    # JWT Secret (min 32 characters)
    JWT_SECRET=your-super-secret-random-string-here
    
    # Instagram OAuth
    INSTAGRAM_CLIENT_ID=your-instagram-client-id
    INSTAGRAM_CLIENT_SECRET=your-instagram-client-secret
    INSTAGRAM_REDIRECT_URI=http://localhost:3000/auth/instagram/callback
    
    # Frontend URL
    FRONTEND_URL=http://localhost:3000
    NEXT_PUBLIC_API_URL=http://localhost:3000
    
    # Email (Optional - for waitlist notifications)
    RESEND_API_KEY=your-resend-api-key
    
    # Admin (Optional)
    ADMIN_PASSWORD=your-admin-password
  4. Set up database

    Using Docker:

    docker run --name cg-postgres \
      -e POSTGRES_USER=postgres \
      -e POSTGRES_PASSWORD=postgres \
      -e POSTGRES_DB=creator_growth \
      -p 5432:5432 \
      -d postgres:15
  5. Run migrations

    npm run migrate
  6. Start development server

    npm run dev

    Visit http://localhost:3000

πŸ“ Project Structure

creator-growth-api/
β”œβ”€β”€ app/                    # Next.js App Router
β”‚   β”œβ”€β”€ api/               # API routes
β”‚   β”‚   β”œβ”€β”€ auth/          # Authentication endpoints
β”‚   β”‚   β”œβ”€β”€ instagram/     # Instagram OAuth & data
β”‚   β”‚   β”œβ”€β”€ waitlist/      # Waitlist signup
β”‚   β”‚   β”œβ”€β”€ admin/         # Admin dashboard API
β”‚   β”‚   └── growth/        # Analytics endpoints
β”‚   β”œβ”€β”€ auth/              # OAuth callback routes
β”‚   β”œβ”€β”€ dashboard/         # Dashboard page
β”‚   β”œβ”€β”€ login/             # Login page
β”‚   β”œβ”€β”€ admin/             # Admin page
β”‚   β”œβ”€β”€ page.tsx           # Home/waitlist page
β”‚   β”œβ”€β”€ layout.tsx         # Root layout
β”‚   └── globals.css        # Global styles
β”œβ”€β”€ lib/                   # Shared utilities
β”‚   β”œβ”€β”€ db.ts             # Database connection
β”‚   β”œβ”€β”€ services/         # Business logic
β”‚   β”‚   β”œβ”€β”€ auth.ts       # Authentication
β”‚   β”‚   β”œβ”€β”€ jwt.ts        # JWT tokens
β”‚   β”‚   β”œβ”€β”€ instagram.ts  # Instagram API
β”‚   β”‚   β”œβ”€β”€ email.ts      # Email sending
β”‚   β”‚   └── growth.ts     # Analytics
β”‚   └── utils/            # Helper functions
β”‚       └── auth.ts       # Auth middleware helpers
β”œβ”€β”€ scripts/              # Utility scripts
β”‚   └── migrate.ts        # Database migrations
β”œβ”€β”€ middleware.ts         # Next.js middleware (JWT auth)
β”œβ”€β”€ package.json
β”œβ”€β”€ tsconfig.json
└── .env.local           # Environment variables (not in git)

πŸ”‘ API Endpoints

Authentication

  • POST /api/auth/register - User registration
  • POST /api/auth/login - User login
  • GET /api/auth/me - Get current user (protected)

Instagram

  • GET /api/instagram/connect - Get OAuth URL (protected)
  • GET /auth/instagram/callback - OAuth callback
  • POST /api/instagram/refresh - Refresh posts (protected)
  • DELETE /api/instagram/disconnect - Disconnect account (protected)
  • GET /api/instagram/posts - Get user's posts (protected)

Analytics

  • GET /api/growth/stats - Get growth statistics (protected)

Waitlist

  • POST /api/waitlist/signup - Join waitlist

Admin

  • GET /api/admin/waitlist - View waitlist entries (admin only)

🚒 Deployment

Vercel (Recommended)

  1. Push to GitHub
  2. Connect to Vercel
    • Import your repository
    • Vercel will auto-detect Next.js
  3. Add environment variables in Vercel dashboard
  4. Set up Vercel Postgres (optional, or use your own PostgreSQL)
  5. Deploy!

Environment Variables for Production

Make sure to set all environment variables in your deployment platform:

  • POSTGRES_URL - Your production database URL
  • JWT_SECRET - Strong random secret
  • INSTAGRAM_CLIENT_ID - Your Instagram app ID
  • INSTAGRAM_CLIENT_SECRET - Your Instagram app secret
  • INSTAGRAM_REDIRECT_URI - Your production callback URL (e.g., https://your-domain.com/auth/instagram/callback)

πŸ“ Database Schema

  • users - User accounts
  • instagram_accounts - Connected Instagram accounts
  • instagram_posts - Fetched Instagram posts
  • waitlist - Waitlist signups

πŸ”’ Security

  • JWT tokens for authentication
  • Password hashing with bcrypt
  • Rate limiting on auth endpoints
  • Secure token storage
  • CORS protection
  • Environment variable security

πŸ“„ License

MIT License - see LICENSE file for details

🀝 Contributing

Contributions welcome! Please open an issue or submit a pull request.

πŸ“§ Support

For issues and questions, please open a GitHub issue.

About

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages