{"id":26657745,"url":"https://github.com/thedondope/wits","last_synced_at":"2025-07-18T07:03:11.671Z","repository":{"id":243253698,"uuid":"765935665","full_name":"TheDonDope/wits","owner":"TheDonDope","description":"Wits - The Weed Information Tracking System","archived":false,"fork":false,"pushed_at":"2025-07-08T22:50:18.000Z","size":1037,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-07-08T23:35:41.826Z","etag":null,"topics":["golang","htmx","supabase","templ"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/TheDonDope.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-03-01T23:02:35.000Z","updated_at":"2025-07-08T22:50:16.000Z","dependencies_parsed_at":"2024-06-20T09:58:44.587Z","dependency_job_id":"a13ef55b-9386-4f5d-94ed-c22b92186d48","html_url":"https://github.com/TheDonDope/wits","commit_stats":null,"previous_names":["thedondope/wits"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/TheDonDope/wits","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TheDonDope%2Fwits","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TheDonDope%2Fwits/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TheDonDope%2Fwits/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TheDonDope%2Fwits/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TheDonDope","download_url":"https://codeload.github.com/TheDonDope/wits/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TheDonDope%2Fwits/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265716278,"owners_count":23816354,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["golang","htmx","supabase","templ"],"created_at":"2025-03-25T09:16:32.550Z","updated_at":"2025-07-18T07:03:11.634Z","avatar_url":"https://github.com/TheDonDope.png","language":"Go","funding_links":["https://opencollective.com/daisyui"],"categories":[],"sub_categories":[],"readme":"# Wits - The 🥦 Information Tracking System\n\n[![codecov](https://codecov.io/gh/TheDonDope/wits/graph/badge.svg?token=QM1XTAUsfU)](https://codecov.io/gh/TheDonDope/wits)\n\nWits aims to help cannabis patients and users to manage and monitor their cannabis consumption and inventory.\n\n## Building the Application\n\nBuilding the binary requires multiple steps:\n\n- Compiling the Tailwind CSS output\n- Generating the Go code from the Templ Templates\n- Building the Go binary\n\nTo do this in one command, run the following:\n\n```shell\n$ make build\ncurl -L -o public/js/htmx.min.js https://unpkg.com/htmx.org@1.9.10/dist/htmx.min.js\n  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current\n                                 Dload  Upload   Total   Spent    Left  Speed\n100 47755    0 47755    0     0   216k      0 --:--:-- --:--:-- --:--:--  217k\ncp ./node_modules/jquery/dist/jquery.min.js public/js/jquery.min.js\ncp ./node_modules/font-awesome/css/font-awesome.min.css public/css/font-awesome.min.css\ncp ./node_modules/font-awesome/fonts/* public/fonts/\nnpx tailwindcss -i pkg/view/css/app.css -o public/css/styles.css\n\nRebuilding...\n\n🌼   daisyUI 4.7.2\n├─ ✔︎ 2 themes added  https://daisyui.com/docs/themes\n╰─ ❤︎ Support daisyUI project: https://opencollective.com/daisyui\n\n\nDone in 200ms.\ntempl generate view\n(✓) Complete [ updates=4 duration=23.351583ms ]\ngo build -v -o ./bin/wits ./cmd/server.go\n```\n\n## Building and pushing the container image\n\nAssuming the use of [Podman](https://podman.io/), the following steps are supported:\n\n### Building the latest local image\n\nYou can run `make build-image`.\n\n### Pushing the latest tag to GitHub Container Registry\n\n_Prerequisite_: Acquire a Personal Access Token (PAT) in your GitHub Account.\n\nThen, login with GHCR, like so:\n\n```bash\n$ echo $PAT | podman login ghcr.io --username \u003cYOUR_GITHUB_USERNAME\u003e --password-stdin\nLogin Succeeded!\n```\n\nNow, the latest local image can be pushed by running `make push-image`.\n\n## Running the Application\n\nWits can be run in two different flavours via environment variables, either `DB_TYPE=local` or `DB_TYPE=remote`. In the applications context, `local` means:\n\n- The application handles User login and registration itself\n- JWT tokens are self-signed and stored in an encrypted session cookie (using [gorilla/sessions](https://github.com/gorilla/sessions))\n- User data is stored in a Postgres database (the connection is configurable with environment variables, see below)\n- Domain data is stored in a Postgres database (the connection is configurable with environment variables, see below)\n\nIn contrast, `remote` means:\n\n- The application uses Supabase for User login and registration (including managing and storage of user data)\n- The user can also login with their Google account\n- JWT tokens are signed by Supabase and stored in an encrypted session cookie (using [gorilla/sessions](https://github.com/gorilla/sessions))\n- Domain data is stored in a Postgres database, hosted on Supabase (the connection is configurable with environment variables, see below)\n\n### Required Environment Variables\n\nA minimum viable `.env` file can be found at [.env.example](.env.example). Simply rename it to `.env` to be able to run the application with a Postgres database. Fill in the other values if you want to integrate with Supabase.\n\nThe following environment variables are required to run the application:\n\n| Environment Variable     | Description                                                                                                                                   |\n| ------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------- |\n| `HTTP_LISTEN_ADDR`       | The address the server runs at (format: `\u003curl\u003e:\u003cport\u003e`, example: `127.0.0.1:3000`)                                                            |\n| `LOG_LEVEL`              | The level at which to log (one of: `DEBUG`, `INFO`, `WARN`, `ERROR`, `OFF`)                                                                   |\n| `LOG_DIR`                | The path to the directory for the application logs                                                                                            |\n| `LOG_FILE`               | The name of the file for the application logs (within `LOG_DIR`)                                                                              |\n| `ACCESS_LOG_FILE`        | The path of the file for the application access logs (within `LOG_DIR`)                                                                       |\n| `JWT_SECRET_KEY`         | The secret key with which to sign the access token (only relevant for `DB_TYPE=local`)                                                        |\n| `JWT_REFRESH_SECRET_KEY` | The secret key with which to sign the refresh (only relevant for `DB_TYPE=local`)token                                                        |\n| `SESSION_SECRET`         | The secret key with which to sign the cookie store session                                                                                    |\n| `DB_TYPE`                | The type of database to use (choose `local` for local Postgres db using Bun or `remote` for remote Postgres db using Bun and Supabase Client) |\n| `DB_HOST`                | The host of the Postgres db                                                                                                                   |\n| `DB_USER`                | The user of the Postgres db                                                                                                                   |\n| `DB_PASSWORD`            | The password of the Postgres db                                                                                                               |\n| `DB_NAME`                | The name of the Postgres db                                                                                                                   |\n| `SUPABASE_URL`           | The Supabase URL (required for the client configuration), when `DB_TYPE=remote`                                                               |\n| `SUPABASE_SECRET`        | The Supabase secret (required for the client configuration), when `DB_TYPE=remote`                                                            |\n| `AUTH_CALLBACK_URL`      | The callback URL for remote login, when `DB_TYPE=remote`                                                                                      |\n\n### Required Database\n\nWits requires a Postgres database to run. The connection details are configurable via environment variables (see above). For local deployment and testing, kubernetes resources for the database and application are provided in the `k8s` folder. In the [Makefile](Makefile) you can spin those up with `$ make k8s-up`. It can be brought down with `$ make k8s-down` . **Note**: Currently, bringing the database down also deletes all data. This behaviour is subject to change.\n\nThese commands requires [kubectl](https://kubernetes.io/docs/tasks/tools/install-kubectl/) to be installed on your machine.\n\n**Important**: Make sure to create the secret for the database credentials, like so:\n\n```shell\nkubectl create secret generic postgres-credentials --from-literal=user=\u003cyour-user\u003e --from-literal=password=\u003cyour-password\u003e --from-literal=dbname=\u003cyour-db-name\u003e\n```\n\nWith a running database, the built application binary can be started by:\n\n```shell\n$ ./bin/wits\n2024/03/07 00:27:08 INFO 💬 🖥️  (cmd/server.go) 🥦 Welcome to Wits!\n2024/03/07 00:27:08 INFO 💬 💾 (pkg/storage/bun.go) InitBunWithPostgres()\n2024/03/07 00:27:08 INFO 💬 💾 (pkg/storage/bun.go) CreatePostgresDB()\n2024/03/07 00:27:08 INFO ✅ 💾 (pkg/storage/bun.go) CreatePostgresDB() -\u003e 📂 Successfully created Postgresql db connection with host=127.0.0.1:5432\n2024/03/07 00:27:08 INFO ✅ 💾 (pkg/storage/bun.go) InitBunWithPostgres() -\u003e 📂 Successfully initialized Bun with Postgres db\n2024/03/07 00:27:08 INFO 💬 🖥️  (cmd/server.go) configureLogging()\n2024/03/07 00:27:08 INFO ✅ 🖥️  (cmd/server.go) configureLogging() -\u003e 🗒️  OK with logLevel=INFO logFilePath=log/wits.log accessLogPath=log/access.log\n2024/03/07 00:27:08 INFO 🚀 🖥️  (cmd/server.go) 🛜 Wits server is running at addr=127.0.0.1:3000\n\n   ____    __\n  / __/___/ /  ___\n / _// __/ _ \\/ _ \\\n/___/\\__/_//_/\\___/ v4.11.4\nHigh performance, minimalist Go web framework\nhttps://echo.labstack.com\n____________________________________O/_______\n                                    O\\\n⇨ http server started on 127.0.0.1:3000\n```\n\nThe built binary is explicitly ignored from source control (see [.gitignore](.gitignore)).\n\n## Running the Application in a Kubernetes cluster\n\nWits provides the required resources to be deployed to a k8s cluster. If you are running a local cluster, e.g. through `minikube` you will want to add your Personal Access Token from your GitHub Account to be able to read your packages from the ghcr registry. You can do so by running:\n\n```bash\n$ kubectl create secret generic ghcr-secret --from-file=.dockerconfigjson=$HOME/.config/containers/auth.json --type=kubernetes.io/dockerconfigjson\n\nsecret/ghcr-secret created\n```\n\n## Running Tests\n\n- Run the testsuite with coverage enabled:\n\n```shell\n$ make test\ngo test -race -v ./... -coverprofile coverage.out\n?    github.com/TheDonDope/wits/pkg/types [no test files]\n?    github.com/TheDonDope/wits/pkg/view [no test files]\n github.com/TheDonDope/wits/pkg/handler  coverage: 0.0% of statements\n github.com/TheDonDope/wits/cmd  coverage: 0.0% of statements\n github.com/TheDonDope/wits/pkg/view/dashboard  coverage: 0.0% of statements\n github.com/TheDonDope/wits/pkg/view/layout  coverage: 0.0% of statements\n github.com/TheDonDope/wits/pkg/view/auth  coverage: 0.0% of statements\n github.com/TheDonDope/wits/pkg/storage  coverage: 0.0% of statements\n github.com/TheDonDope/wits/pkg/view/ui  coverage: 0.0% of statements\n```\n\n- Generate the coverage results as html:\n\n```shell\n$ make cover\ngo test -race -v ./... -coverprofile coverage.out\n?    github.com/TheDonDope/wits/pkg/types [no test files]\n?    github.com/TheDonDope/wits/pkg/view [no test files]\n github.com/TheDonDope/wits/cmd  coverage: 0.0% of statements\n github.com/TheDonDope/wits/pkg/handler  coverage: 0.0% of statements\n github.com/TheDonDope/wits/pkg/view/auth  coverage: 0.0% of statements\n github.com/TheDonDope/wits/pkg/view/ui  coverage: 0.0% of statements\n github.com/TheDonDope/wits/pkg/view/layout  coverage: 0.0% of statements\n github.com/TheDonDope/wits/pkg/storage  coverage: 0.0% of statements\n github.com/TheDonDope/wits/pkg/view/dashboard  coverage: 0.0% of statements\ngo tool cover -html coverage.out -o coverage.html\n[Empty output on success]\n```\n\n- Open the results in the browser:\n\n```shell\n$ make show-cover\ngo test -race -v ./... -coverprofile coverage.out\n?    github.com/TheDonDope/wits/pkg/types [no test files]\n?    github.com/TheDonDope/wits/pkg/view [no test files]\n github.com/TheDonDope/wits/cmd  coverage: 0.0% of statements\n github.com/TheDonDope/wits/pkg/handler  coverage: 0.0% of statements\n github.com/TheDonDope/wits/pkg/storage  coverage: 0.0% of statements\n github.com/TheDonDope/wits/pkg/view/ui  coverage: 0.0% of statements\n github.com/TheDonDope/wits/pkg/view/auth  coverage: 0.0% of statements\n github.com/TheDonDope/wits/pkg/view/layout  coverage: 0.0% of statements\n github.com/TheDonDope/wits/pkg/view/dashboard  coverage: 0.0% of statements\ngo tool cover -html coverage.out -o coverage.html\nopen coverage.html\n\u003cOpens Browser\u003e\n```\n\nBoth the `coverage.out` as well as the `coverage.html` are explicitly ignored from source control (see [.gitignore](.gitignore)).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthedondope%2Fwits","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthedondope%2Fwits","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthedondope%2Fwits/lists"}