import { Callout } from "nextra-theme-docs"; import { Steps } from "nextra-theme-docs"; # Setting up a Dev environment This is a guide to set up a dev environment for LearnHouse, it will guide you through the installation of the backend and the frontend. ## Prerequisites - [Docker](https://docs.docker.com/get-docker/) - [Node.js 21.x](https://nodejs.org/en/download/) - [pnpm](https://pnpm.io/installation) - [Python 3.12.x](https://www.python.org/downloads/) - [Poetry](https://python-poetry.org/docs/) - macOS, Linux or Windows ## Backend configuration ### Get the repository ```bash copy git clone https://github.com/learnhouse/learnhouse ``` ```shell copy cd learnhouse ``` ### Build & install LearnHouse This will build & run the backend and the database docker images ```shell copy docker-compose up -d ``` This will install all the dependencies needed for the backend - A **Postgres** database - A **Redis** server - A **Collaboration** nodejs server - _A built LearnHouse App\* (Frontend & Backend)_ You should **ignore** the Built LearnHouse App as it's not needed for the dev environment, in this case it will be useful only for installing learnhouse contents (Roles, Organization, Users in the database) ### Run the backend in dev mode You'll need to modify the config file to enable the install mode #### Go to the backend folder ```shell copy cd apps/api ``` #### Install python dependencies ```shell copy poetry install ``` #### Run the Backend in Dev mode ```shell copy poetry run python app.py ``` To learn more about Configuration options, please refer to the [Configuration](/self-hosting/configuration) documentation #### Check the API Go to [http://localhost:1338/docs/](http://localhost:1338/docs/) ## Frontend configuration ### Init the frontend Go to the frontend folder ```shell copy cd apps/web ``` This will install all the dependencies needed for the frontend ```shell copy pnpm i ``` Add an .env file in the front folder with the following content ```env filename="apps/web/.env" {1-2} NEXT_PUBLIC_LEARNHOUSE_MULTI_ORG=false NEXT_PUBLIC_LEARNHOUSE_DEFAULT_ORG=test NEXT_PUBLIC_LEARNHOUSE_API_URL=http://localhost:1338/api/v1/ NEXT_PUBLIC_LEARNHOUSE_BACKEND_URL=http://localhost:1338/ NEXT_PUBLIC_LEARNHOUSE_DOMAIN=localhost:3000 ``` Setting MultiOrg to true won't work locally for now, please set it to false To learn about Organizations Hosting modes, please refer to the [Organization Hosting Modes](/self-hosting/organization-hosting-modes) documentation Run the dev environment ```shell copy pnpm run dev ``` ### Configure your Organization as the default one Copy this content to the .env file in the web folder ```env filename="apps/web/.env" {2} NEXT_PUBLIC_LEARNHOUSE_MULTI_ORG=false NEXT_PUBLIC_LEARNHOUSE_DEFAULT_ORG=default NEXT_PUBLIC_LEARNHOUSE_API_URL=http://localhost:1338/api/v1/ NEXT_PUBLIC_LEARNHOUSE_BACKEND_URL=http://localhost:1338/ NEXT_PUBLIC_LEARNHOUSE_DOMAIN=localhost:3000 NEXT_PUBLIC_LEARNHOUSE_COLLABORATION_WS_URL=wss://localhost:1998 ``` Make sure to change the `NEXT_PUBLIC_LEARNHOUSE_DEFAULT_ORG` to the organization you want to set as the default one, you''l find the organization slug in the database in the `organizations` table Here it is set to `default` which is the default organization created by the backend when you ran the backend in the previous steps ### Congratulations, you're done! 🎉 Visit the app at [http://localhost:3000/](http://localhost:3000/) ## Next Steps Thanks for contributing to LearnHouse 💟 You'll find here some issues/ features we need help with, feel free to contribute to any of them - [Help Wanted Issues](https://github.com/learnhouse/learnhouse/labels/help%20wanted)