Skip to content

animorphcoop/journey-coop

Repository files navigation

Journey to co-op

What is it?

A community platform for sharing the life events that led people to join co-ops across the globe. People can share their multimedia stories for other users to view and engage with.

The goal of the platform is to create an organic repository of inspiring stories and to facilitate a discussion on what brings people into the co-op ecosystem.

What is it made of?

Server-Side-Rendered web-app comprising of Django, HTMX, Alpine.js and Tailwind CSS. The frontend (including Typescript bundled with Vite.

What does it facilitate?

With a single-page-application feel, the website enables users to create accounts, post stories and respond to them without refreshing.

Setup & development

PostgreSQL

  1. Project uses PostreSQL database. Before being able to run the project properly, you need to install it on your device. On linux you need the following system packages:
sudo apt install postgresql postgresql-contrib libpq-dev python3-dev
  1. Once installed, configure the db, user in line with journey/dev.py:
sudo -u postgres psql
CREATE
DATABASE journey_db_dev;
CREATE
USER journey_user_dev WITH ENCRYPTED PASSWORD 'local_testing_password';
ALTER
ROLE journey_user_dev SET client_encoding TO 'utf8';
ALTER
ROLE journey_user_dev SET default_transaction_isolation TO 'read committed';
ALTER
ROLE journey_user_dev SET timezone TO 'UTC';
GRANT
ALL
PRIVILEGES
ON
DATABASE
journey_db_dev TO journey_user_dev;
\q

Django

  1. Create virtual environment and activate it (after cloning and entering the project root dir):
python3 -m venv venv
source venv/bin/activate
  1. Prepare Django for development
pip install -r dev_requirements.txt
python manage.py migrate

(after changes to the models)

python manage.py makemigrations

(if in doubt that some static assets have not been pulled)

python manage.py collectstatic

For making admin account

python manage.py createsuperuser

Vite

Before running Django, open another terminal window to set up Vite to bundle frontend static assets

npm install

For running it in development (as described in vite.config.js)

  1. Now run SSR app (continue Vite process in parallel)
python manage.py runserver

Deployment

with uWSGI and Caddy on Debian

Project setup on the server

  1. Setup keys & clone repo

  2. Follow installation steps above (from the start, install requirements.txt, add local.py with secrets, make sure there is a match with PostgreSQL credentials)

  3. Build static assets

npm run build


3.Export production settings

```bash
export DJANGO_SETTINGS_MODULE='journey.prod'
  1. Collect static files
python manage.py collectstatic

uwsgi

journey.ini is creating a pid and log in uwsgi directory

To start uwsgi:

uwsgi --ini journey.ini
  • When changing settings reload pid file to update changes in settings or ini
uwsgi --reload uwsgi/uwsgi_journey.pid

Caddy

  • Please refer to Caddyfile, it has been moved to /etc/caddy/)
caddy start
  • if you change the config don't forget to reload
caddy reload --config /etc/caddy/Caddyfile

Running Tests

In order to run tests before to push your changes to main branch or create a Pull Request, you need to install a couple of libraries:

pip install -r dev_requirements.txt

Then you have to measure your code coverage, ideally always maintain at least a 90% of cc.

coverage run --source='.' manage.py test
coverage report

If you would like to analyze visually the lines of code covered by the tests, you should run this command after the previous commands:

coverage html

This will generate an html report inside the folder htmlcov/. For further info, please visit coverage docs

About

A community platform for sharing the life events that led people to join co-ops across the globe.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published