From 10dab97d91411b855892fb6b6513dd860ccd014e Mon Sep 17 00:00:00 2001 From: Giovanni Rezcjikov Date: Fri, 6 Feb 2026 21:12:33 +0300 Subject: [PATCH] readme added --- README | 119 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 119 insertions(+) create mode 100644 README diff --git a/README b/README new file mode 100644 index 0000000..13010fd --- /dev/null +++ b/README @@ -0,0 +1,119 @@ +# Link Shortener + +A simple and fast URL shortener service built with Go and Redis. + +## Features + +- Shorten long URLs into compact short links +- Redirect short links to original URLs +- 30-day expiration for stored links + +## Getting Started + +### Prerequisites + +- Docker and Docker Compose + +### Installation & Running + +1. Clone the repository: +```bash +git clone https://github.com/dusiburg/link-shortener +cd link-shortener +``` + +2. Start the application with docker compose: +```bash +docker compose up +``` + +The service will be available at `http://localhost:8080` + +## API Endpoints + +### Create Short Link + +**Request:** +``` +GET /l/{original-url} +``` + +**Example:** +```bash +curl "http://localhost:8080/l/https://example.com/very/long/url" +``` + +**Response:** +```json +{ + "status": "success", + "short_link": "http://localhost:8080/r/abc123xyz", + "original_link": "https://example.com/very/long/url", + "expires_in": "30d" +} +``` + +### Redirect to Original Link + +**Request:** +``` +GET /r/{short-id} +``` + +**Example:** +```bash +curl "http://localhost:8080/r/abc123xyz" +``` + +This will redirect to the original URL. + +### Health Check + +**Request:** +``` +GET /ping +``` + +**Response:** +```json +{ + "status": "success" +} +``` + +## Configuration + +Environment variables can be set via `.env` file or docker compose: + +- `SERVER_HOST` - Server host (default: `localhost`) +- `SERVER_PORT` - Server port (default: `8080`) +- `REDIS_URL` - Redis connection URL (required) + +## Project Structure + +``` +. +├── cmd/ +│ └── main.go # Application entry point +├── internal/ +│ ├── config/ # Configuration management +│ ├── db/ # Database connections +│ ├── handlers/ # HTTP request handlers +│ ├── http/ # HTTP server setup +│ ├── repositories/ # Data access layer +│ └── services/ # Business logic +├── docker-compose.yml # Docker Compose configuration +├── Dockerfile # Multi-stage Docker build +└── README # This file +``` + +## Development + +To build locally without Docker: + +```bash +go build -o bin/application ./cmd +./bin/application +``` + +Make sure Redis is running before starting the application. \ No newline at end of file