|
| 1 | +# Architecture of Crates.io |
| 2 | + |
| 3 | +This document is an intro to the codebase in this repo. If you want to work on a bug or a feature, |
| 4 | +hopefully after reading this doc, you'll have a good idea of where to start looking for the code |
| 5 | +you want to change. |
| 6 | + |
| 7 | +This is a work in progress. Pull requests and issues to improve this document are very welcome! |
| 8 | + |
| 9 | +## Documentation |
| 10 | + |
| 11 | +Documentation about the codebase appears in these locations: |
| 12 | + |
| 13 | +* `LICENSE-APACHE` and `LICENSE-MIT` - the terms under which this codebase is licensed. |
| 14 | +* `README.md` - Important information we want to show on the github front page. |
| 15 | +* `docs/` - Long-form documentation. |
| 16 | + |
| 17 | +## Backend - Rust |
| 18 | + |
| 19 | +The backend of crates.io is written in Rust. Most of that code lives in the *src* directory. It |
| 20 | +serves a JSON API over HTTP, and the HTTP server interface is provided by the [conduit][] crate and |
| 21 | +related crates. More information about the backend is in |
| 22 | +[`docs/BACKEND.md`](https://github.com/rust-lang/crates.io/blob/master/docs/BACKEND.md). |
| 23 | + |
| 24 | +[conduit]: https://crates.io/crates/conduit |
| 25 | + |
| 26 | +These files and directories have to do with the backend: |
| 27 | + |
| 28 | +* `build.rs` - Cargo build script |
| 29 | +* `Cargo.lock` - Locks dependencies to specific versions providing consistency across development |
| 30 | + and deployment |
| 31 | +* `Cargo.toml` - Defines the crate and its dependencies |
| 32 | +* `migrations/` - Diesel migrations applied to the database during development and deployment |
| 33 | +* `.rustfmt.toml` - Defines Rust coding style guidelines which are enforced by the CI environment |
| 34 | +* `src/` - The backend's source code |
| 35 | +* `target/` - Compiled output, including dependencies and final binary artifacts - (ignored in |
| 36 | + `.gitignore`) |
| 37 | +* `tmp/index-co` - The registry repository; in production this is cloned from Github and in |
| 38 | + development from `tmp/index-bare` - (ignored in `.gitignore`) |
| 39 | + |
| 40 | +The backend stores information in a Postgres database. |
| 41 | + |
| 42 | +## Frontend - Ember.js |
| 43 | + |
| 44 | +The frontend of crates.io is written in JavaScript using [Ember.js][]. More information about the |
| 45 | +frontend is in [`docs/FRONTEND.md`](https://github.com/rust-lang/crates.io/blob/master/docs/FRONTEND.md). |
| 46 | + |
| 47 | +[Ember.js]: https://emberjs.com/ |
| 48 | + |
| 49 | +These files have to do with the frontend: |
| 50 | + |
| 51 | +* `app/` - The frontend's source code |
| 52 | +* `config/{environment,targets}.js` - Configuration of the frontend |
| 53 | +* `dist/` - Contains the distributable (optimized and self-contained) output of building the |
| 54 | + frontend; served under the root `/` url - (ignored in `.gitignore`) |
| 55 | +* `.ember-cli` - Settings for the `ember` command line interface |
| 56 | +* `ember-cli-build.js` - Contains the build specification for Broccoli |
| 57 | +* `.eslintrc.js` - Defines Javascript coding style guidelines (enforced during CI???) |
| 58 | +* `mirage/` - A mock backend used during development and testing |
| 59 | +* `node_modules/` - npm dependencies - (ignored in `.gitignore`) |
| 60 | +* `package.json` - Defines the npm package and its dependencies |
| 61 | +* `package-lock.json` - Locks dependencies to specific versions providing consistency across |
| 62 | + development and deployment |
| 63 | +* `public/` - Static files that are merged into `dist/` during build |
| 64 | +* `testem.js` - Integration with Test'em Scripts |
| 65 | +* `tests/` - Frontend tests |
| 66 | +* `vendor/` - frontend dependencies not distributed by npm; not currently used |
| 67 | + |
| 68 | +## Deployment - Heroku |
| 69 | + |
| 70 | +Crates.io is deployed on [Heroku][https://heroku.com/]. See [`docs/MIRROR.md`][] for info about |
| 71 | +setting up your own instance on Heroku! |
| 72 | + |
| 73 | +[`docs/MIRROR.md`]: https://github.com/rust-lang/crates.io/blob/master/docs/MIRROR.md |
| 74 | + |
| 75 | +These files are Heroku-specific; if you're deploying the crates.io codebase on another platform, |
| 76 | +there's useful information in these files that you might need to translate to a different format |
| 77 | +for another platform. |
| 78 | + |
| 79 | +* `app.json` - Configuration for Heroku Deploy Button |
| 80 | +* `.buildpacks` - A list of buildpacks used during deployment |
| 81 | +* `config/nginx.conf.erb` - Template used by the nginx buildpack |
| 82 | +* `.diesel_version` - Used by diesel buildpack to install a specific version of Diesel CLI during |
| 83 | + deployment |
| 84 | +* `Procfile` - Contains process type declarations for Heroku |
| 85 | + |
| 86 | +## Development |
| 87 | + |
| 88 | +These files are mostly only relevant when running crates.io's code in development mode. |
| 89 | + |
| 90 | +* `.editorconfig` - Coding style definitions supported by some IDEs // TODO: Reference extensions |
| 91 | + for common editors |
| 92 | +* `.env` - Environment variables loaded by the backend - (ignored in `.gitignore`) |
| 93 | +* `.env.sample` - Example environment file checked into the repository |
| 94 | +* `.git/` - The git repository; not available in all deployments (e.g. Heroku) |
| 95 | +* `.gitignore` - Configures git to ignore certain files and folders |
| 96 | +* `script/init-local-index.sh` - Creates registry repositories used during development |
| 97 | +* `tmp/` - Temporary files created during development; when deployed on Heroku this is the only |
| 98 | + writable directory - (ignored in `.gitignore`) |
| 99 | +* `tmp/index-bare` - A bare git repository, used as the origin for `tmp/index-co` during |
| 100 | + development - (ignored in `.gitignore`) |
| 101 | +* `.travis.yml` - Configuration for continous integration at [TravisCI][] |
| 102 | +* `.watchmanconfig` - Use by Ember CLI to efficiently watch for file changes if you install watchman |
| 103 | + |
| 104 | +[TravisCI]: https://travis-ci.org/rust-lang/crates.io |
0 commit comments