/jonogon-mono

Take Action on Issues you care about

Primary LanguageTypeScriptMIT LicenseMIT

jonogon

A citizen petition platform for Bangladesh 2.0

Development

Philosophies

Just one for now:

To ensure participation, we want to keep the project as abstraction free as possible, and when we do use an abstraction (sometimes a necessary evil for simplicity), we want to keep them as simple and leak-free as possible.

Stack

TODO

Requirements

  • Docker >= 26.1.4

Quick Start

git clone git@github.com:jonogon/jonogon-mono.git
cd jonogon-mono

# ----------- feel free to run the below commands
# whenever you do a `git pull` ------------------

# install dependencies
docker compose run --build --rm mono pnpm install

# run migrations
docker compose run --rm -w /mono/misc/migrator mono pnpm run migration up

# start
docker compose up --remove-orphans

If you're encountering difficulties with Docker, such as automatic updates not functioning, consider using Windows Subsystem for Linux (WSL). Click here for a comprehensive guide.

DevMode Authentication

  • All OTPs sent in dev mode will be visible exclusively on the console.
  • The OTP for 01111111111 is hard coded to be 1111 only in dev mode.

Migrations

Database migrations are done via node-pg-migrate. The migrator tool can be found in /misc/migrator.

Create Migration

# `--no-deps` because creating migrations does not require the database containers
docker compose run --rm --no-deps -w /mono/misc/migrator mono pnpm run migration create $MIGRATION_FILE_NAME

Run Migrations

# up
docker compose run --rm -w /mono/misc/migrator mono pnpm run migration up

# down
docker compose run --rm -w /mono/misc/migrator mono pnpm run migration down

Postgres

Codegen for kysely

docker compose run --rm -w /mono/apps/jonogon-core mono pnpm run kysely:codegen

tRPC

Playground

Once you have the server running, you can access the tRPC playground at http://localhost:12001/trpc-playground. This is only available in dev mode, and not in production.

Authenticating Playground

  1. Complete the login flow at http://localhost:12002/login
  2. While at http://localhost:12002/, open the browser console.
  3. Run the following script and copy the token JSON.parse(window.localStorage.getItem('auth:token')).token
  4. Go to the Playground.
  5. Open "Settings" from the top right corner.
  6. Create a header called Authorization and paste the token as the value in the format Bearer {TOKEN}.

Docker with WSL Setup

Prerequisites:

  • Windows 10 (version 1903 or later) or Windows 11

  • WSL 2 enabled:

    1. Open PowerShell as administrator.
    2. Run wsl --supported to verify compatibility.
    3. If compatible, enable WSL 2 with: wsl --set-default-version 2

Installation Steps:

  1. Install WSL 2 (if not already installed):

    • Follow this YouTube tutorial: https://youtu.be/eId6K8d0v6o
    • If Ubuntu is not installed for WSL, Run wsl --install --d Ubuntu to install it.
  2. Install Docker Desktop:

Enabling WSL Integration in Docker Desktop:

  1. Open terminal and switch to Ubuntu. Switching to Ubuntu
  2. Open Docker Desktop (has to be running in the background).
  3. Go to Settings > General.
    Go to Settings
  4. Under "WSL Integration," enable "Enable WSL 2 backend" (if not already enabled). Enable WSL 2 Backend Enable Ubuntu from Resources > WSL integation
  5. If you have multiple WSL distributions, select your preferred one under "WSL Integation."
  6. Now you can run everything from Quick Start Guide inside the Ubuntu console we opened in Step #1.

Additional Notes:

Learning Resources

Frontend (Jonogon Web)

Backend (Jonogon Core)