Skip to content

Harshil2120/PostLane

Repository files navigation

πŸš€ PostLane - AI-Powered Social Media Management

Screenshot 2025-12-02 at 10 18 00β€―PM A modern Next.js application that accelerates your social media workflow with intelligent AI agents that create, optimize, and schedule your content across all platforms.

✨ Features

  • AI-Powered Content Creation: Intelligent content generation and optimization
  • Multi-Platform Support: Twitter (X) and LinkedIn integration
  • Smart Scheduling: Optimal posting times for maximum engagement
  • Authentication: Google OAuth and Email magic links via NextAuth.js
  • Twitter Integration: Full OAuth 1.0a flow for posting tweets
  • User Management: Profile management and analytics
  • Security: Rate limiting, input sanitization, and security headers
  • Modern UI: Beautiful interface built with shadcn/ui and Tailwind CSS

πŸš€ Quick Start

Prerequisites

  • Node.js 18+
  • MongoDB database
  • Google OAuth credentials
  • Twitter API credentials
  • Resend account for email magic links
  • Cloudflare Turnstile account for bot protection

Environment Setup

  1. Copy the environment template:
cp .env.example .env.local
  1. Fill in your environment variables:
# NextAuth Configuration
NEXTAUTH_SECRET=your-secret-key-here
NEXTAUTH_URL=http://localhost:3000

# Database
MONGODB_URI=mongodb://localhost:27017/postlane-db
MONGODB_DB_NAME=postlane-db

# Google OAuth
GOOGLE_CLIENT_ID=your-google-client-id
GOOGLE_CLIENT_SECRET=your-google-client-secret

# Twitter OAuth
TWITTER_CLIENT_ID=your-twitter-client-id
TWITTER_CLIENT_SECRET=your-twitter-client-secret

# Email Configuration (Resend)
RESEND_API_KEY=your-resend-api-key
EMAIL_FROM=your-verified-email@domain.com

# Security (Cloudflare Turnstile)
NEXT_PUBLIC_TURNSTILE_SITE_KEYY=your-turnstile-site-key
TURNSTILE_SECRET_KEY=your-turnstile-secret-key

Installation

# Install dependencies
npm install

# Run development server
npm run dev

Open http://localhost:3000 to see the application.

πŸ› οΈ Development

# Development
npm run dev

# Build for production
npm run build

# Start production server
npm start

# Lint code
npm run lint

# Fix linting issues
npm run lint:fix

🎨 UI Components & Design System

PostLane uses shadcn/ui - a collection of beautifully designed, accessible, and customizable components built on top of Radix UI primitives and styled with Tailwind CSS.

Key UI Features:

  • Accessible Components: Built with accessibility in mind using Radix UI primitives
  • Customizable: Easy to modify and extend with Tailwind CSS
  • Dark Mode: Built-in dark theme support with CSS variables
  • Responsive: Mobile-first design approach
  • Type Safe: Full TypeScript support (when implemented)

Available Components:

  • Layout: Sidebar, Sheet, Card, Separator
  • Forms: Input, Button, Label, Checkbox, Select
  • Feedback: Alert, Badge, Skeleton, Tooltip
  • Navigation: Dropdown Menu, Toggle, Toggle Group
  • Data Display: Avatar

Adding New Components:

# Add new shadcn/ui components
npx shadcn-ui@latest add [component-name]

# Example: Add a dialog component
npx shadcn-ui@latest add dialog

πŸ—οΈ Architecture

Tech Stack

  • Framework: Next.js 14 with App Router
  • Authentication: NextAuth.js v4
  • Database: MongoDB with connection pooling
  • UI Components: shadcn/ui with Radix UI primitives
  • Styling: Tailwind CSS with CSS variables
  • OAuth: Twitter OAuth 1.0a, Google OAuth 2.0
  • Email: Resend for magic links
  • Security: Cloudflare Turnstile for bot protection

Project Structure

app/
β”œβ”€β”€ api/                    # API routes
β”‚   β”œβ”€β”€ auth/              # NextAuth configuration
β”‚   β”œβ”€β”€ tweet/             # Tweet posting
β”‚   β”œβ”€β”€ twitter/           # Twitter OAuth flow
β”‚   └── user/              # User management
β”œβ”€β”€ auth/                  # Authentication pages
β”œβ”€β”€ chat/                  # Main application
└── layout.js              # Root layout

components/
β”œβ”€β”€ ui/                    # shadcn/ui components
β”œβ”€β”€ auth/                  # Authentication components
β”œβ”€β”€ features/              # Feature-specific components
β”œβ”€β”€ layout/                # Layout components
└── common/                # Shared components

lib/
β”œβ”€β”€ auth.js                # Authentication utilities
β”œβ”€β”€ mongodb.js             # Database connection
β”œβ”€β”€ security.js            # Security utilities
β”œβ”€β”€ twitter-oauth.js       # Twitter OAuth implementation
β”œβ”€β”€ twitter-token-validator.js # Token validation
└── utils.js               # Utility functions

πŸ”’ Security Features

  • Rate Limiting: Built-in rate limiting for API endpoints
  • Input Sanitization: XSS protection and input validation
  • Security Headers: Comprehensive security headers
  • Token Validation: Automatic Twitter token validation
  • Session Management: Secure JWT sessions with MongoDB storage
  • Bot Protection: Cloudflare Turnstile integration
  • CSRF Protection: Built-in NextAuth.js CSRF protection

πŸš€ Production Deployment

Environment Variables

Ensure all required environment variables are set in production:

# Required for production
NEXTAUTH_SECRET=your-production-secret
NEXTAUTH_URL=https://yourdomain.com
MONGODB_URI=your-production-mongodb-uri
MONGODB_DB_NAME=postlane-db
GOOGLE_CLIENT_ID=your-google-client-id
GOOGLE_CLIENT_SECRET=your-google-client-secret
TWITTER_CLIENT_ID=your-twitter-client-id
TWITTER_CLIENT_SECRET=your-twitter-client-secret
RESEND_API_KEY=your-resend-api-key
EMAIL_FROM=your-verified-email@domain.com
TURNSTILE_SITE_KEY=your-turnstile-site-key
TURNSTILE_SECRET_KEY=your-turnstile-secret-key
NODE_ENV=production

Deployment Platforms

Vercel (Recommended)

  1. Connect your GitHub repository to Vercel
  2. Set environment variables in Vercel dashboard
  3. Deploy automatically on push to main branch

Other Platforms

  • Railway: Supports MongoDB and Next.js
  • Netlify: With serverless functions
  • DigitalOcean: App Platform with managed MongoDB

Database Setup

  • Use MongoDB Atlas for production database
  • Ensure connection string includes SSL
  • Set up proper indexes for performance

πŸ“Š Monitoring & Analytics

The application includes built-in analytics:

  • User registration and sign-in tracking
  • Twitter connection status monitoring
  • Tweet posting success/failure rates
  • Rate limiting and error tracking

πŸ”§ Troubleshooting

Common Issues

  1. Twitter OAuth Errors

    • Verify Twitter app credentials
    • Check callback URLs in Twitter Developer Portal
    • Ensure OAuth 1.0a is enabled
  2. Database Connection Issues

    • Verify MongoDB URI format
    • Check network connectivity
    • Ensure database user permissions
  3. Email Magic Links Not Working

    • Verify Resend API key
    • Check domain verification in Resend
    • Ensure EMAIL_FROM is verified
  4. Turnstile Verification Issues

    • Verify TURNSTILE_SITE_KEY and TURNSTILE_SECRET_KEY
    • Check domain configuration in Cloudflare Turnstile
    • Ensure site key matches the domain

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors