This document is an intro to the codebase in this repo. If you want to work on a bug or a feature, hopefully after reading this doc, you'll have a good idea of where to start looking for the code you want to change.
This is a work in progress. Pull requests and issues to improve this document are very welcome!
Documentation about the codebase appears in these locations:
LICENSE-APACHE
andLICENSE-MIT
- the terms under which this codebase is licensed.README.md
- Important information we want to show on the github front page.docs/
- Long-form documentation.
The backend of crates.io is written in Rust. Most of that code lives in the src directory. It
serves a JSON API over HTTP, and the HTTP server interface is provided by the axum crate and
related crates. More information about the backend is in
docs/BACKEND.md
.
These files and directories have to do with the backend:
build.rs
- Cargo build scriptCargo.lock
- Locks dependencies to specific versions providing consistency across development and deploymentCargo.toml
- Defines the crate and its dependenciesmigrations/
- Diesel migrations applied to the database during development and deployment.rustfmt.toml
- Defines Rust coding style guidelines which are enforced by the CI environmentsrc/
- The backend's source codetarget/
- Compiled output, including dependencies and final binary artifacts - (ignored in.gitignore
)
The backend stores information in a Postgres database.
The frontend of crates.io is written in JavaScript using Ember.js. More information about the
frontend is in docs/FRONTEND.md
.
These files have to do with the frontend:
app/
- The frontend's source codeconfig/{environment,targets}.js
- Configuration of the frontenddist/
- Contains the distributable (optimized and self-contained) output of building the frontend; served under the root/
url - (ignored in.gitignore
).ember-cli
- Settings for theember
command line interfaceember-cli-build.js
- Contains the build specification for Broccoli.eslintrc.js
- Defines Javascript coding style guidelines (enforced during CI???)mirage/
- A mock backend used during development and testingnode_modules/
- npm dependencies - (ignored in.gitignore
)package.json
- Defines the npm package and its dependenciespackage-lock.json
- Locks dependencies to specific versions providing consistency across development and deploymentpublic/
- Static files that are merged intodist/
during buildtestem.js
- Integration with Test'em Scriptstests/
- Frontend testsvendor/
- frontend dependencies not distributed by npm; not currently used
crates.io is deployed on Heroku.
These files are Heroku-specific; if you're deploying the crates.io codebase on another platform, there's useful information in these files that you might need to translate to a different format for another platform.
.buildpacks
- A list of buildpacks used during deploymentconfig/nginx.conf.erb
- Template used by the nginx buildpack.diesel_version
- Used by diesel buildpack to install a specific version of Diesel CLI during deploymentProcfile
- Contains process type declarations for Heroku
These files are mostly only relevant when running crates.io's code in development mode.
.editorconfig
- Coding style definitions supported by some IDEs- EditorConfig for VS Code
- EditorConfig for JetBrains IDEs
- More plugins are available at: https://editorconfig.org/#download
.env
- Environment variables loaded by the backend - (ignored in.gitignore
).env.sample
- Example environment file checked into the repository.git/
- The git repository; not available in all deployments (e.g. Heroku).gitignore
- Configures git to ignore certain files and folderslocal_uploads/
- Serves crates and readmes that are published to the local development environmentscript/init-local-index.sh
- Creates registry repositories used during developmenttmp/
- Temporary files created during development; when deployed on Heroku this is the only writable directory - (ignored in.gitignore
)tmp/index-bare
- A bare git repository during development - (ignored in.gitignore
).github/workflows/*
- Configuration for continuous integration at GitHub Actions.watchmanconfig
- Use by Ember CLI to efficiently watch for file changes if you install watchman