NanoUrl is a web-based URL shortening service built using C# and the .NET framework, designed to provide a simple and secure way to create short URLs. The service includes features such as creating custom short URL, URL mapping retrieval, and redirection. It utilizes MongoDB for storing URL mappings, Azure Key Vault for securely managing secrets and Azure App Service for hosting the Web API.
- API Host: NanoUrl API
- Interactive API Documentation: Swagger UI for NanoUrl
- Example User Interface: NanoUrl Client UI
- Shorten URLs: Generate unique short URLs for any valid input URL
- Custom Short Codes: Create personalized short codes for URLs
- Redirect: Use short URLs to redirect user to the original URL
- Secure & Scalable: Implements Azure Key Vault for secure configuration and MongoDB for scalability
- Interactive Documentation: OpenAPI specification available with Swagger UI
- Backend: ASP.NET Core
- Database: MongoDB (hosted as a free MongoDB Atlas cluster)
- Security: Azure Key Vault for managing sensitive information (e.g., database connection strings)
- Hosting: Deployed on Azure App Service
- API Documentation: OpenAPI/Swagger interactive documentation here
- Example Client UI: HTML, CSS, and JavaScript, deployed on GitHub Pages here
HTTP Method | Endpoint | Description |
---|---|---|
GET |
/ |
Retrieve the base URL of the NanoUrl server |
GET |
/{shortCode} |
Redirect to the original URL associated with a short code |
GET |
/get/{shortCode} |
Fetch the original URL mapped to a specified short code |
POST |
/custom |
Create a custom short URL for a given long URL |
POST |
/shorten |
Generate a short URL for a given long URL |
-
Create a Short URL:
POST /shorten Content-Type: application/json "https://example.com"
Response:
"nan1.azurewebsites.net/abc123"
-
Create a Custom Short URL:
POST /custom Content-Type: application/json { "id": "this_field_is_optional", "original": "https://www.verylongurl.com/subdomain0/subdomain1", "shortCode": "myUrl" }
Response:
"nan1.azurewebsites.net/myUrl"
-
The live version of the API is hosted on Azure and can be accessed at: https://nan1.azurewebsites.net
-
Interactive API Documentation: The OpenAPI specification, deployed with Swagger UI, is available here. Use this to explore and test the API endpoints interactively.
- Client UI: A basic user interface for interacting with the API is available here. This is to demonstrate how users/developers can integrate their own UI to use NanoUrl API.
- Critical configurations such as connection strings are securely stored in Azure Key Vault.
- The API enforces HTTPS for all requests.
This project demonstrates:
- Cloud Integration: Use of Azure services like App Service and Key Vault.
- Scalable Database: Integration with MongoDB Atlas for efficient data storage.
- API Best Practices: Follows RESTful principles with OpenAPI documentation.
- Full-Stack Knowledge: Implements backend development with C# and .NET and a front-end interface.
- Add analytics to track usage statistics for shortened URLs.
- Improve error handling and user-friendly response messages.
This project is licensed under the MIT License.