Enterprise-grade file storage and management API with comprehensive analytics
A modern, scalable file storage microservice with real-time analytics, unlimited file uploads, and dual database support
π Quick Start β’ π Analytics β’ π³ Docker β’ π Documentation
- Unlimited File Uploads - No size restrictions, optimized for large files
- Universal File Support - Store any file type with metadata
- RESTful API - Clean, intuitive endpoints with OpenAPI/Swagger documentation
- File Management - Upload, download, view, update, and delete operations
- Tagging System - Organize files with custom tags and descriptions
- Real-time Download Tracking - Automatic monitoring of all file operations
- Interactive Dashboard - Beautiful web interface with live statistics
- Usage Insights - Popular files, download trends, user behavior analytics
- Comprehensive Metrics - Total downloads, data transfer, daily patterns
- Historical Data - Detailed download history with user agent and IP tracking
- Dual Database Support - MongoDB for scale, LiteDB for simplicity or EntityFramework with your favourite database
- Docker Ready - Self-contained deployment or traditional MongoDB setup
- Production Optimized - Health checks, logging, security best practices
- Microservice Architecture - Clean separation of concerns, testable codebase
Zero configuration, fully self-contained deployment:
# Linux/Mac
./run-standalone.sh
# Windows
run-standalone.batβ What you get:
- π― Zero Dependencies - No MongoDB installation required
- π¦ Single Container - Everything runs in one container
- πΎ Embedded Database - Uses LiteDB or SQLite for data storage
- π Persistent Storage - Data survives container restarts
- π Instant Access - API available at
http://localhost:5100
Traditional setup with MongoDB and MongoDB Express:
docker-compose up -dAccess Points:
- π API:
http://localhost:5100 - π Analytics:
http://localhost:5100/analytics.html - ποΈ MongoDB Express:
http://localhost:8081
# Clone and setup
git clone <repository-url>
cd FilesAPI_9-master
# Restore dependencies
dotnet restore
# Build solution
dotnet build
# Run with LiteDB (recommended for development)
USE_EMBEDDED_DATABASE=true dotnet run --project FilesAPI
# Or run with MongoDB (requires MongoDB running)
dotnet run --project FilesAPIAccess the beautiful analytics dashboard at: http://localhost:5100/analytics.html
Dashboard Features:
- π Overview Cards - Total downloads, files, data transferred
- π₯ Popular Files - Most downloaded files with metrics
- π Activity Trends - Daily download patterns and insights
- π Real-time Updates - Live data with refresh functionality
- π± Responsive Design - Works perfectly on all devices
GET /api/analytics/dashboard # Complete dashboard data
GET /api/analytics/statistics # Overall download statistics
GET /api/analytics/popular?count=10 # Most popular files
GET /api/analytics/daily?days=30 # Daily download statistics
GET /api/analytics/history/{fileId} # Download history for file
DELETE /api/analytics/cleanup?daysToKeep=365 # Cleanup old data- Download Metrics - Total downloads, file popularity, data transfer
- User Behavior - User agents, IP addresses, referrer tracking
- Temporal Patterns - Daily, weekly, monthly download trends
- File Analytics - Most popular files, download frequency
- Performance Data - Download completion rates, timing data
Perfect for production with zero external dependencies:
# docker-compose.standalone.yml
version: '3.8'
services:
filesapi:
build: .
ports:
- "5100:8080"
environment:
- USE_EMBEDDED_DATABASE=true
- ANALYTICS_ENABLED=true
volumes:
- filesapi_data:/app/data
- filesapi_uploads:/app/uploadsScalable setup with MongoDB:
# docker-compose.yml
version: '3.8'
services:
filesapi:
build: .
ports:
- "5100:8080"
environment:
- ANALYTICS_ENABLED=true
depends_on:
- mongodb
mongodb:
image: mongo:7.0
ports:
- "27017:27017"# Database Configuration
USE_EMBEDDED_DATABASE=true # Use LiteDB (true) or MongoDB (false)
DATABASE_PATH=/app/data/filesapi.db # LiteDB database path
UPLOADS_PATH=/app/uploads # File storage path
# Analytics Configuration
ANALYTICS_ENABLED=true # Enable/disable analytics
ANALYTICS_RETENTION_DAYS=365 # Days to keep analytics data
# Application Configuration
ASPNETCORE_ENVIRONMENT=Production # Environment mode
ASPNETCORE_URLS=http://+:8080 # Binding URLs| Database | Use Case | Pros | Cons |
|---|---|---|---|
| LiteDB | Development, Small-Medium Scale | Zero setup, Self-contained, Fast | Single file, Limited concurrency |
| MongoDB | Production, Enterprise Scale | High performance, Scalable, GridFS | Requires setup, External dependency |
# File Operations
POST /api/storage # Upload file
GET /api/storage/{id}/download # Download file
GET /api/storage/{id}/view # View file in browser
GET /api/storage # List all files
GET /api/storage/details/{id} # Get file details
PUT /api/storage/details/{id} # Update file details
DELETE /api/storage/{id} # Delete file
GET /api/storage/details/tags/{tag} # Get files by tag
# System Endpoints
GET /health # Health check
GET /swagger # API documentation
GET /analytics.html # Analytics dashboard# Upload file with metadata
curl -X POST \
-F "File=@document.pdf" \
-F "Description=Important document" \
-F "Tags=document,important" \
http://localhost:5100/api/storage# Download file
curl "http://localhost:5100/api/storage/{fileId}/download" \
-o downloaded-file.pdf
# View file in browser
curl "http://localhost:5100/api/storage/{fileId}/view"FilesAPI_9-master/
βββ π FilesAPI/ # Main web API project
β βββ Controllers/ # API controllers
β βββ wwwroot/ # Static files (analytics dashboard)
β βββ Program.cs # Application entry point
βββ π Services/ # Business logic layer
β βββ Repositories/ # Data access implementations
β βββ Events/ # Event handling system
βββ π Models/ # Data models and DTOs
βββ π Contracts/ # Interfaces and contracts
βββ π Services.Tests/ # Unit tests (NUnit)
βββ π³ Dockerfile # Container configuration
βββ π³ docker-compose.yml # Multi-container setup
βββ π Documentation/ # Additional docs
- Framework: .NET 10.0
- Databases: MongoDB 7.0, LiteDB 5.0.21
- API Documentation: Swashbuckle.AspNetCore 9.0.3
- Testing: NUnit 4.2.2
- Containerization: Docker & Docker Compose
- Frontend: Vanilla JavaScript, CSS3, HTML5
- Non-root Container - Runs as dedicated
appuser - Input Validation - Comprehensive request validation
- Error Handling - Graceful error responses
- CORS Support - Configurable cross-origin requests
- Health Checks -
/healthendpoint with database status - Structured Logging - Comprehensive application logging
- Metrics Ready - Analytics data for monitoring systems
- Docker Health Checks - Container health monitoring
- Unlimited File Uploads - No size restrictions
- Streaming Support - Efficient large file handling
- Database Indexes - Optimized queries for MongoDB
- Non-blocking Analytics - Zero impact on file operations
# Run all tests
dotnet test
# Run with coverage
dotnet test --collect:"XPlat Code Coverage"
# Build verification
dotnet build --configuration ReleaseTest Coverage:
- β Unit Tests: 6/6 passing
- β Integration Tests: API endpoints
- β Repository Tests: Database operations
- β Service Tests: Business logic
| Feature | Status | Description |
|---|---|---|
| π Analytics System | β Complete | Real-time download tracking with interactive dashboard |
| π« Unlimited Uploads | β Complete | Removed all file size limitations |
| π³ Docker Support | β Complete | Self-contained and traditional deployments |
| πΎ LiteDB Integration | β Complete | Embedded database with full feature parity |
| π₯ Health Monitoring | β Complete | Comprehensive health checks |
| π§ Environment Config | β Complete | Flexible database backend switching |
- β [Issue #1] File size limitation on upload
- β [Issue #3] Docker support implementation
- β [PR #8] Incomplete LiteDB implementation
- β MongoDB 3.4.1 Compatibility and GridFS integration
- β NUnit 4.x Migration and test framework updates
- β .NET 9.0 Framework upgrade and optimization
We welcome contributions! Please see our Contributing Guidelines for details.
- Fork the repository
- Clone your fork:
git clone <your-fork-url> - Create a feature branch:
git checkout -b feature/amazing-feature - Make your changes and add tests
- Test your changes:
dotnet test - Commit your changes:
git commit -m 'Add amazing feature' - Push to your branch:
git push origin feature/amazing-feature - Create a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- π Documentation: DEPLOYMENT.md | ANALYTICS.md
- π Issues: GitHub Issues
- π¬ Discussions: GitHub Discussions
β Star this repository if you find it useful!
Built with β€οΈ using .NET 10.0