docs/technical/future-repository-structure.md
This document is a work in progress which covers where things should be found and outlines how things will be organized in the GitHub Desktop source.
Note: this document will be updated over time because this will be an incremental process, with lots of unknowns, and we want to continue to ship features while doing this work
app/srcI'm going to walk through these in the order in what might look like a strange order, but hopefully it makes sense by the end.
These folders should contain modules that can be shared across any of the Webpack bundles that Desktop generates.
app/src/models - contains the shapes used in the codebase to represent
common objects. They should be immutable and plain.
app/src/lib - contains functions that do not depend on executing in a
specific environment.
In some cases, such as the main and renderer processes using IPC (inter-process
communication), we want to ensure the shapes of objects being sent are
consistent. For logic or features associated with a specific bundle and not
intended to be shared across bundles, these should follow the same pattern and
live within a models or lib folder within the given bundle directory.
I'm referring to these folders as "bundles" because our webpack config will transpile a specific file in each of these directories to generate what it needs to package and run the application.
app/src/mainModules and logic to be bundled for the main process, which is the entry point for the user to launch Desktop.
app/src/rendererModules and logic to be bundled for the renderer process, which displays the user interface and handles most of the data management in Desktop.
As the largest part of the current codebase, I've sketched out how the folders
within app/src/renderer may be organized:
There's a lot of opinions out there about how to structure React projects, but for the moment I wanted to focus on addressing these problems:
What lives in each of these folders:
components - contains the React components used in our application. I don't
have strong opinions on how to organize these, but better organizing of these
would simplify our imports elsewhere. I've also mentioned subdirectories that
might represent new groups of related components, based on existing componentslib - functions and logic specific to the renderer processlib/git - our current Git functionality, localized for use in the renderermodels - interfaces and classes specific to the renderer processstores - our existing collection of stores from lib/storesviews - these are the top-level components that we render based on the state
of the repository - repository.tsx, cloning-repository.tsx and
missing-repository.tsxThe entry point index.tsx should be available at the root, but everything else
should be moved to a more relevant location on disk.
app/src/highlighterModule and logic associated with the highlighter web worker that Desktop initializes to perform asynchronous computation of syntax highlighting in diffs.
app/src/crashModules and logic that Desktop uses to show a default UI when an unhandled error occurs that crashes the main application.
app/src/cliModule and logic to be bundled for the github command line interface that
users can enable for Desktop
Having read all that, you might be asking why do all this work if things are currently working?