"onepixel" is an API-first URL shortener.
A URL shortener should have a short domain name, possibly 2 or 3 letter in length.
"1 pixel" is the smallest unit of a screen.
So 1px.li
stands for one pixel links
- i.e. smallest possible links :)
The latest version of the code is automatically deployed via Railway
to
https://onepixel.link
You can deploy your own instance too
There are two databases used in this project
- Application DB
This stores users, shortlinks and link groups - Events/Analytics DB
This stores every redirection event used for analytics and stats
Purpose | Database |
---|---|
Application DB | PostgreSQL |
Events DB | Clickhouse |
For tests on CI it is better to use small embedded databases instead of spinning up a full database server.
Purpose | Database |
---|---|
Application DB | SQLite |
Events DB | DuckDB |
Note
You can also override .onepixel.local.env
to use
the embedded databases for local development
but they are not recommended for production use.
Simplest way to get it running is
- make a
./data
directory where your database will be stored - run
docker-compose up
We will use docker to run an instance of our databases, but we will run the project using air locally
- make the following directories where your database will be stored
./data
for postgres./clk_data
for clickhouse./clk_logs
for clickhouse logs
- run
docker-compose up -d postgres clickhouse
- run
air
in the root directory of the project 1
We will be using the embedded databases for local development without docker
- Make the following changes in
.onepixel.local.env
DB_DIALECT=sqlite DATABASE_URL="app.db" USE_FILE_DB=true EVENTS_DB_DIALECT=duckdb EVENTDB_URL="events.db"
- run
air
in the root directory of the project 1
Note[1]: you can also run
go run src/main.go
but it will not reload on changes