Skip to content

FeedRecap: AI-powered platform for personalized newsletters πŸ“© featuring top tweets 🐦 on trending topics like Politics, Tech, Sports, and Finance πŸ’Ό. Follow categories or custom Twitter profiles for curated content πŸ“°. Built with Next.js, Node.js, Express.js, MongoDB, TypeScript

License

Notifications You must be signed in to change notification settings

hasanpeal/FeedRecap

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

194 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

FeedRecap

FeedRecap Logo

FeedRecap is a cutting-edge AI-powered newsletter platform that curates top tweets from Twitter, delivering them directly to your inbox. Whether you're following trending categories like politics, tech, finance, or entertainment, or customizing your feed with specific Twitter profiles, FeedRecap ensures you stay informed effortlessly and efficiently.


πŸš€ Live Demo

🌐 Website: FeedRecap

πŸ”— Repository: GitHub


✨ Features

πŸ“° Category Mode

  • Choose from predefined categories:
    • Politics
    • Geopolitics
    • Finance
    • AI
    • Tech
    • Crypto
    • Meme
    • Sports
    • Entertainment
  • Set your preferred newsletter delivery times (Morning, Afternoon, Night).
  • Receive AI-curated newsletters with the top 15 tweets from your selected categories and share them easily with friends via WhatsApp, Telegram, or Email.

πŸ”§ Custom Profile Mode

  • Add Twitter profiles via an auto-suggestion feature.
  • Follow as many Twitter profiles as you like.
  • Get personalized newsletters based on your custom profile feed, curated by AI.

πŸ“Š Dashboard

  • Access your personalized dashboard with these tabs:
    1. Newsfeed: View top tweets based on your selected categories or custom profiles.
    2. Latest Newsletter: Access the most recent newsletters.
    3. Settings: Update your categories, custom profiles, timezone, and delivery time.

πŸ“© Newsletter Features

  • Newsletter: AI-powered newsletter content delivered straight to your inbox.
  • Top Tweets: Curated top tweets of the day.
  • Share Easily: Share tweets or newsletters to:
    • WhatsApp
    • Telegram
    • Email
  • Web Link: Access your newsletter via a web link for easy sharing with friends.

πŸ“Š Audit Logging System

FeedRecap includes a comprehensive audit logging system that tracks all user activities for security, analytics, and debugging purposes.

  • Automatic Activity Tracking: All major user actions are automatically logged:

    • Page visits (all pages)
    • Account creation and login/logout
    • Password changes
    • Account updates
    • Twitter account linking/unlinking
    • Category and profile updates
    • Feed type changes
    • Newsletter views
    • Link clicks (with full URLs)
    • Feedback submissions
  • Metadata Storage: Each log entry includes:

    • User ID and email
    • Activity type and description
    • Page/route information
    • IP address and user agent
    • Timestamp
    • Additional metadata (links, categories, etc.)
  • Database Storage: All audit logs are stored in MongoDB with indexed fields for fast queries and analytics.

πŸ” Admin Dashboard

FeedRecap includes a powerful admin dashboard for monitoring and analytics (accessible only to admin users).

  • Admin Authentication:

    • Users with isAdmin: true in the database can access the admin dashboard
    • Protected by JWT authentication middleware
    • Accessible at /admin route
  • Analytics Features:

    • Page Views Analytics: Track page visits with time period filters (1d, 3d, 7d, 30d, 6m, 1y)
    • Link Clicks Tracking: Monitor all clicked links with user information and timestamps
    • Activity Statistics: View activity distribution with visual charts
    • User Metrics: Track total users, feed type distribution, Twitter account linking stats
  • Visualizations:

    • Line charts for page views over time
    • Pie charts for activity distribution
    • Scrollable lists for link clicks and live activities
  • Live Activities Feed:

    • Real-time audit log display
    • Filter by user email
    • Filter by activity type
    • Shows timestamp, user, activity, description, and page
  • User Management:

    • View all users with email, feed type, and Twitter account status
    • User statistics and metrics

πŸ› οΈ Tech Stack

Frontend

  • Framework: Next.js, React
  • Language: TypeScript
  • State Management: React Context API
  • HTTP Client: Axios with JWT interceptors
  • Analytics: Google Analytics, Vercel Analytics
  • Deployed On: Vercel

Backend

  • Framework: Express.js
  • Authentication: JWT (JSON Web Tokens), Google OAuth, Email-based login with two-step verification
  • Database: MongoDB with Mongoose
  • API: SendGrid (Email), Gemini AI, Axios
  • Language: TypeScript
  • Dev Tools: Nodemon, MongoDB Atlas, Postman, Node.js
  • Automation: Node Cron for scheduling newsletter tasks
  • Generative AI: Google Gemini AI

