I was curious about how overengineered a Todo list (everyone's loved and hated) can be
I guess it's something similar to LinkTree. Hosted on railway
The idea started with "why tf do you need to pay LinkTree for analytics and fancy features" it's an overbloated next.js app + gatsby site (it has gotten much slower over the years) and the project itself its a 1 person product can be built in 3 days (I meant about 72 hours).
And it was.
- Chi for backend.
- templ as frontend to give me an experience similar to React (not quite xd)
- htmx (just a little bit)
- Alpine for interactivity.
- ent the only ORM and query builder in Golang feels like drizzle in Golang
- Sentry for error monitoring.
- AxiomFM for analytics (not sure might change later). At the moment see current implementation details in
pkg/monitor/axiom.go
oh yeah, and a docker compose file to help me (or you) to scaffold database during development.
git clone git@github.com:zmzlois/LinkGoGo.git
cd LinkGoGo
cp .env.example .env
pnpm run dev
see environment variables to find where you can obtain values for this project.
pnpm run dev
is a built in pipeline to run all modules and update templ generationg concurrently. See package.json
for what's inside this command
Alternatively if you need to start with a Postgres database you can do a docker compose up -d
. It will
- Start the app
- Start a Postgres database (If you wish to disable this, comment out sections according to the
docker-compose.yml
file)
The implementation details can be seen in
- pkg/auth
- The client struct is first defined in entry.go and client is used as a receiver in most of the function to help functions to access client credentials and exchanging with discord api to obtain other necessary values (access token, refresh token, oauth url etc )
- pkg/handler/oauth_callback.go
To obtain credentials for this project you will need
- An Axiom account
- A Sentry account
- A Discord app registered in development portal
- URL
- The url you are running it. Might be `http://localhost:3000` or `https://linkgogo.domain.com` depends on how you will run it in production.
- Environment
- This value is used by Sentry to understand whether the error happened in `production` or `development`. See [Sentry guide](https://docs.sentry.io/platforms/go/configuration/environments/) for how this works.
- PORT
- On convention it's either `:3000` or `:8080`. Remember to put a colon!!!
- DB_HOST
- If you are using docker compose the value would be `localhost`
- DB_PORT, DB_USER, DB_PASSWORD, DB_NAME
- You can modify these values in docker-compose.yml
- JWT_SECRET_KEY
- You can generate one by `openssl rand -hex 32` or other commands. See more about the required secret key standards on [jtw.io](https://jwt.io/introduction)
- AXIOM_TOKEN
- Find this value on your organisation's setting page `API token` tab.
- AXIOM_ORG_ID
- Copy paste the string under your organisation's name on setting page (there is a copy pasta button!!!)
- DISCORD_APPLICATION_ID, DISCORD_PUBLIC_KEY
- Required. You should find the values on your application's `General Information` page
- DISCORD_CLIENT_ID
- Required. Find this on `OAuth2` tab.
- DISCORD_CLIENT_SECRET
- Required. Generate this value on `OAuth2` tab.
- DISCORD_REDIRECT_URI
- Required. If you are developing locally the url would be `http://localhost:port/discord-callback` (please don't add `s` in http it will cause redirection failure). If you are deployed to production with SSL it should be `https://domain.com/discord-callback`. Other than providing it in `.env` file you will also need to configure this value on application's `OAuth2` tab.
- DISCORD_OAUTH_URL
- Optional. You don't need to provide this value because the `Auth` package helps you generate this based on values above and the scope you selected.
- Scopes (see in `pkg/auth/entry.go` and `pkg/auth/scope.go`)
- A list of scopes(string value) seperated by space.
- Sentry DSN
- Once you register your sentry account, sentry will ask you for a language and the dsn value will be provided in the documentation + setting page.
- OAuth
- At the moment OAuth package is customised for discord authentication, but it should be rewritten to fit standard OAuth authentication by providing different credentials and scope
- Logging
- The logging