How miccaaz/url-shortener-api works
This is a small ASP.NET URL-shortening service. A client submits a URL to the shorten endpoint; the endpoint validates it, asks the code-generation service for an unused code, and stores a shortened-URL record. A later request looks up that code and redirects the client to the original URL. The excerpts show EF Core persistence configured for PostgreSQL and development-time migration application. The README documents no additional capabilities; migrations and configuration files were not sampled.
Main entry points: Program.cs Shorten endpoint · AppDbContext.cs EF context · UrlShortenerService.cs Code generator · MigrationExtension.cs Migration extension
Components 10
HTTP API
- Shorten endpoint
UrlShortener.API/Program.cs - URL validation
UrlShortener.API/Program.cs - Redirect endpoint
UrlShortener.API/Program.cs
Shortening
- Shorten request
UrlShortener.API/Models/ShortenedUrlRequest.cs - Code generator
UrlShortener.API/Services/UrlShortenerService.cs - Short URL record
UrlShortener.API/Entities/ShortenedUrl.cs
Persistence
- EF context
UrlShortener.API/Infrastructure/AppDbContext.cs - PostgreSQL
- Migration extension
UrlShortener.API/Extensions/MigrationExtension.cs
Other components
- Client
Connections 15
- Client → Shorten endpoint: submits URL
UrlShortener.API/Program.cs - Shorten endpoint → Shorten request: binds request
UrlShortener.API/Program.cs - Shorten endpoint → URL validation: validates URL
UrlShortener.API/Program.cs - Shorten endpoint → Code generator: requests code
UrlShortener.API/Program.cs - Code generator → EF context: checks code
UrlShortener.API/Services/UrlShortenerService.cs - Shorten endpoint → Short URL record: creates record
UrlShortener.API/Program.cs - Shorten endpoint → EF context: saves record
UrlShortener.API/Program.cs - Redirect endpoint → EF context: looks up code
UrlShortener.API/Program.cs - Redirect endpoint → Client: redirects
UrlShortener.API/Program.cs - EF context → Short URL record: maps entity
UrlShortener.API/Infrastructure/AppDbContext.cs - Shorten endpoint → Client: returns short URL
UrlShortener.API/Program.cs - Shorten endpoint → PostgreSQL: configures provider
UrlShortener.API/Program.cs - Shorten endpoint → Migration extension: applies in development
UrlShortener.API/Program.cs - Migration extension → EF context: runs migrations
UrlShortener.API/Extensions/MigrationExtension.cs - Client → Redirect endpoint: requests code
UrlShortener.API/Program.cs