2020-11-30 12:12:56 +00:00
---
2021-06-21 19:25:56 +00:00
title: Full development environment
2020-11-30 12:12:56 +00:00
---
## Backend
2020-12-05 21:08:42 +00:00
To create a local development setup for authentik, you need the following:
2020-11-30 12:12:56 +00:00
2021-10-04 15:54:06 +00:00
### Requirements
2020-11-30 12:12:56 +00:00
- Python 3.9
- pipenv, which is used to manage dependencies, and can be installed with `pip install pipenv`
2021-07-26 20:52:58 +00:00
- Go 1.16
2020-11-30 12:12:56 +00:00
- PostgreSQL (any recent version will do)
- Redis (any recent version will do)
For PostgreSQL and Redis, you can use the docker-compose file in `scripts/` . You can also use a native install, if you prefer.
2021-10-04 15:54:06 +00:00
### Setup
```shell
pipenv shell # Creates a python virtualenv, and activates it in a new shell
pipenv sync --dev # Install all required dependencies, including development dependencies
```
2020-12-05 21:08:42 +00:00
To configure authentik to use the local databases, create a file in the authentik directory called `local.env.yml` , with the following contents
2020-11-30 12:12:56 +00:00
```yaml
debug: true
postgresql:
user: postgres
log_level: debug
2021-05-16 21:45:28 +00:00
secret_key: "A long key you can generate with `pwgen 40 1` for example"
2020-11-30 12:12:56 +00:00
```
2021-10-11 20:33:31 +00:00
To apply database migrations, run `make migrate` . This is needed after the initial setup, and whenever you fetch new source from upstream.
2021-09-27 14:04:41 +00:00
Afterwards, you can start authentik by running `make run` . authentik is now accessible under `localhost:9000` .
2021-07-26 20:52:58 +00:00
Generally speaking, authentik is a Django application, ran by gunicorn, proxied by a Go application. The Go application serves static files.
2020-11-30 12:12:56 +00:00
Most functions and classes have type-hints and docstrings, so it is recommended to install a Python Type-checking Extension in your IDE to navigate around the code.
2021-07-26 20:52:58 +00:00
Before committing code, run `make lint` to ensure your code is formatted well. This also requires `pyright@1.1.136` , which can be installed with npm.
2021-04-18 15:25:03 +00:00
2021-05-16 21:24:52 +00:00
Run `make gen` to generate an updated OpenAPI document for any changes you made.
2021-04-18 15:25:03 +00:00
2020-11-30 12:12:56 +00:00
## Frontend
2021-09-27 14:04:41 +00:00
By default, no compiled bundle of the frontend is included. To build the UI, you need Node 14 or newer.
2021-03-18 21:02:04 +00:00
2020-11-30 12:12:56 +00:00
To build the UI, run these commands:
```
cd web/
npm i
npm run build
```
If you want to make changes to the UI, run `npm run watch` instead.
2021-04-18 15:25:03 +00:00
To ensure the code is formatted well, run `npx eslint . --fix` and `npm run lit-analyse` .