
Introduction
Wanting to deepen my understanding of Apache Tomcat and enterprise Java web architectures, I decided to create something practical that would force me to engage with various aspects of Tomcat deployment and configuration. Introducing RetroFeed, a proxy server that transforms Mastodon feeds into plain text for the terminal or text-only HTML for vintage computers.
The Project Concept
The idea: create a web application that would allow vintage computers running text-based browsers, or even curl on the command line, to read Mastodon feeds. This required not just implementing the Mastodon API integration, but also careful consideration of content delivery and compatibility with older HTTP clients.
You can find the project at: https://github.com/busrus/retrofeed/
Features
- Transforms rich Mastodon content into terminal-friendly text
- Handles boosts (reblogs) with proper attribution
- Displays image alt-text descriptions
- Smart content negotiation: serves HTML to browsers, plain text to curl
- Self-hosted on your local network
- Configurable for any Mastodon instance
Technical Architecture
The application is built on a multi-tier architecture:
- Presentation Layer
- Transforms modern social media content into HTML 2.0 compatible format
- Uses basic HTML elements for maximum compatibility
- Handles character encoding and content formatting
- Content negotiation based on User-Agent
- Application Layer (Tomcat)
- Servlet-based implementation
- Configuration management for API tokens
- Content transformation pipeline
- HTML/plain text rendering logic
- Integration Layer
- Mastodon API client
- Content fetching and parsing
- Error handling
Why Tomcat?
While this could have been implemented using lighter-weight frameworks, using Tomcat provided several learning opportunities:
- Servlet lifecycle management
- WAR file deployment
- Container configuration
- Security settings
- Multi-tier architecture design
- Proxy configuration
Key Learning Points
1. Servlet Configuration
I learned how to properly structure a web application’s deployment descriptor (web.xml) and how to use annotations for servlet mapping.
2. Configuration Management
One interesting challenge was securing the Mastodon API token. This led to implementing a configuration service that loads settings from an external file, keeping sensitive data outside the WAR file.
3. Content Type Handling
Perhaps the most interesting technical challenge was ensuring compatibility with both modern and vintage clients. This required careful attention to User-Agent detection and content type handling:
String userAgent = request.getHeader("User-Agent");
boolean isCurl = userAgent != null && userAgent.toLowerCase().contains("curl");
if (isCurl) {
response.setContentType("text/plain; charset=UTF-8");
} else {
response.setContentType("text/html; charset=UTF-8");
}
4. Apache Integration
Apache is configured as a reverse proxy:
ProxyPass /retrofeed http://localhost:8080/retrofeed
ProxyPassReverse /retrofeed http://localhost:8080/retrofeed
Challenges and Solutions
- Vintage Browser Compatibility
- Challenge: Modern web standards don’t work with vintage browsers
- Solution: Implemented strict HTML 2.0 compliance and proper content type handling
- Security
- Challenge: Protecting API tokens in a web application
- Solution: External configuration file with proper filesystem permissions
- Content Transformation
- Challenge: Converting modern social media content to text-only format
- Solution: Custom transformation pipeline with HTML sanitization
- Media Handling
- Challenge: Making image content accessible in text-only format
- Solution: Implemented alt-text display for images
Looking Forward
This project served as an excellent learning vehicle for understanding Tomcat’s architecture and configuration. It forced me to think about:
- Proper separation of concerns
- Security considerations
- Configuration management
- Content type handling
- Proxy configuration
- Backward compatibility
While a simpler framework might have been more appropriate for this specific use case, building it with Tomcat provided valuable experience with enterprise Java patterns and deployment scenarios.
Try It Yourself
The project is open source and available on GitHub. If you’re interested in learning about Tomcat or just want to read Mastodon on a vintage computer, feel free to check it out and contribute!
https://github.com/busrus/retrofeed
What started as a learning exercise turned into a functional project that not only helped me understand Tomcat better but also created something useful.