Skip to content

Commit cada1e5

Browse files
committed
Add overview of folder structure
1 parent 3da0897 commit cada1e5

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

ARCHITECTURE.md

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,19 @@ Finally, LUNA is deployed using a [containerized](https://www.docker.com) [Nginx
1212

1313
## Code Structure
1414

15-
The top-level [`App.tsx`](https://github.com/ProjectLighthouseCAU/luna/blob/main/src/App.tsx) hosts the root component for the app. This mainly wraps a number of [context](https://react.dev/learn/passing-data-deeply-with-context) providers for all state that is managed globally (e.g. the color scheme, auth/model server connections, persisted UI state like user pins etc.). Peeling away these wrappers, we get the "actual" root component, namely `<RouterProvider>`. This presents a view based on the path in the URL. These views are called "screens" in our terminology and are discussed in detail below.
15+
The top-level [`App.tsx`](https://github.com/ProjectLighthouseCAU/luna/blob/main/src/App.tsx) hosts the root component for the app. This mainly wraps a number of [context](https://react.dev/learn/passing-data-deeply-with-context) providers for all state that is managed globally (e.g. the color scheme, auth/model server clients, persisted UI state like user pins etc.). Peeling away these wrappers, we get the "actual" root component, namely `<RouterProvider>`. This presents a view based on the path in the URL. These views are called "screens" in our terminology and are discussed in detail below.
1616

1717
## Folder Structure
1818

19-
The file structure is based on the ["grouping by file type"](https://legacy.reactjs.org/docs/faq-structure.html#grouping-by-file-type) convention.
20-
21-
<!-- TODO: Detailed discussion of folders -->
22-
19+
The basic folder structure is based on the ["grouping by file type"](https://legacy.reactjs.org/docs/faq-structure.html#grouping-by-file-type) convention and contains the following top-level folders:
20+
21+
| Name | Description |
22+
| ---- | ----------- |
23+
| `/components` | Reusable, isolated components that usually don't depend on contexts or similar |
24+
| `/constants` | Enums and other constants that are used globally |
25+
| `/contexts` | Custom [React contexts](https://react.dev/learn/passing-data-deeply-with-context) for global state. Examples include `AuthContext` and `ModelContext`, which manage connections to the auth API and the model server, respectively. UI state (e.g. the color scheme, user pins etc.) is also managed through a context, usually either because it is persisted to the user's [local storage](https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage) (e.g. user pins) or because it's global (e.g. display search). |
26+
| `/hooks` | Custom [React hooks](https://react.dev/reference/react/hooks), i.e. simple functions that abstract over other hooks. These are used for a wide variety of things that _refer_ to something stateful (anything that can be expressed in terms of the built-in hooks like `useState`, `useContext`, ...). Convenient examples include `useStream`, which automatically creates/manages a stream to some model server resource. |
27+
| `/modals` | Modal components (i.e. popups) |
28+
| `/routes` | Constants declaring the route tree with its components. Add new routes here. |
29+
| `/screens` | Screen components, i.e. generally non-reusable top-level views |
30+
| `/utils` | Reusable utility functionality that generally doesn't depend on React |

0 commit comments

Comments
 (0)