πŸ—‚οΈ Project Structure

FeedRecap/
β”œβ”€β”€ client/                    # Frontend (Next.js)
β”‚   β”œβ”€β”€ app/                   # Next.js app directory
β”‚   β”‚   β”œβ”€β”€ api/               # API routes (DeepSeek, Twitter, video-proxy)
β”‚   β”‚   β”œβ”€β”€ dashboard/         # User dashboard page
β”‚   β”‚   β”œβ”€β”€ signin/            # Sign-in page
β”‚   β”‚   β”œβ”€β”€ signup/            # Sign-up page
β”‚   β”‚   └── ...                # Other pages
β”‚   β”œβ”€β”€ components/            # React components
β”‚   β”‚   β”œβ”€β”€ dashboard/         # Dashboard-specific components
β”‚   β”‚   └── PageVisitLogger.tsx # Automatic page visit logging
β”‚   β”œβ”€β”€ app/
β”‚   β”‚   └── admin/            # Admin dashboard page
β”‚   β”œβ”€β”€ context/               # React Context (UserContext)
β”‚   β”œβ”€β”€ utils/                 # Utility functions (axios, notifications)
β”‚   └── public/                # Static assets
β”œβ”€β”€ server/                    # Backend (Express.js)
β”‚   β”œβ”€β”€ src/                   # TypeScript source files
β”‚   β”‚   β”œβ”€β”€ server.ts          # Main server file with JWT auth
β”‚   β”‚   β”œβ”€β”€ userModel.ts        # User MongoDB model
β”‚   β”‚   β”œβ”€β”€ newsletterModel.ts  # Newsletter MongoDB model
β”‚   β”‚   β”œβ”€β”€ tweetModel.ts       # Tweet MongoDB model
β”‚   β”‚   β”œβ”€β”€ auditLogModel.ts    # Audit log MongoDB model
β”‚   β”‚   β”œβ”€β”€ auditLogger.ts      # Audit logging utilities
β”‚   β”‚   β”œβ”€β”€ digest.ts          # Newsletter generation logic
β”‚   β”‚   └── db.ts              # Database connection
β”‚   └── dist/                  # Compiled JavaScript files
β”œβ”€β”€ start.sh                   # Startup script for client + server
└── README.md                  # This file

πŸ§‘β€πŸ’» Getting Started

Prerequisites

  • Node.js (v18 or higher)
  • npm or yarn
  • MongoDB database (local or MongoDB Atlas)
  • Environment variables configured (see Environment Variables section below)

Environment Variables

Before running the application, you need to configure environment variables:

Server Environment Variables (server/.env)

# MongoDB Configuration
MONGO_USERNAME=your_mongodb_username
MONGO_PASSWORD=your_mongodb_password

# JWT Configuration
JWT_SECRET=your_jwt_secret_key (or auto-generated if not provided)
JWT_EXPIRES_IN=7d (default: 7 days)

# SendGrid Email Configuration
SENDGRID_API_KEY=your_sendgrid_api_key
FROM_EMAIL=your_sender_email@example.com

# Google OAuth Configuration
CLIENT=your_google_oauth_client_id
SECRET=your_google_oauth_client_secret

# Server URLs
SERVER=http://localhost:3001
ORIGIN=http://localhost:3000
ORIGINTEST=http://localhost:3000 (optional, for testing)
CLIENT_URL=http://localhost:3000

Client Environment Variables (client/.env.local)

# Backend Server URL
NEXT_PUBLIC_SERVER=http://localhost:3001

# EmailJS Configuration (optional, for contact forms)
NEXT_PUBLIC_SERVICE_ID=your_emailjs_service_id
NEXT_PUBLIC_TEMPLATE_ID=your_emailjs_template_id
NEXT_PUBLIC_PUBLIC_KEY=your_emailjs_public_key

Note: Create .env file in the server directory and .env.local file in the client directory with the above variables.

Quick Start (Recommended)

Use the provided start.sh script to automatically start both client and server:

# Make the script executable (first time only)
chmod +x start.sh

# Run the application
./start.sh

The script will:

  • βœ… Check and install dependencies for both client and server
  • βœ… Build the TypeScript server code
  • βœ… Start the Express.js server on port 3001
  • βœ… Start the Next.js client on port 3000
  • βœ… Handle graceful shutdown with Ctrl+C

Access the application:

Manual Setup

If you prefer to run the services separately:

