LW Open Source – Overview of the Codebase

post by Raemon · 2018-05-16T23:50:35.108Z · LW · GW · 3 comments

Contents

  The Ties That Bind
    ~/packages/lesswrong
  The lesswrong package structure
    The lib folder
  Up Next...
None
3 comments

If you’re interested in making longterm, serious contributions to the LessWrong codebase, it’ll be helpful to know some of the gritty details of how the codebase fits together.

This is an overview of the file structure – some of the root files that bind the application together, and the most important folders of the lesswrong package in particular.

The Ties That Bind

Understanding the “glue” files that connect the app together.

After you’ve gotten a local server up and running, take a look at these files in the root directory:

package.json – This is the npm manager. In addition to telling npm install which node packages to download, it has a new scripts that you’ll want to run the application

sample_settings.json – These are the default settings, which doesn’t come with any passwords, or connections to our mongo database or galaxy server.

settings.json – Automatically generated from sample_settings.json. If you’re doing longterm development and are trusted by the site admins, we can send you credentials for the either the development or production server/database.

You’ll also see these folders:

node_modules/ – where all node modules are installed

packages/ – where all vulcanJS packages live.

~/packages/lesswrong

This is where most of our code lives.

Each vulcanJS package has a package.js file , which initializes the package. Glancing inside packages/lesswrong/package.js, you’ll see:

And then you’ll find:

One last layer of “glue” files exists inside the lib folder: the aforementioned index.js , which in turn imports components.js (as well as all other .js files)

If you've written some new files and your code isn't working, there's a good chance you forgot to import those files into components.js or index.js (depending on whether they're a React component or a general javascript file).

The lesswrong package structure

In the lesswrong package folder, you'll the following folders:

The lib folder

The lib folders contains some legacy files that aren't really in use (or are unlikely to be relevant). Folders that I do expect to be important to you are:

The lib folder also contains some files. The one you'll most likely need to refer to is routes.js, which establishes the url routing for the site.

Up Next...

To really get started, you'll want to understand our collections and components folders – the bulk of our codebase. These are complex enough that I'll be covering them in a separate post.

3 comments

Comments sorted by top scores.

comment by Robert Miles (robert-miles) · 2021-10-26T20:15:01.938Z · LW(p) · GW(p)

Is there a public-facing API endpoint for the Algolia search system? I'd love to be able to say to my discord bot "Hey wasn't there a lesswrong post about xyz?" and have him post a few links

Replies from: habryka4
comment by habryka (habryka4) · 2021-10-27T03:25:15.780Z · LW(p) · GW(p)

Pretty sure you should just be able to copy the structure of the query from the Chrome network tab, and reverse engineer it this way. IIRC the structure was pretty straightforward, and the response pretty well structured.

Replies from: robert-miles
comment by Robert Miles (robert-miles) · 2021-10-27T10:43:44.293Z · LW(p) · GW(p)

Ah ok, thanks! My main concern with that is that it goes to "https://z0gr6exqhd-dsn.algolia.net", which feels like it could be a dynamically allocated address that might change under me?