Openverse is a search engine for openly-licensed media. This monorepo includes all application code.
Improve documentation for partial stack setups (#974)
Dhruv Bhanushali817fc637f851
diff --git a/documentation/guides/api/index.md b/documentation/guides/api/index.mdindex e961259a5..68f2bce31 100644--- a/documentation/guides/api/index.md+++ b/documentation/guides/api/index.md@@ -3,5 +3,6 @@```{toctree}:maxdepth: 1+quickstarttest```diff --git a/documentation/guides/api/quickstart.md b/documentation/guides/api/quickstart.mdnew file mode 100644index 000000000..2295d01d0--- /dev/null+++ b/documentation/guides/api/quickstart.md@@ -0,0 +1,104 @@+# Quickstart guide++This is the quick start guide for setting up and running the API locally.++## Prerequisites++Refer to the [general setup guide](../general_setup.md) for setting up the+prerequisites. Refer to the 'API' column in the+[requirement matrix](../general_setup.md#requirement-matrix) to know what you+need to run this.++## Starting up++1. Ensure you download, install and set up all prerequisites. Ensure that the+ Docker daemon is running.++2. Clone the repository to your computer. Then switch to the cloned directory.+ If you're planning to contribute, fork the repo and clone your fork instead.++ ```console+ $ git clone https://github.com/WordPress/openverse.git # or your fork+ $ cd openverse/+ ```++ If you followed the general setup guide and installed+ [GitHub CLI](./general_setup.md#github-cli), you can clone more simply using+ the `gh` command.++ ```console+ $ gh repo clone WordPress/openverse # or your fork+ $ cd openverse/+ ```++3. Bring the ingestion server and API up, along with all their dependent+ services.++ ```console+ $ just api/up+ ```++ The `api/up` recipe orchestrates the following services: `cache`, `db`,+ `upstream_db`, `es`, `indexer_worker`, `ingestion_server`, `web` and `proxy`.++ Now you should be able to access the following endpoints:++ - the list of ingestion jobs on+ [http://localhost:50281/task](http://localhost:50281/task)+ - the API documentation on [http://localhost:50280](http://localhost:50280)++4. Load the sample data. This step can take a few minutes to complete.++ ```console+ $ just api/init+ ```++ ````{admonition} Troubleshooting+ If this step fails, cleaning up and restarting usually fixes it.++ ```console+ $ just down -v+ $ just api/init+ ```+ ````++5. With the data loaded, the API can now return JSON responses to your HTTP+ requests.++ ```console+ $ just api/stats+ just _curl-get "images/stats/" localhost:50280+ curl "http://localhost:50280/v1/images/stats/"+ [{"source_name":"flickr","display_name":"Flickr","source_url":"https://www.flickr.com","logo_url":null,"media_count":2500},{"source_name":"stocksnap","display_name":"StockSnap","source_url":"https://stocksnap.io","logo_url":null,"media_count":2500}]%+ ```++ ````{tip}+ [`jq`](https://stedolan.github.io/jq/) is a tool for parsing and manipulating+ JSON data. If you have `jq` installed, you can pipe the response to it and+ transform it.++ ```console+ $ just api/stats | jq '.[0]'+ {+ "source_name": "flickr",+ "display_name": "Flickr",+ "source_url": "https://www.flickr.com",+ "logo_url": null,+ "media_count": 2500+ }++ $ just api/stats 'audio' | jq '[.[] | .source_name]'+ [+ "freesound",+ "jamendo",+ "wikimedia_audio"+ ]+ ```++ `jq` is great, we recommend you+ [download](https://stedolan.github.io/jq/download/) it.+ ````++## Shutting down++Refer to the [common instructions](../quickstart.md#shutting-down).diff --git a/documentation/guides/document.md b/documentation/guides/documentation/guidelines.mdsimilarity index 100%rename from documentation/guides/document.mdrename to documentation/guides/documentation/guidelines.mddiff --git a/documentation/guides/documentation/index.md b/documentation/guides/documentation/index.mdnew file mode 100644index 000000000..9a3415432--- /dev/null+++ b/documentation/guides/documentation/index.md@@ -0,0 +1,8 @@+# Documentation++```{toctree}+:maxdepth: 1++quickstart+guidelines+```diff --git a/documentation/guides/documentation/quickstart.md b/documentation/guides/documentation/quickstart.mdnew file mode 100644index 000000000..e96ca87b9--- /dev/null+++ b/documentation/guides/documentation/quickstart.md@@ -0,0 +1,62 @@+# Quickstart guide++This is the quick start guide for setting up and running the documentation+locally.++## Prerequisites++Refer to the [general setup guide](../general_setup.md) for setting up the+prerequisites. Refer to the 'Docs' column in the+[requirement matrix](../general_setup.md#requirement-matrix) to know what you+need to run this.++## Starting up++1. Ensure you download, install and set up all prerequisites.++2. Clone the repository to your computer. Then switch to the cloned directory.+ If you're planning to contribute, fork the repo and clone your fork instead.++ ```console+ $ git clone https://github.com/WordPress/openverse.git # or your fork+ $ cd openverse/+ ```++ If you followed the general setup guide and installed+ [GitHub CLI](./general_setup.md#github-cli), you can clone more simply using+ the `gh` command.++ ```console+ $ gh repo clone WordPress/openverse # or your fork+ $ cd openverse/+ ```++3. Install only the Python dependencies. You do not need to install any Node.js+ dependencies to run the documentation.++ ```console+ $ just documentation/install+ ```++4. Run the documentation live server. Once this is done, you should be able to+ see the documentation on [http://127.0.0.1:50230](http://127.0.0.1:50230).++ ```console+ $ just documentation/live+ ```++ ````{admonition} Troubleshooting+ Sometimes, the documentation does not refresh to reflect changes in the table+ of contents or changes to the file system. In those cases, you can clean the+ caches and restart the live server.++ ```console+ $ just documentation/clean+ $ just documentation/live+ ```+ ````++## Shutting down++You can press <kbd>Ctrl</kbd> + <kbd>C</kbd> to terminate the documentation live+server.diff --git a/documentation/guides/frontend/analytics.md b/documentation/guides/frontend/analytics.mdnew file mode 100644index 000000000..93e37a342--- /dev/null+++ b/documentation/guides/frontend/analytics.md@@ -0,0 +1,23 @@+# Analytics++Analytics on the frontend requires the Plausible setup to be up and running.++## Starting up++Bring up the Docker services needed by the frontend. This includes Plausible and+the PostgreSQL and Clickhouse databases it needs.++```console+$ just frontend/up+```++The `frontend/up` recipe orchestrates the following services: `plausible_ch`,+`plasible_db` and `plausible`.++Now you should be able to access the following endpoints:++- the Plausible UI on [http://localhost:50288](http://localhost:50288)++## Shutting down++Refer to the [common instructions](../quickstart.md#shutting-down).diff --git a/documentation/guides/frontend/index.md b/documentation/guides/frontend/index.mdindex 1fe2e42ce..80e89ab14 100644--- a/documentation/guides/frontend/index.md+++ b/documentation/guides/frontend/index.md@@ -3,5 +3,6 @@```{toctree}:maxdepth: 1+quickstarttest```diff --git a/documentation/guides/frontend/quickstart.md b/documentation/guides/frontend/quickstart.mdnew file mode 100644index 000000000..021abfaca--- /dev/null+++ b/documentation/guides/frontend/quickstart.md@@ -0,0 +1,64 @@+# Quickstart guide++This is the quick start guide for setting up and running the frontend locally.++## Prerequisites++Refer to the [general setup guide](../general_setup.md) for setting up the+prerequisites. Refer to the 'Frontend' column in the+[requirement matrix](../general_setup.md#requirement-matrix) to know what you+need to run this.++## Starting up++1. Ensure you download, install and set up all prerequisites. Ensure that the+ Docker daemon is running.++2. Clone the repository to your computer. Then switch to the cloned directory.+ If you're planning to contribute, fork the repo and clone your fork instead.++ ```console+ $ git clone https://github.com/WordPress/openverse.git # or your fork+ $ cd openverse/+ ```++ If you followed the general setup guide and installed+ [GitHub CLI](./general_setup.md#github-cli), you can clone more simply using+ the `gh` command.++ ```console+ $ gh repo clone WordPress/openverse # or your fork+ $ cd openverse/+ ```++3. Install only the Node.js dependencies. You do not need to install any Python+ dependencies to run the frontend.++ ```console+ $ just node-install+ ```++4. To bring up the frontend, we have another `just` recipe. We have `just`+ recipes for almost everything.++ ```console+ $ just frontend/run dev+ ```++ If you want your frontend to use a different API instance, you can set the+ `API_URL` environment variable to point to that instance. If you had the+ [API running locally](../api/quickstart.md), you can do the following to use+ the local API with the frontend.++ ```console+ $ env API_URL="http://localhost:50280" just frontend/run dev+ ```++ Now you should be able to access the following endpoints:++ - the Openverse search engine frontend on+ [http://localhost:8443](http://localhost:8443)++## Shutting down++You can press <kbd>Ctrl</kbd> + <kbd>C</kbd> to terminate the frontend process.diff --git a/documentation/guides/general_setup.md b/documentation/guides/general_setup.mdindex 24f5ee2e5..5652021a7 100644--- a/documentation/guides/general_setup.md+++ b/documentation/guides/general_setup.md@@ -27,6 +27,25 @@ Installation instructions for WSL on Windows 10 and 11 can be found inMicrosoft's[official documentation](https://docs.microsoft.com/en-us/windows/wsl/install).+## Requirement matrix++Based on which part of the Openverse stack you are contributing to, you might+not need everything mentioned on this page. Refer to this chart to see which+prerequisites are required to get started with your contributions.++| Requirement | Docs | Ingestion server | API | Frontend | Management |+| ------------------ | ---- | ---------------- | --- | -------------- | ---------- |+| [Git](#git) | ✅ | ✅ | ✅ | ✅ | ✅ |+| [`just`](#just) | ✅ | ✅ | ✅ | ✅ | ✅ |+| [Python](#python) | ✅ | ➖ | ➖ | ➖ | ✅ |+| [Node.js](#nodejs) | ➖ | ➖ | ➖ | ✅ | ✅ |+| [Docker](#docker) | ➖ | ✅ | ✅ | ❔[^analytics] | ➖ |++Here ✅ means required, ➖ means not required and ❔ means conditionally+required.++[^analytics]: This is required to run analytics, not required otherwise.+## Required setupThe following setup steps are needed to set up a local copy of Openverse and do@@ -47,11 +66,48 @@ If you see `git version x.y.z`, you have Git installed. If you see an error, youneed to install it by following the[official instructions](https://git-scm.com/downloads).+### `just`++We use `just` as our command runner. It makes it easier to run cumbersome+commands that are generally needed a lot during development, like bringing up+our backend services or linting the codebase.++`just` can be [installed](https://github.com/casey/just#installation) for a host+of operating systems via their respective+[pacakge managers](https://github.com/casey/just#packages) or using+[pre-built binaries](https://github.com/casey/just#pre-built-binaries) available+for some operating systems.++````{tip}+If you run `just` inside the Openverse root repo without a recipe name, you can+see a huge list of all the different recipes present in the project.++```console+$ cd openverse/+$ just+```+````++If for some reason, you are unable to install `just`, you can refer to the+`justfile` to see the commands that make up a recipe, and then run those+commands individually in a terminal. It won't be the best user experience, but+it will work just the same.++## Conditional setup++A subset of the following requirements will be required depending on the extent+of your contribution to the project. To see which of these you need, refer to+the [requirement matrix](#requirement-matrix) above.+### Python```{note}-This is only needed for working with the Python stack outside of Docker and for-Python automations.+This is only needed if you are working with the following:++- documentation+- Python automations+- API (outside Docker, for debugging purposes)+- ingestion server (outside Docker, for debugging purposes)```We use Python 3 in the backend of our stack. So to work with that part of the@@ -80,7 +136,10 @@ You can install Pipenv by following the### Node.js```{note}-This is only needed for working with the frontend and for Node.js automations.+This is only needed if you are working with the following:++- frontend+- Node.js automations```We use Node.js in the frontend of our stack. So to work with that part of the@@ -108,8 +167,11 @@ onwards. So no installation is needed.### Docker```{note}-This is only needed for working with the Python stack. The Node.js stack runs-on the host.+This is only needed if you are working with the following:++- API+- ingestion server+- frontend```Our Python packages are published as Docker images to make it easier to work@@ -139,31 +201,12 @@ If you see `Docker Compose version vx.y.z`, you have Docker Compose installed.If you see an error, you need to install it by following the[official instructions](https://docs.docker.com/compose/install/).-### `just`--We use `just` as our command runner. It makes it easier to run cumbersome-commands that are generally needed a lot during development, like bringing up-our backend services or linting the codebase.--`just` can be [installed](https://github.com/casey/just#installation) for a host-of operating systems via their respective pacakge managers.--````{tip}-If you run `just` inside the Openverse root repo without a recipe name, you can-see a huge list of all the different recipes present in the project.+### GitHub-```console-$ cd openverse/-$ just+```{note}+This is only needed if you want to contribute code to Openverse. The codebase+can be read, accessed and downloaded without an account.```-````--## Development dependencies--The following setup steps are needed to not just setup Openverse but to also-contribute code to the project.--### GitHubThe source code for Openverse is hosted on GitHub. To contribute to Openverse,you will also need to [sign up](https://github.com/signup) for a GitHub account.@@ -231,6 +274,7 @@ found for -lssl` error when running the project outside Docker.```This `psycopg2` package can fail to install on Apple Silicon Macs with the-`ld: library not found for -lssl` error. To rectify this, install `openssl` via-Homebrew and set `LDFLAGS` and `CPPFLAGS` as per the instructions in the output-of the Homebrew installation.+`ld: library not found for -lssl` error. To rectify this, install the+[`openssl` formula](https://formulae.brew.sh/formula/openssl@3) using+[Homebrew](https://brew.sh/) and set `LDFLAGS` and `CPPFLAGS` as per the+instructions in the output of the Homebrew installation.diff --git a/documentation/guides/index.md b/documentation/guides/index.mdindex f374a12d7..bad3aff9b 100644--- a/documentation/guides/index.md+++ b/documentation/guides/index.md@@ -2,20 +2,29 @@Here you will find guides to get you started with Openverse development.+## General guides+```{toctree}:maxdepth: 1general_setupquickstart+# run+# test+# https+# publish+# deploy+logging+zero-downtime-database-management+```++## Stack-specific guides++```{toctree}+:maxdepth: 2+api/indexingestion_server/indexfrontend/index-run-test-https-document-publish-deploy-logging-zero-downtime-database-management+documentation/index```diff --git a/documentation/guides/ingestion_server/index.md b/documentation/guides/ingestion_server/index.mdindex 573fb671e..3e323c365 100644--- a/documentation/guides/ingestion_server/index.md+++ b/documentation/guides/ingestion_server/index.md@@ -3,5 +3,6 @@```{toctree}:maxdepth: 1+quickstarttest```diff --git a/documentation/guides/ingestion_server/quickstart.md b/documentation/guides/ingestion_server/quickstart.mdnew file mode 100644index 000000000..5e4ac89e9--- /dev/null+++ b/documentation/guides/ingestion_server/quickstart.md@@ -0,0 +1,51 @@+# Quickstart guide++This is the quick start guide for setting up and running the ingestion server+locally.++## Prerequisites++Refer to the [general setup guide](../general_setup.md) for setting up the+prerequisites. Refer to the 'Ingestion server' column in the+[requirement matrix](../general_setup.md#requirement-matrix) to know what you+need to run this.++## Starting up++1. Ensure you download, install and set up all prerequisites. Ensure that the+ Docker daemon is running.++2. Clone the repository to your computer. Then switch to the cloned directory.+ If you're planning to contribute, fork the repo and clone your fork instead.++ ```console+ $ git clone https://github.com/WordPress/openverse.git # or your fork+ $ cd openverse/+ ```++ If you followed the general setup guide and installed+ [GitHub CLI](./general_setup.md#github-cli), you can clone more simply using+ the `gh` command.++ ```console+ $ gh repo clone WordPress/openverse # or your fork+ $ cd openverse/+ ```++3. Bring the ingestion server up, along with all their dependent services.++ ```console+ $ just ingestion_server/up+ ```++ The `ingestion_server/up` recipe orchestrates the following services: `db`,+ `upstream_db`, `es`, `indexer_worker` and `ingestion_server`.++ Now you should be able to access the following endpoints:++ - the list of ingestion jobs on+ [http://localhost:50281/task](http://localhost:50281/task)++## Shutting down++Refer to the [common instructions](../quickstart.md#shutting-down).diff --git a/documentation/guides/quickstart.md b/documentation/guides/quickstart.mdindex 3efda9553..e767ec9e6 100644--- a/documentation/guides/quickstart.md+++ b/documentation/guides/quickstart.md@@ -1,14 +1,32 @@# Quickstart guide+<!-- the main entrypoint of the Openverse documentation system -->+This guide covers the steps to get the Openverse stack running locally on your-computer.+computer. This guide is for setting up the full stack, which includes the API,+the ingestion server and the frontend.++## Stack-specific quickstarts++It is very unlikely that you want to contribute to everything, everywhere, all+at once. In all likelihood, you intend to contribute to a narrower slice of the+stack. In such cases, you might find it more beneficial to go through one of+these stack-specific quickstart guides.++- [API](./api/quickstart.md)+- [Frontend](./frontend/quickstart.md)+- [Ingestion server](./ingestion_server/quickstart.md)+- [Documentation](./documentation/quickstart.md)++That said, there is something very appealing about running the full stack+locally, which this guide is all about.## PrerequisitesRefer to the [general setup guide](./general_setup.md) for setting up theprerequisites.-## Steps+## Starting up1. Ensure you download, install and set up all prerequisites. Ensure that theDocker daemon is running.@@ -30,30 +48,53 @@ prerequisites.$ cd openverse/```-3. Install all dependencies. This is generally not advisable unless you plan to- work on everything! This step won't install API or ingestion server- dependencies because they are meant to run using Docker containers.+3. Install all dependencies. This step installs dependencies for the frontend,+ the documentation and the automations (both Node.js and Python) but won't+ install API or ingestion server dependencies because they are meant to run+ using Docker containers.```console$ just install```-4. Bring the ingestion server and API up, along with all their dependent- services. Once this is done, you should be able to see the API documentation- on [http://localhost:50280](http://localhost:50280).+ To be more specific with your install, you can run either of the following.++ ```console+ $ just node-install # only frontend and Node.js automations+ $ just py-install # only documentation and Python automations+ ```++4. Spin up and orchestrate all Docker services.```console$ just up```-5. Load the sample data. This step take a few minutes. If it fails, take down- everything with `just down -v` and start again from the previous step.+ The `up` recipe orchestrates the following services: `cache`, `db`,+ `upstream_db`, `es`, `indexer_worker`, `ingestion_server`, `web`, `proxy`,+ `plausible-ch`, `plausible-db` and `plausible`.++ Now you should be able to access the following endpoints:++ - the list of ingestion jobs on+ [http://localhost:50281/task](http://localhost:50281/task)+ - the API documentation on [http://localhost:50280](http://localhost:50280)+ - the Plausible UI on [http://localhost:50288](http://localhost:50288)++5. Load the sample data. This step can take a few minutes to complete.```console$ just init```- The ingestion server is working fine.+ ````{admonition} Troubleshooting+ If this step fails, cleaning up and restarting usually fixes it.++ ```console+ $ just down -v+ $ just api/init+ ```+ ````6. With the data loaded, the API can now return JSON responses to your HTTPrequests.@@ -65,8 +106,10 @@ prerequisites.[{"source_name":"flickr","display_name":"Flickr","source_url":"https://www.flickr.com","logo_url":null,"media_count":2500},{"source_name":"stocksnap","display_name":"StockSnap","source_url":"https://stocksnap.io","logo_url":null,"media_count":2500}]%```- If you don't have [`jq`](https://stedolan.github.io/jq/) installed, you- should, it's great. If you do, you can pipe the response through that.+ ````{tip}+ [`jq`](https://stedolan.github.io/jq/) is a tool for parsing and manipulating+ JSON data. If you have `jq` installed, you can pipe the response to it and+ transform it.```console$ just api/stats | jq '.[0]'@@ -77,34 +120,47 @@ prerequisites."logo_url": null,"media_count": 2500}++ $ just api/stats 'audio' | jq '[.[] | .source_name]'+ [+ "freesound",+ "jamendo",+ "wikimedia_audio"+ ]```- The API is working fine.+ `jq` is great, we recommend you+ [download](https://stedolan.github.io/jq/download/) it.+ ````7. To bring up the frontend, we have another `just` recipe. We have `just`- recipes for almost everything. You can open- [http://localhost:8443](http://localhost:8443) in a browser to see your very- own copy of Openverse.+ recipes for almost everything.```console$ env API_URL="http://localhost:50280" just frontend/run dev```- The frontend is working fine.+ Now you should be able to access the following endpoints:++ - the Openverse search engine frontend on+ [http://localhost:8443](http://localhost:8443)++## Shutting down++1. You can <kbd>Ctrl</kbd> + <kbd>C</kbd> to terminate the frontend process.-8. You can <kbd>Ctrl</kbd> + <kbd>C</kbd> to terminate the frontend process.- Then use another `just` recipe to bring down all the services. If you include- the `-v` flag, it'll remove all volumes too.+2. For services running inside Docker, like the API, ingestion server and+ Plausible, use another `just` recipe to bring them down.```console$ just down- $ just down -v # delete Docker volumes```-9. To see the logs for all services, you can use the `logs` recipe. To see the- logs for a particular service, pass the service name as an argument.+ ````{tip}+ If you include the `-v` flag, all Docker volumes (including their data) will+ be deleted too, which is useful in case you want a fresh start.```console- $ just logs- $ just logs web # only see logs for web+ $ just down -v```+ ````diff --git a/documentation/index.md b/documentation/index.mdindex dd1c57427..95ee87e6d 100644--- a/documentation/index.md+++ b/documentation/index.md@@ -1,8 +1,19 @@-# Openverse documentation+<img src="https://raw.githubusercontent.com/WordPress/openverse/main/brand/banner.svg" width="100%" alt="Openverse"/>+Openverse is a search engine for openly licensed media.++## Documentation++To setup your computer and install pre-requisites for developing Openverse,+refer to the [general setup guide](./guides/general_setup.md). To run the+Openverse stack locally on your computer, refer to the+[quickstart guide](./guides/quickstart.md).++```{note}This documentation is for developers who are building Openverse. If you want touse the Openverse API, you should instead refer to the[API consumer documentation](https://api.openverse.engineering/).+```## Related documentationdiff --git a/justfile b/justfileindex 16da6411e..91c879c8e 100644--- a/justfile+++ b/justfile@@ -40,17 +40,22 @@ DC_USER := env_var_or_default("DC_USER", "opener")# Dev ########-# Installs Node.js dependencies for the entire monorepo.+# Install Node.js dependencies for the entire monoreponode-install:pnpm ijust frontend/run i18n:enjust frontend/run i18n:copy-test-locales-# Install all dependencies-install: node-install+# Install Python dependences for the monorepo+py-install:just automations/python/installjust documentation/install+# Install all dependencies+install:+ just node-install+ just py-install+# Setup pre-commit as a Git hookprecommit:#!/usr/bin/env bash