Frontend

  1. Navigate to the client folder:
    cd client
  2. Install dependencies:
    npm install
  3. Create a .env.local file with required environment variables
  4. Start the development server:
    npm run dev
    The client will run on http://localhost:3000

Backend

  1. Navigate to the server folder:
    cd server
  2. Install dependencies:
    npm install
  3. Create a .env file with required environment variables
  4. Build the TypeScript code:
    npm run build
  5. Start the backend server:
    npm run start
    The server will run on http://localhost:3001

Setting Up Admin Access

To grant admin access to a user, update the user's isAdmin field in MongoDB:

// Using MongoDB shell or MongoDB Compass
db.users.updateOne(
  { email: "admin@example.com" },
  { $set: { isAdmin: true } }
)

Or use MongoDB Atlas interface to update the user document directly.

Once a user has isAdmin: true, they can:

  • Access the admin dashboard at /admin
  • View all analytics and audit logs
  • Monitor user activities in real-time

πŸ”’ Authentication

FeedRecap uses JWT (JSON Web Tokens) for stateless authentication, providing secure and scalable user authentication.

Authentication Methods

1. Email-Based Authentication

  • Sign Up: Users register with email and password

    • Two-step email verification (OTP) required for account creation
    • Password is hashed using bcrypt before storage
    • JWT token issued upon successful registration
  • Sign In: Users sign in with email and password

    • Credentials verified against MongoDB
    • JWT token issued upon successful authentication

2. Google OAuth Authentication

  • Users can sign up or sign in using their Google account
  • OAuth flow handled via Passport.js Google Strategy
  • JWT token issued after successful OAuth authentication
  • New users are automatically created with default settings

JWT Implementation

Backend (Server)

  • Token Generation:

    • Tokens are signed with userId and email in the payload
    • Default expiration: 7 days (configurable via JWT_EXPIRES_IN)
    • Secret key stored in environment variable JWT_SECRET
    • Issuer: "feedrecap"
  • Token Verification:

    • authenticateJWT middleware protects authenticated routes
    • Validates token signature and expiration
    • Extracts user information from token payload
    • Attaches user data to request object for route handlers
  • Protected Routes:

    • /data - Fetch user dashboard data
    • /updateProfiles - Update custom Twitter profiles
    • /updateFeedType - Change feed type (category/custom)
    • /updateCategories - Update selected categories
    • /getIsNewUser - Check if user is new
    • /getUserDetails - Get user account details
    • /updateAccount - Update account information
    • /check-session - Validate current session
    • /unlinkX - Unlink Twitter account
    • And more...

Frontend (Client)

  • Token Storage:

    • JWT tokens stored in localStorage as token
    • Persists across browser sessions
    • Automatically removed on logout or expiration
  • Token Usage:

    • Axios interceptor automatically adds Authorization: Bearer <token> header to all API requests
    • Token validated on app initialization
    • Automatic redirect to sign-in page on token expiration (401 errors)
  • Token Management:

    • Token retrieved from URL parameters after OAuth redirects
    • Token validated via /check-session endpoint
    • Email extracted from token for user context

Security Features

  • βœ… Password hashing with bcrypt (10 salt rounds)
  • βœ… JWT token expiration (default 7 days)
  • βœ… Token signature verification
  • βœ… CORS protection with origin validation
  • βœ… Request origin/referer validation
  • βœ… Automatic token cleanup on expiration
  • βœ… Secure HTTP-only token handling

Authentication Flow

  1. Login/Registration β†’ Server validates credentials β†’ JWT token generated
  2. Token Storage β†’ Frontend stores token in localStorage
  3. API Requests β†’ Axios interceptor adds token to Authorization header
  4. Route Protection β†’ Backend middleware validates token
  5. Token Expiration β†’ Frontend detects 401 β†’ Removes token β†’ Redirects to sign-in

πŸ“š Routes

Frontend Routes (Client)

Route Description Auth Required
/ Homepage No
/signin User sign-in page No
/signup User sign-up page No
/aboutus Learn more about FeedRecap No
/samplenewsletter Preview a sample newsletter No
/dashboard User dashboard with 3 tabs: Yes (JWT)
- Newsfeed: View top tweets
- Latest Newsletter: Access recent
- Settings: Manage preferences
/readnewsletter Read newsletter by ID No
/unsubscribe Unsubscribe from newsletters No
/admin Admin dashboard with analytics Yes (Admin)

Backend API Routes (Server)

