This is the repository for the PlanB Network website. The goal of this project is to create a free, open-source, and community-driven platform to learn about Bitcoin.
The repository holding the data for this project is here.
We are looking for contributors! If you want to help or learn more about the project, please reach out to us on Twitter or Discord.
We use Turbo to manage the monorepo and Docker to run the development environment.
Follow the next steps to run the project locally, on a linux machine.
Do it.
Duplicate the .env.example file and rename the duplicate .env
.
To start the development environment, run :
pnpm install
docker compose up --build -V
This will start all the necessary containers.
On the first run, you will need to run the DB migrations.
To do so, run the migration script : pnpm run dev:db:migrate
Once the containers are up and running, you can access the front at http://localhost:8181
. The app will automatically reload if you change any of the source files.
In order to sync the database with the data from the data repository, you can make a request to the API with curl -X POST http://localhost:3000/api/github/sync
. This will import all the data from the data repository into the database.
When running the sync locally, there is currently and access right issue with the cdn and sync volumes. To fix it, update the access rights with the following command :
docker exec --user=root bitcoin-learning-management-system-api-1 chmod 777 /tmp/{sync,cdn}
You may want to run the project locally to test your changes. Here is how to do it.
- Node.js
- PostgreSQL
- Redis
npm i -g pnpm dotenv-cli
Login to your local PostgreSQL instance (psql -U postgres
) and run the following commands:
CREATE USER plan_b WITH PASSWORD 'plan_b';
CREATE DATABASE plan_b WITH OWNER plan_b;
Update your .env
file accordingly.
pnpm run dev:db:migrate:local
docker run -d --restart=always -p 8080:80 \
-v /tmp/cdn:/var/www/cdn:ro \
-v ./docker/cdn/nginx.conf:/etc/nginx/nginx.conf:ro \
--name cdn-server \
nginx:alpine
The central point for the database schema is this file : Schema.
For any update to it, you first have to update the schema.ts file.
Once updated, to reflect it in your database, run the following commands :
pnpm run dev:db:generate
This will add a new migration script, then you have to run it :
pnpm run dev:db:migrate
Once the database is updated, add new schemas, if needed, in the schema pacakge.
Once done, create the associated types running :
pnpm build
To open psql, run docker exec -it bitcoin-learning-management-system-postgres-1 psql -U postgres -d postgres