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.
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.
- 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
- 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
- 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
- Automated post synchronization from Instagram
- Background jobs for token refresh
- Database-backed analytics with PostgreSQL
- Efficient data upserts to prevent duplicates
- 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
- Node.js 18+
- PostgreSQL database (local Docker or Vercel Postgres)
- Instagram App credentials (Facebook Developer Console)
-
Clone the repository
git clone <your-repo-url> cd creator-growth-api
-
Install dependencies
npm install
-
Set up environment variables
Create
.env.localin 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
-
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
-
Run migrations
npm run migrate
-
Start development server
npm run dev
Visit
http://localhost:3000
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)
POST /api/auth/register- User registrationPOST /api/auth/login- User loginGET /api/auth/me- Get current user (protected)
GET /api/instagram/connect- Get OAuth URL (protected)GET /auth/instagram/callback- OAuth callbackPOST /api/instagram/refresh- Refresh posts (protected)DELETE /api/instagram/disconnect- Disconnect account (protected)GET /api/instagram/posts- Get user's posts (protected)
GET /api/growth/stats- Get growth statistics (protected)
POST /api/waitlist/signup- Join waitlist
GET /api/admin/waitlist- View waitlist entries (admin only)
- Push to GitHub
- Connect to Vercel
- Import your repository
- Vercel will auto-detect Next.js
- Add environment variables in Vercel dashboard
- Set up Vercel Postgres (optional, or use your own PostgreSQL)
- Deploy!
Make sure to set all environment variables in your deployment platform:
POSTGRES_URL- Your production database URLJWT_SECRET- Strong random secretINSTAGRAM_CLIENT_ID- Your Instagram app IDINSTAGRAM_CLIENT_SECRET- Your Instagram app secretINSTAGRAM_REDIRECT_URI- Your production callback URL (e.g.,https://your-domain.com/auth/instagram/callback)
- users - User accounts
- instagram_accounts - Connected Instagram accounts
- instagram_posts - Fetched Instagram posts
- waitlist - Waitlist signups
- JWT tokens for authentication
- Password hashing with bcrypt
- Rate limiting on auth endpoints
- Secure token storage
- CORS protection
- Environment variable security
MIT License - see LICENSE file for details
Contributions welcome! Please open an issue or submit a pull request.
For issues and questions, please open a GitHub issue.