Route Method Description Auth Required
/login POST Email/password login No
/register POST User registration No
/logout POST User logout Yes (JWT)
/check-session GET Validate JWT token Yes (JWT)
/data GET Get user dashboard data Yes (JWT)
/updateProfiles POST Update custom Twitter profiles Yes (JWT)
/updateFeedType POST Change feed type (category/custom) Yes (JWT)
/updateCategories POST Update selected categories Yes (JWT)
/updateTimes POST Update newsletter delivery times Yes (JWT)
/updateAccount POST Update user account details Yes (JWT)
/getUserDetails GET Get user account information Yes (JWT)
/getIsNewUser GET Check if user is new Yes (JWT)
/newsletter/:id GET Get newsletter by ID No
/sentOTP POST Send OTP for email verification No
/resetPassword POST Reset user password No
/validateEmail GET Check if email exists No
/saveX POST Link Twitter account No
/unlinkX POST Unlink Twitter account Yes (JWT)
/auth/google/signup GET Google OAuth sign-up No
/auth/google/signin GET Google OAuth sign-in No
/auth/google/callback GET Google OAuth callback No
/logPageVisit POST Log page visit Yes (JWT)
/logLinkClick POST Log link click Yes (JWT)
/logFeedback POST Log feedback submission Yes (JWT)
/admin/analytics/pageviews GET Get page views analytics Yes (Admin)
/admin/analytics/linkclicks GET Get link clicks analytics Yes (Admin)
/admin/analytics/activities GET Get activity statistics Yes (Admin)
/admin/audit-logs GET Get all audit logs (live feed) Yes (Admin)
/admin/users GET Get all users and metrics Yes (Admin)

🌟 Why Use FeedRecap?

  • AI-Driven: Save time by getting top tweets curated with AI (Gemini AI).
  • Personalized: Choose your favorite categories or custom Twitter profiles.
  • Engaging Content: Access newsletters with trending tweets and easily share them with friends.
  • Seamless Dashboard: Stay updated with a user-friendly dashboard.
  • Effortless Automation: Newsletters and updates are automated with Node Cron.
  • Secure Authentication: JWT-based stateless authentication for scalability and security.
  • Multiple Auth Options: Sign in with email or Google OAuth.
  • Easy Setup: One-command startup with start.sh script.
  • Comprehensive Audit Logging: Track all user activities for security and analytics.
  • Admin Dashboard: Powerful analytics dashboard with visualizations and real-time activity monitoring.

πŸ”‘ Keywords

AI-powered-newsletter personalized-newsletters Twitter-curation top-tweets trending-news AI-curated-content category-based-news custom-twitter-profiles AI-news-delivery tech-newsletters sports-newsletters finance-newsletters politics-newsletters Next.js React Express.js MongoDB TypeScript Google-OAuth Vercel SendGrid JWT-authentication newsletter-app social-media-curation open-source news-dashboard feedrecap curated-tweets trending-topics Axios Node-Cron Gemini-AI automation JWT-tokens stateless-authentication personalized-content AI-newsletter-platform generative-AI-tech time-based-newsletters tweet-curation-tools Twitter-news-integration news-sharing-platform newsletter-dashboard curated-news-updates Twitter-profile-suggestions category-based-curation breaking-news-aggregator AI-newsletter-software JWT-based-auth custom-profile-news delivery-time-preferences trending-tweet-insights automation-with-cron MongoDB-database-newsletter AI-driven-social-curation tailored-newsletters Google-OAuth-authentication React-front-end social-media-newsletters Gemini-AI-integration analytics-for-newsletters SendGrid-email-integration efficient-newsletter-system curated-social-updates open-source-newsletter-platform audit-logging admin-dashboard user-activity-tracking analytics-dashboard activity-monitoring user-analytics page-visit-tracking link-click-analytics real-time-monitoring admin-panel user-management-dashboard


πŸ›‘οΈ License

This project is licensed under the MIT License. See the LICENSE file for details.


🌟 How to Contribute

  1. Fork the repository.
  2. Create a new branch:
    git checkout -b feature/YourFeatureName
  3. Commit your changes:
    git commit -m 'Add some feature'
  4. Push to the branch:
    git push origin feature/YourFeatureName
  5. Open a pull request.

⭐ Support the Project

If you like this project, please consider starring 🌟 the repository on GitHub to support its growth and visibility!


πŸ“§ Contact

For questions or suggestions, feel free to reach out:

About

FeedRecap: AI-powered platform for personalized newsletters πŸ“© featuring top tweets 🐦 on trending topics like Politics, Tech, Sports, and Finance πŸ’Ό. Follow categories or custom Twitter profiles for curated content πŸ“°. Built with Next.js, Node.js, Express.js, MongoDB, TypeScript

Topics

Resources

License

Stars

Watchers

Forks

Contributors

Languages