Skip to content

Stand Alone

In order to have get started with developing hypha locally, you'll need these minimal setup, the setup may vary slightly for your base operating systems.

System Dependencies

Make sure you have these things installed on your system:

  • Git – Installation Guide
  • Python 3.12
  • Node 20.18
  • PostgreSQL 14 (with libpq-dev on Linux)

Info

On Linux install them with your normal package manager. On macOS Homebrew is an excellent option. For Windows Chocolatey seems popular but we have no experience with Windows.

This project ships with .python-version and .nvmrc to support pyenv and nvm. You can use it to setup the correct versions of Python and Node required for this project.

Basic installation steps

This process was tested on Ubuntu 22.04 LTS. It should work on any Debian-based system.

Install Python pip, venv & PostgreSQL:

sudo apt install -y \
    python3-pip python3-venv \
    postgresql postgresql-contrib postgresql-server-dev-14

This process was tested on Fedora Workstation 38. It should work on RHEL as well.

Install Python pip, venv & PostgreSQL:

sudo dnf module -y reset postgresql
sudo dnf module -y enable postgresql:14
sudo dnf install -y \
    python3-pip gcc python3-devel \
    postgresql-server postgresql-contrib libpq-devel
sudo /usr/bin/postgresql-setup --initdb

This process was tested on macOS Ventura 13.5.2.

Install Python pip, venv & PostgreSQL:

brew install [email protected] 
brew install postgres@14
brew services start postgres@14

Get the code

Use git to fetch the code, this will create a hypha/ directory.

git clone https://github.com/HyphaApp/hypha.git hypha
cd hypha

Now, create some local directories.

cd hypha
mkdir -p var/log media

NOTE: In production media is stored on AWS S3 but for local development you need a "media" directory. The var/log is used to store local logs, if configured.

Info

Everything from now on will happen inside the hypha/ directory.

Installing Node Version Manager

NodeJS versions have potential to change. To allow for ease of upgrading, it is recommended to use Node Version Manager (nvm).

The following commands will install nvm and proceed to setup Node based off of the content of .nvmrc.

wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bash
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"  # This loads nvm bash_completion
nvm install     # Install the Node version in .nvmrc
nvm use         # Use the Node version in .nvmrc

Compile JS & SCSS

Build all JS/CSS assets for development:

npm run dev:build

Info

Hypha uses NodeJS to compile SCSS and JS from the hypha/static_src/ directory. See the package.json file for a complete list of commands.

Add/Update Configuration

Hypha supports configuration via either a local.py or a .env file:

Create an empty .env file at the root of the project:

.
├── .env
├── manage.py
├── hypha
│   ├── urls.py
│   ├── settings/
│   ├── ...
├── ...

Open .env file and add your config:

./.env
ALLOWED_HOSTS=hypha.test
BASE_URL=http://hypha.test
SECRET_KEY=<put-in-long-random-string>
DATABASE_URL=postgres://localhost/hypha

Copy the provided local.py.example file and rename it to local.py.

cp -p hypha/settings/local.py.example hypha/settings/local.py
.
├── manage.py
├── hypha
│   ├── urls.py
│   ├── settings
│   │   ├── __init__.py
│   │   ├── base.py
│   │   ├── dev.py
│   │   ├── django.py
│   │   ├── local.py
│   │   ├── local.py.example
│   │   ├── production.py
│   │   └── test.py
│   ├── ...
├── ...

Open and take a look at the local.py, it already has some sensible defaults and you can use this to override all the settings.

Setup Database and Initial Data

Create an empty database:

createdb hypha

Ensure database name hypha is added to your hypha/settings/local.py or .env.

Let's create all the tables and schemas required by the project.

There are two ways to about it, you can either load demo data from /public/sandbox_db.dump or start with empty tables.

To load demo data run:

pg_restore --verbose --clean  --if-exists --no-acl --no-owner \
             --dbname=hypha public/sandbox_db.dump

It's not always completely up to date so run:

python3 manage.py migrate
python3 manage.py sync_roles

Create the cache tables.

python3 manage.py createcachetable

Run all migrations to set up the database tables.

python3 manage.py migrate
python3 manage.py sync_roles

Tips

  • If createdband dropdb are not available you will need to add the Postgres bin directory to your path or call the commands with complete path.
  • If you need to delete/drop the database, you can use dropdb hypha
  • On Linux you might need to run as the "postgres" user first when setting up Postgres. Use it to create the database and set up a database user.For local development I suggest creating a user with the same name as your account, then you will not need to specify it on every command.

    su - postgres
    createdb hypha
    createuser [your-account-name]
    

Setup Sites

You will need two domain to run this app, used to serve the public and apply site on different domains

First, add these sites to the database:

$ python manage.py wagtailsiteupdate hypha.test 9001

Then, add this to your /etc/hosts file.

/etc/hosts
127.0.0.1 hypha.test

Here we are setting the public site be served at http://hypha.test:9001.

Is it safe to use .test?

The ".test" TLD is safe to use, it's reserved for testing purposes. Feel free to use another name but then remember to use it in all the commands below.

Create Login credentials

python3 manage.py createsuperuser

Run Development Server

python3 manage.py runserver 0.0.0.0:9001 --settings=hypha.settings.dev

Alternatively, you can also use make serve-django

Now you should be able to access the site:

  1. Apply Site: http://hypha.test:9001/

Documentation

To live preview of documentation, while you writing it.

Activate your virtual environment and install dependencies:

source venv/bin/activate
python3 -m pip install --no-deps -r requirements/dev.txt

If utilizing application machine translations, install the required dependencies:

python3 -m pip install -r requirements/translate.txt

Run:

make serve-docs

Open http://localhost:9100/ to preview the documentation site.

Tip

You can use make serve command to run Django Development Server, watch and compile frontend changes and preview docs all at once.

Running tests

Hypha uses ruff and py.test test runner and uses hypha/settings/testing.py for test settings. For frontend code, stylelint and eslint is used.

Run the test with:

make test

For lint the code and not run the full test suite you can use:

make lint

Helpful URLs

Use the email address and password you set in the createsuperuser step above to login.