You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: ARCHITECTURE.md
+13-5Lines changed: 13 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,11 +12,19 @@ Finally, LUNA is deployed using a [containerized](https://www.docker.com) [Nginx
12
12
13
13
## Code Structure
14
14
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.
16
16
17
17
## Folder Structure
18
18
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