A powerful, intelligent tool that transforms long-form content into engaging X (Twitter) threads with dual-language support and smart hashtag generation.
X Thread Generator is a sophisticated web application designed to convert long-form articles, blog posts, or notes into well-structured X (Twitter) threads. Built with a dual-audience strategy, it serves both Arabic-speaking developers interested in English tech content and global English-speaking users.
- π€ AI-Powered: Integrates with Google Gemini AI for intelligent content segmentation
- π Dual-Language: Native Arabic and English support with smart RTL/LTR handling
- π± Smart Hashtags: Dynamic hashtag generation with 70% English / 30% Arabic distribution
- π Privacy-First: No data collection, all processing happens locally
- β‘ Reliable: Comprehensive fallback system ensures 100% uptime
- π¨ Modern UI: Clean, responsive interface with dark mode support
- AI-Powered Segmentation: Uses Gemini AI for smart content breakdown
- Local Fallback: Template-based generation when AI is unavailable
- Unicode-Safe: Proper emoji and special character counting
- Smart Truncation: Respects word and sentence boundaries
- Arabic Interface: Native RTL support for Arabic-speaking users
- English Interface: Global accessibility with LTR layout
- Technical Content: APIs and documentation remain in English for consistency
- Auto-Detection: Intelligent language detection based on user preferences
- Content-Aware: Analyzes text to suggest relevant hashtags
- Topic Detection: 11+ categories (AI, Programming, Business, Health, etc.)
- Hybrid Distribution: 70% English hashtags for global reach, 30% Arabic for local engagement
- No Duplicates: Thread-level deduplication ensures variety
- RESTful API: Complete API for programmatic access
- JSON Schema: Validated responses and requests
- Comprehensive Testing: Unit and integration test coverage
- Docker Ready: Easy deployment and scaling
- Node.js 16.0.0 or higher
- npm 8.0.0 or higher
- Google Gemini API Key (optional, for AI features)
-
Clone the repository
git clone https://github.com/yourusername/x-thread-generator.git cd x-thread-generator -
Install dependencies
npm install
-
Configure environment
cp .env.template .env # Edit .env with your settings (see Configuration section) -
Start the application
npm start
-
Access the application
Open http://localhost:3000 in your browser
Create a .env file based on .env.template:
# Server Configuration
PORT=3000
NODE_ENV=development
# AI Integration (Optional)
GEMINI_ENABLED=true
GEMINI_API_KEY=your_gemini_api_key_here
GEMINI_QUOTA_LIMIT=100
# Security & Limits
RATE_LIMIT_MAX_REQUESTS=100
MAX_INPUT_LENGTH=10000
MAX_TWEETS_PER_THREAD=20
# Logging
LOG_LEVEL=info
LOG_FILE_MAX_SIZE=10m- Visit Google AI Studio
- Generate your API key
- Add it to your
.envfile - Set
GEMINI_ENABLED=true
Note: The application works perfectly without Gemini AI using intelligent local templates.
- Navigate to http://localhost:3000
- Switch Language using the π toggle (Arabic/English)
- Paste Content in the text area
- Configure Options:
- Language: Auto-detect, Arabic, English, or Mixed
- Style: Educational, Professional, Technical, Engaging, or Concise
- Max Tweets: 1-20 tweets per thread
- Include hashtags and image suggestions
- Generate Thread and copy the results
curl -X POST http://localhost:3000/api/generate-thread \
-H "Content-Type: application/json" \
-d '{
"text": "Artificial Intelligence is revolutionizing how we work. Machine learning algorithms can now process vast amounts of data in seconds, enabling businesses to make data-driven decisions faster than ever before.",
"language": "auto",
"style": "educational",
"maxTweets": 3,
"includeHashtags": true
}'{
"metadata": {
"language": "en",
"direction": "ltr",
"tweets_generated": 3,
"style": "educational"
},
"thread": [
{
"index": 1,
"text": "π§΅ Let's learn something new today: Artificial Intelligence is revolutionizing how we work.",
"char_count": 95,
"hashtags": ["#AI", "#MachineLearning", "#Thread"]
},
{
"index": 2,
"text": "2/3 Machine learning algorithms can now process vast amounts of data in seconds, enabling businesses to make data-driven decisions faster than ever before.",
"char_count": 148,
"hashtags": ["#DataScience", "#Business"]
},
{
"index": 3,
"text": "3/3 Did you learn something new? Share this with someone who needs it! #Education #Learning #TechTrends",
"char_count": 103,
"hashtags": ["#Education", "#Learning", "#TechTrends"]
}
],
"estimated_engagement_score": 8.5
}βββββββββββββββββββ ββββββββββββββββββββ βββββββββββββββββββ
β Frontend β β Express API β β AI Services β
β β β β β β
β β’ Dual Language βββββΊβ β’ RESTful API βββββΊβ β’ Gemini AI β
β β’ Modern UI β β β’ Input Validationβ β β’ Local Fallbackβ
β β’ Real-time β β β’ Rate Limiting β β β’ Smart Templatesβ
βββββββββββββββββββ ββββββββββββββββββββ βββββββββββββββββββ
β
βΌ
ββββββββββββββββββββ
β Utilities β
β β
β β’ Hashtag Gen β
β β’ Char Counter β
β β’ Lang Detection β
β β’ Input Sanitizerβ
ββββββββββββββββββββ
βββ π config/ # Configuration files
β βββ constants.js # Application constants
β βββ languages.js # Language configurations
βββ π public/ # Frontend assets
β βββ index.html # Main UI
β βββ main.js # Frontend logic
β βββ languageManager.js # Dual-language system
βββ π services/ # Core business logic
β βββ geminiService.js # AI integration
β βββ hashtagGenerator.js # Dynamic hashtag system
β βββ localTemplates.js # Fallback generation
βββ π utils/ # Utility functions
β βββ charCounter.js # Unicode-safe counting
β βββ inputSanitizer.js # Input validation
β βββ langDetect.js # Language detection
β βββ dedupe.js # Deduplication logic
βββ π tests/ # Test suites
βββ π schemas/ # JSON schemas
βββ server.js # Express application
# Run all tests
npm test
# Run with coverage report
npm run test:coverage
# Watch mode for development
npm run test:watch
# Lint code
npm run lint- API Endpoints: Integration tests for all routes
- Utility Functions: Unit tests for character counting, language detection
- Hashtag Generation: Comprehensive testing of dynamic hashtag system
- Security: Input sanitization and validation tests
- Multi-Platform Support: LinkedIn, Instagram, Facebook thread generation
- Advanced AI: GPT-4 integration with custom fine-tuning
- Analytics Dashboard: Thread performance tracking
- Team Collaboration: Multi-user workspace
- Mobile App: React Native application
- Browser Extension: Chrome/Firefox extension
- Scheduling: Automated thread posting
- Templates: Pre-built thread templates
- Enterprise Features: SSO, team management
- API Marketplace: Third-party integrations
- Advanced Analytics: AI-powered insights
- White-label Solution: Customizable branding
We welcome contributions from developers worldwide! Please see our Contributing Guidelines for details.
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
# Clone your fork
git clone https://github.com/yourusername/x-thread-generator.git
# Install dependencies
npm install
# Start development server
npm run dev
# Run tests
npm testThis project is licensed under the MIT License - see the LICENSE file for details.
- Google Gemini AI for intelligent content processing
- Arabic Typography Community for RTL layout guidance
- Open Source Contributors who make projects like this possible
- LogicCrafterDZ for project development and maintenance
- π¦ Twitter: [@Arana_lib]
- π± Telegram: [t.me/LogicCrafterDZ]
- π§ Email: [logiccrafterdz@gmail.com]
- Issues: Report bugs via GitHub Issues
- Discussions: Join our GitHub Discussions
- Security: Report security issues privately via email
Empowering content creators worldwide