How bal16/link3 works
Link3 is a self-hosted URL-shortener API. Requests enter through the Elysia server and controller; link operations validate or generate slugs, query the repository, and return API responses or redirects. The README also documents paginated search, JWT-protected writes, and Scalar OpenAPI docs. The excerpts show the route-to-service-to-repository calls; database and documentation capabilities are corroborated by the README and server setup, while unsampled Prisma schema details are not expanded.
Main entry points: controller.ts Link routes · service.ts Link service · server.ts Elysia server · index.ts Application entrypoint
Components 15
API surface
- Elysia server
src/app/server.ts - Link routes
src/app/controller.ts - JWT verification
src/app/controller.ts - Request schemas
src/app/model/link.model.ts - Response model
src/app/model/web.model.ts
Link operations
- Link service
src/app/service.ts - Slug generation
src/app/service.ts - Search and pagination
src/app/service.ts - Short-link redirect
src/app/controller.ts
Persistence
- Prisma repository
src/app/repository.ts - PostgreSQL
Runtime and docs
- Application entrypoint
src/index.ts - Base URL config
src/const.ts - OpenAPI and Scalar
src/app/server.ts
Other components
- API client
Connections 18
- API client → Application entrypoint: sends requests
README.md - Application entrypoint → Elysia server: starts
src/index.ts - Elysia server → Link routes: mounts
src/app/server.ts - API client → Link routes: calls routes
README.md - Link routes → JWT verification: verifies writes
src/app/controller.ts - Link routes → Request schemas: validates bodies
src/app/controller.ts - Link routes → Link service: invokes operations
src/app/controller.ts - Link service → Slug generation: generates slugs
src/app/service.ts - Link service → Search and pagination: searches and pages
src/app/service.ts - Link service → Prisma repository: queries links
src/app/service.ts - Prisma repository → PostgreSQL: reads and writes
README.md - Link routes → Short-link redirect: resolves slug
src/app/controller.ts - Short-link redirect → Link service: gets target URL
src/app/controller.ts - Link service → Base URL config: builds short URLs
src/app/service.ts - Application entrypoint → Base URL config: logs address
src/index.ts - Link routes → Response model: returns envelopes
src/app/controller.ts - Elysia server → OpenAPI and Scalar: configures docs
src/app/server.ts - API client → OpenAPI and Scalar: opens UI
README.md