bradmca/pulse-tag-c-sharp
C# implementation of PulseTag, an intelligent social media utility designed to maximize post engagement through AI-driven trend analysis. It bridges the gap between content creation and discovery by analysing social media posts in real-time and generating optimized hashtag strategies.
PulseTag - AI-Driven Hashtag Generator (.NET)
A powerful web application built with .NET 10 that analyzes your social media posts in real-time, suggesting the top trending hashtags to maximize post reach and engagement. Perfect for influencers and marketers who want to stay ahead of the trend curve.
๐ Features
- ๐ค AI-Powered Analysis: Uses OpenRouter AI to analyze post content and generate relevant hashtags
- ๐ฑ Multi-Platform Support: Works with LinkedIn, Twitter/X, and general web content
- ๐ Secure: Implements SSRF protection, input sanitization, and secure API key handling
- โก High Performance: Built with ASP.NET Core and Blazor for optimal performance
- ๐ณ Docker Support: Fully containerized for easy deployment
- ๐งช Tested: Comprehensive unit tests with xUnit
- ๐ CI/CD Ready: GitHub Actions workflow for automated testing and deployment
๐๏ธ Architecture
Tech Stack
- Backend: ASP.NET Core 10 Web API
- Frontend: Blazor Web App (Server-Side Rendering)
- AI Integration: OpenAI SDK with OpenRouter
- Web Scraping: Playwright for .NET
- Testing: xUnit with Moq
- Containerization: Docker & Docker Compose
- CI/CD: GitHub Actions
Solution Structure
PulseTag/
โโโ src/
โ โโโ PulseTag.Api/ # Web API
โ โโโ PulseTag.Web/ # Blazor Frontend
โ โโโ PulseTag.Shared/ # Shared Models
โโโ tests/
โ โโโ PulseTag.Api.Tests/ # Unit Tests
โโโ .github/workflows/ # CI/CD Pipelines
โโโ docker-compose.yml # Docker Compose Configuration
โโโ PulseTag.sln # Solution File
๐ Quick Start
Prerequisites
- .NET 10.0 SDK
- Docker (optional)
- OpenRouter API Key (free at openrouter.ai)
Local Development
-
Clone the repository
git clone https://github.com/bradmca/pulse-tag-c-sharp.git cd pulse-tag -
Set up configuration
Create
src/PulseTag.Api/appsettings.Development.json:{ "OpenRouter": { "ApiKey": "your-openrouter-api-key", "Model": "microsoft/phi-3-medium-128k-instruct:free" }, "LinkedIn": { "Cookies": "your-linkedin-cookies-optional" } } -
Run the solution
# Run both API and Web dotnet run --project src/PulseTag.Api dotnet run --project src/PulseTag.Web -
Access the applications
For Docker deployment:
- Frontend: http://localhost:3000
- API: http://localhost:8000
- API Documentation: http://localhost:8000/swagger
For local development:
- Frontend: https://localhost:5001
- API: https://localhost:8000
- API Documentation: https://localhost:8000/swagger
Docker Deployment
-
Using Docker Compose
# Create .env file with your configuration cp .env.example .env # Edit .env with your API keys # Run with Docker Compose docker-compose up -d
-
Access the applications
- Frontend: http://localhost:3000
- API: http://localhost:8000
๐ API Documentation
Analyze Endpoint
POST /api/analyze
Content-Type: application/json
{
"url": "https://linkedin.com/posts/example"
}Response:
{
"originalText": "Your post content...",
"hashtags": {
"safe": ["Marketing", "Business"],
"rising": ["GrowthHacking", "GenAI"],
"niche": ["B2BMarketingTips"]
}
}Health Check
GET /api/health๐ง Configuration
Environment Variables
| Variable | Description | Default |
|---|---|---|
OpenRouter__ApiKey |
OpenRouter API key | Required |
OpenRouter__Model |
AI model to use | microsoft/phi-3-medium-128k-instruct:free |
LinkedIn__Cookies |
LinkedIn cookies for authenticated access | Optional |
AllowedOrigins |
CORS allowed origins | http://localhost:3000 |
ApiBaseUrl |
API base URL for frontend | http://localhost:8000 |
Supported Platforms
- LinkedIn: Works with public posts. Use cookies for private posts.
- Twitter/X: Requires individual tweet URLs (must contain
/status/). - General Websites: Can extract content from most web pages.
๐งช Testing
Run the test suite:
# Run all tests
dotnet test
# Run tests with coverage
dotnet test --collect:"XPlat Code Coverage"๐ Deployment
Production Deployment
-
Environment Setup
# Create production settings cp src/PulseTag.Api/appsettings.json src/PulseTag.Api/appsettings.Production.json # Update with production values
-
Docker Deployment
# Build and deploy docker-compose -f docker-compose.yml -f docker-compose.prod.yml up -d -
Kubernetes
# Apply Kubernetes manifests kubectl apply -f k8s/
๐ Security Features
- SSRF Protection: URL validation to only allow approved domains
- Input Sanitization: Prevents prompt injection attacks
- Secure Headers: CORS, CSP, and other security headers
- Rate Limiting: Built-in rate limiting capabilities
- No Hardcoded Secrets: All secrets via environment variables
๐ค Contributing
- 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 at https://github.com/bradmca/pulse-tag-c-sharp
๐ License
This project is licensed under the MIT License - see the LICENSE file for details.
๐ Acknowledgments
- OpenRouter for providing free AI model access
- Playwright for reliable web scraping
- Blazor for the modern web framework
- .NET for the powerful runtime
๐ Support
If you have any questions or issues, please open an issue on GitHub.
โญ If this project helps you, please give it a star!