Live demo: https://fanficdownloader.com
Fanfic Downloader is a web service that downloads fanfics from supported websites and generates EPUB or TXT files.
The service provides:
- Web interface
- REST API
- Telegram bot integration
It is designed as a small production-ready service with a queue-based architecture to safely process downloads without overloading the server.
- Download fanfics as EPUB or TXT
- Web UI for quick downloads
- REST API for automation
- Telegram bot integration
- Queue-based download system
- Configurable concurrency
- Source-specific parsers
- Proxy rotation for ficbook.net requests
- Optional Cloudflare bypass via FlareSolverr
- PostgreSQL-backed cache metadata storage
- R2 object storage for cached TXT/EPUB files
- Cache-first download flow (reuse previously generated files)
- Docker deployment
- Nginx reverse proxy
- HTTPS via Let's Encrypt
- Health endpoint for monitoring
Currently supported fanfiction sites:
- ficbook.net (proxy-first, with FlareSolverr fallback)
- snapetales.com
- fanfiction.net (via FlareSolverr)
- walkingtheplank.org
Additional sources can be added by implementing new IFanficSource implementations.
Typical production architecture:
Internet
↓
Nginx (HTTPS / reverse proxy)
↓
ASP.NET Core (Kestrel)
↓
FanficDownloader service
↓
Download queue
↓
Fanfic parsers
↓
EPUB/TXT generation
Downloads are processed through an internal queue to:
- limit concurrency
- prevent server overload
- ensure stable performance
Backend
- .NET 10
- ASP.NET Core
- Kestrel web server
- Background services
Infrastructure
- Docker
- Nginx reverse proxy
- Let's Encrypt HTTPS
- FlareSolverr (optional)
FanficDownloader
FanficDownloader.Web
Controllers
DownloadController
QueueController
Services
DownloadQueueService
TelegramBotBackgroundService
Pages
Index.cshtml
Program.cs
DependencyInjection.cs
wwwroot
FanficDownloader.Application
Services
FanficDownloadService
FanficCacheService
ImageDownloadService
Configuration
DownloadSettings
FlareSolverrSettings
Security
UrlValidator
Models
DownloadFileResult
FanficDownloader.Core
Sources
FicbookSource
FanfictionNetSource
SnapetalesSource
WalkingThePlankSource
SourceManager
Parsers
FicbookParser
FanfictionNetParser
SnapetalesParser
WalkingThePlankParser
Formatting
FanficEpubFormatter
FanficTxtFormatter
Clients
FlareSolverrClient
Services
R2StorageService
ProxyService
ProxyState
Models
Fanfic
Chapter
DownloadResult
ImageInfo
FanficCacheEntry
FanficDownloader.Bot
Services
FanficService
Formatting
FanficTelegramFormatter
FanficDownloader.Tests
Parser tests
Formatter tests
Source tests
git clone https://github.com/YOUR_USERNAME/FanficDownloader.git
cd FanficDownloaderEdit:
FanficDownloader.Web/appsettings.json
Example configuration:
{
"Download": {
"MaxConcurrentDownloads": 2
},
"FlareSolverr": {
"Url": "http://localhost:8191"
}
}Optional: set Telegram bot token
TG_BOT_TOKEN=<your_token>
dotnet restore
dotnet run --project FanficDownloader.WebOpen in browser:
http://localhost:5000
Cloudflare-protected sources use FlareSolverr (fanfiction.net and ficbook.net fallback path).
Start FlareSolverr and ensure the URL matches the configuration.
Example:
http://localhost:8191
| Endpoint | Description |
|---|---|
| POST /download/info | Fetch fanfic metadata |
| POST /download/txt | Download TXT |
| POST /download/epub | Download EPUB |
| GET /queue/position | Queue position |
| GET /health | Health check |
The service exposes a simple health endpoint.
GET /health
Example:
https://fanficdownloader.com/health
Response:
OK
This endpoint can be used by:
- monitoring systems
- uptime checks
- container health checks
All downloads are processed through an internal queue.
This ensures that:
- only a limited number of downloads run simultaneously
- the server cannot be overloaded
- large downloads do not block the system
Concurrency is controlled via:
Download:MaxConcurrentDownloads
The service uses a cache layer to avoid rebuilding the same files repeatedly.
How it works:
- On TXT/EPUB request, the service checks PostgreSQL table
fanfic_cacheby:- source URL
- output format (
txtorepub)
- If a cache record exists, the file is downloaded from object storage (R2) and returned immediately.
- If no cache record exists, the fanfic is downloaded and generated normally.
- The generated file is uploaded to R2, and metadata is saved to PostgreSQL.
Cached metadata includes:
urltitleobject_keycreated_atformat
This approach reduces repeated parsing/formatting work and improves response time for repeated downloads.
PostgreSQL is used for cache metadata persistence (fanfic_cache table).
In Docker Compose, PostgreSQL is started as:
- service:
postgres - image:
postgres:16 - database:
fanficdownloader
Connection string is configured in appsettings.json:
"ConnectionStrings": {
"Postgres": "Host=localhost;Port=5432;Database=fanficdownloader;Username=postgres;Password=..."
}When running in containers, ensure the host and credentials match your compose/network setup.
The Telegram bot runs as a background service inside the web host.
If TG_BOT_TOKEN is set, the bot automatically starts when the application launches.
Typical production deployment:
- Docker container running the application
- PostgreSQL container for cache metadata
- (Optional) FlareSolverr container for Cloudflare-protected sources
- Nginx reverse proxy
- HTTPS via Let's Encrypt
- Optional Cloudflare DNS
Deployment workflow:
git push
↓
ssh server
↓
git pull
↓
docker compose up -d --build
dotnet test
Contributions are welcome.
If you'd like to contribute:
- Fork the repository
- Create a feature branch
git checkout -b feature/my-feature
- Implement your changes
- Add tests if applicable
- Commit and push
git commit -m "Add new feature"
git push
- Open a Pull Request
Please ensure that:
- the project builds successfully
- tests pass
- new features include tests when possible
The current web interface is intentionally minimal.
If you'd like to contribute improvements to the UI or create a better design, contributions are very welcome.
Frontend improvements, UI redesigns, and UX enhancements would be greatly appreciated.
Possible future features:
- rate limiting
- download size limits
- monitoring (CPU / memory)
- additional fanfiction sources
- UI improvements