## Table of Contents * [User Survey](#-user-survey) * [Features](#-features) * [Roadmap](#-roadmap) * [How to use](#-how-to-use) * [Configuration Options](#-configuration-options) * [API Endpoints](#-api-endpoints) * [Integrations](#-integrations) * [Best Practices](#-best-practices) * [Developer Notes](#-developer-notes) * [Support](#-support) * [FAQs](#-faqs) ## π¬ **User Survey** I'd love to get some community feedback from active Wakapi users. If you want, please participate in the recent [user survey](https://github.com/muety/wakapi/issues/82). Thanks a lot! ## π Features * β 100 % free and open-source * β Built by developers for developers * β Statistics for projects, languages, editors, hosts and operating systems * β Badges * β REST API * β Partially compatible with WakaTime * β WakaTime integration * β Support for Prometheus exports * β Lightning fast * β Self-hosted ## π§ Roadmap Plans for the near future mainly include, besides usual improvements and bug fixes, a UI redesign as well as additional types of charts and statistics (see [#101](https://github.com/muety/wakapi/issues/101), [#80](https://github.com/muety/wakapi/issues/80), [#76](https://github.com/muety/wakapi/issues/76), [#12](https://github.com/muety/wakapi/issues/12)). If you have feature requests or any kind of improvement proposals feel free to open an issue or share them in our [user survey](https://github.com/muety/wakapi/issues/82). ## β¨οΈ How to use? There are different options for how to use Wakapi, ranging from our hosted cloud service to self-hosting it. Regardless of which option choose, you will always have to do the [client setup](#-client-setup) in addition. ### βοΈ Option 1: Use [wakapi.dev](https://wakapi.dev) If you want to you out free, hosted cloud service, all you need to do is create an account and the set up your client-side tooling (see below). However, we do not guarantee data persistence, so you might potentially lose your data if the service is taken down some day β ### π³ Option 2: Use Docker ```bash # Create a persistent volume $ docker volume create wakapi-data # Run the container $ docker run -d \ -p 3000:3000 \ -e "WAKAPI_PASSWORD_SALT=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w ${1:-32} | head -n 1)" \ -v wakapi-data:/data \ --name wakapi n1try/wakapi ``` **Note:** By default, SQLite is used as a database. To run Wakapi in Docker with MySQL or Postgres, see [Dockerfile](https://github.com/muety/wakapi/blob/master/Dockerfile) and [config.default.yml](https://github.com/muety/wakapi/blob/master/config.default.yml) for further options. ### π¦ Option 3: Run a release ```bash # Download the release and unpack it $ wget https://github.com/muety/wakapi/releases/download/1.20.2/wakapi_linux_amd64.zip $ unzip wakapi_linux_amd64.zip # Optionally adapt config to your needs $ vi config.yml # Run it $ ./wakapi ``` ### π§βπ» Option 4: Run from source #### Prerequisites * Go >= 1.13 (with `$GOPATH` properly set) * gcc (to compile [go-sqlite3](https://github.com/mattn/go-sqlite3)) * Fedora / RHEL: `dnf install @development-tools` * Ubuntu / Debian: `apt install build-essential` * Windows: See [here](https://github.com/mattn/go-sqlite3/issues/214#issuecomment-253216476) #### Compile & Run ```bash # Adapt config to your needs $ cp config.default.yml config.yml $ vi config.yml # Install packaging tool $ export GO111MODULE=on $ go get github.com/markbates/pkger/cmd/pkger # Build the executable $ go generate $ go build -o wakapi # Run it $ ./wakapi ``` **Note:** By default, the application is running in dev mode. However, it is recommended to set `ENV=production` for enhanced performance and security. To still be able to log in when using production mode, you either have to run Wakapi behind a reverse proxy, that enables for HTTPS encryption (see [best practices](#best-practices)) or set `security.insecure_cookies = true` in `config.yml`. ### π» Client Setup Wakapi relies on the open-source [WakaTime](https://github.com/wakatime/wakatime) client tools. In order to collect statistics to Wakapi, you need to set them up. 1. **Set up WakaTime** for your specific IDE or editor. Please refer to the respective [plugin guide](https://wakatime.com/plugins) 2. **Editing your local `~/.wakatime.cfg`** file as follows ```ini [settings] # Your Wakapi server URL or 'https://wakapi.dev/api/heartbeat' when using the cloud server api_url = http://localhost:3000/api/heartbeat # Your Wakapi API key (get it from the web interface after having created an account) api_key = 406fe41f-6d69-4183-a4cc-121e0c524c2b ``` Optionally, you can set up a [client-side proxy](docs/advanced_setup.md) in addition. ## π§ Configuration Options You can specify configuration options either via a config file (default: `config.yml`, customziable through the `-c` argument) or via environment variables. Here is an overview of all options. | YAML Key | Environment Variable | Default | Description | |---------------------------|---------------------------|--------------|---------------------------------------------------------------------| | `env` | `ENVIRONMENT` | `dev` | Whether to use development- or production settings | | `app.custom_languages` | - | - | Map from file endings to language names | | `server.port` | `WAKAPI_PORT` | `3000` | Port to listen on | | `server.listen_ipv4` | `WAKAPI_LISTEN_IPV4` | `127.0.0.1` | IPv4 network address to listen on (leave blank to disable IPv4) | | `server.listen_ipv6` | `WAKAPI_LISTEN_IPV6` | `::1` | IPv6 network address to listen on (leave blank to disable IPv6) | | `server.tls_cert_path` | `WAKAPI_TLS_CERT_PATH` | - | Path of SSL server certificate (leave blank to not use HTTPS) | | `server.tls_key_path` | `WAKAPI_TLS_KEY_PATH` | - | Path of SSL server private key (leave blank to not use HTTPS) | | `server.base_path` | `WAKAPI_BASE_PATH` | `/` | Web base path (change when running behind a proxy under a sub-path) | | `security.password_salt` | `WAKAPI_PASSWORD_SALT` | - | Pepper to use for password hashing | | `security.insecure_cookies` | `WAKAPI_INSECURE_COOKIES` | `false` | Whether or not to allow cookies over HTTP | | `security.cookie_max_age` | `WAKAPI_COOKIE_MAX_AGE` | `172800` | Lifetime of authentication cookies in seconds or `0` to use [Session](https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies#Define_the_lifetime_of_a_cookie) cookies | | `security.allow_signup` | `WAKAPI_ALLOW_SIGNUP` | `true` | Whether to enable user registration | | `security.expose_metrics` | `WAKAPI_EXPOSE_METRICS` | `false` | Whether to expose Prometheus metrics under `/api/metrics` | | `db.host` | `WAKAPI_DB_HOST` | - | Database host | | `db.port` | `WAKAPI_DB_PORT` | - | Database port | | `db.user` | `WAKAPI_DB_USER` | - | Database user | | `db.password` | `WAKAPI_DB_PASSWORD` | - | Database password | | `db.name` | `WAKAPI_DB_NAME` | `wakapi_db.db` | Database name | | `db.dialect` | `WAKAPI_DB_TYPE` | `sqlite3` | Database type (one of `sqlite3`, `mysql`, `postgres`, `cockroach`) | | `db.max_conn` | `WAKAPI_DB_MAX_CONNECTIONS` | `2` | Maximum number of database connections | | `db.ssl` | `WAKAPI_DB_SSL` | `false` | Whether to use TLS encryption for database connection (Postgres and CockroachDB only) | ### Supported databases Wakapi uses [GORM](https://gorm.io) as an ORM. As a consequence, a set of different relational databases is supported. * [SQLite](https://sqlite.org/) (_default, easy setup_) * [MySQL](https://hub.docker.com/_/mysql) (_recommended, because most extensively tested_) * [MariaDB](https://hub.docker.com/_/mariadb) (_open-source MySQL alternative_) * [Postgres](https://hub.docker.com/_/postgres) (_open-source as well_) * [CockroachDB](https://www.cockroachlabs.com/docs/stable/install-cockroachdb-linux.html) (_cloud-native, distributed, Postgres-compatible API_) ### Client-side proxy (`optional`) See the [advanced setup instructions](docs/advanced_setup.md). ## π§ API Endpoints See our [Swagger API Documentation](https://wakapi.dev/swagger-ui). ### Generating Swagger docs ```bash $ go get -u github.com/swaggo/swag/cmd/swag $ swag init -o static/docs ``` ## π€ Integrations ### Prometheus Export You can export your Wakapi statistics to Prometheus to view them in a Grafana dashboard or so. Here is how. ```bash # 1. Start Wakapi with the feature enabled $ export WAKAPI_EXPOSE_METRICS=true $ ./wakapi # 2. Get your API key and hash it $ echo "