https://github.com/m4tx/shrt
Modern link shortener service written in Rust [WIP]
https://github.com/m4tx/shrt
Last synced: 10 days ago
JSON representation
Modern link shortener service written in Rust [WIP]
- Host: GitHub
- URL: https://github.com/m4tx/shrt
- Owner: m4tx
- License: agpl-3.0
- Created: 2024-04-04T22:13:42.000Z (about 2 years ago)
- Default Branch: master
- Last Pushed: 2026-04-02T06:48:45.000Z (3 months ago)
- Last Synced: 2026-04-02T20:21:47.737Z (3 months ago)
- Language: Rust
- Homepage:
- Size: 528 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
shrt
====
[](https://github.com/m4tx/shrt/actions/workflows/rust.yml)
[](https://github.com/m4tx/shrt/actions/workflows/docker-publish.yml)
[](https://github.com/m4tx/shrt/blob/master/LICENSE)
Shrt is a modern link shortener service written in Rust. It is designed to be fast, secure, and easy to use. It is composed of two parts: the backend, which is a RESTful API, and the frontend, which is a single-page application.
## Development
The project is written purely in [Rust](https://www.rust-lang.org/), both its backend and frontend.
### Backend
To run the development server, execute:
```shell
cd shrt-backend
cargo run
```
This will start the server at [localhost:8000](http://localhost:8000).
To build a release version, execute:
```shell
cargo build --release
```
The target binary will be put at `target/release/shrt-backend`.
### Frontend
Frontend uses the [yew](https://yew.rs/docs/getting-started/build-a-sample-app) framework. The code is compiled into a WebAssembly binary and then statically served.
First, install the [Trunk](https://trunkrs.dev/) bundler and add wasm32 target support to your Rust toolchain.
```shell
rustup target add wasm32-unknown-unknown
cargo install trunk
```
Then, you can use:
```shell
cd shrt-frontend
trunk serve
```
to start local server at [localhost:8080](http://localhost:8080). It assumes that the backend is running at [localhost:8000](http://localhost:8000).
To build a distributable version of the frontend, execute:
```shell
trunk build --release
```
This will build a website in `frontend/dist/` directory that can be statically served by a server such as nginx. You can override th backend URL by providing it as the `SHRT_API_URL` environment variable, like so:
```sh
export SHRT_API_URL=http://api.shrt.example.com
trunk build --release
```
#### `pre-commit`
We encourage contributors to use predefined [`pre-commit`](https://pre-commit.com/) hooks — to install them in your local repo, make sure you have `pre-commit` installed and run:
```shell
pre-commit install
```
## Deployment
The easiest way to try locally or deploy _shrt_ is to use auto-generated Docker images. There is a separate image for backend, frontend, and a reverse proxy (that exposes both the backend and frontend under the same server), all of which are published on [the GitHub Container Registry](https://github.com/m4tx?tab=packages&repo_name=shrt). There is an example `docker-compose.yml` file provided in the repository root.
In the project root directory, execute:
```shell
docker compose up -d
```
After that, the website will be available on at [localhost:8000](http://localhost:8000).