Skip to content

Walkthrough

A guide to the basic structure of the frontend.

πŸ“ public

You could add assets outside the module system here (things that won't be processed by webpack), but generally you'll just leave this folder alone.

For more information, see the Create React App Docs.

πŸ“ index.html

The base HTML file that the site is built off of. Here, you can set the page title (shown in the browser's tab), and import fonts by adding links to stylesheets. Ultimately, a <script> tag with the compiled code will be added to this file automatically during the build process.

πŸ“ favicon.ico

The icon displayed in the address bar of the browser.

πŸ“ manifest.json

Specifies basic metadata about the application, such as its name and icons.

πŸ“ robots.txt

Specifies what parts of the site web robots are allowed to crawl. We allow all web crawlers to access all content. Note that web crawlers can ignore this file (it won't stop any malware).

πŸ“ src

πŸ“ App.tsx

The central application component. In it, we handle routing. That is, depending on the user's privilege level and what path the user wanted to go to, we decide which container to render.

πŸ“ store.ts

A Redux file where we create the application store, which holds the state tree of the application. In this file, we declare relevant types (ex. C4CState), combine our reducers, define our initial state, and apply thunk middleware.

πŸ“ api

Contains the logic to access data from the backend. We use Axios to make requests to our backend.

Axios documentation to be completed.

πŸ“ apiClient.ts

Contains the routes, types, and logic to create an ApiClient object, through which users can make PrivilegeLevel.NONE requests to the backend.

πŸ“ protectedApiClient.ts

Contains the routes, types, and logic to create a ProtectedApiClient object, through which users can make PrivilegeLevel.STANDARD, PrivilegeLevel.ADMIN, and PrivilegeLevel.SUPER_ADMIN requests to the backend.

πŸ“ assets

Contains image (under images) and text (within content.tsx) assets to be used throughout the site.

πŸ“ auth

Contains all logic related to the authentication system.

πŸ“ ducks

Contains all Redux ducks related to the authentication state of the application.

πŸ“ authClient.tsx

Contains the routes, types, and logic to create an AuthClient object, through which users can make auth-related requests (ex. login, logout) to the backend.

πŸ“ axios.ts

Creates the application AxiosInstance through which all clients make requests to the backend. Contains logic related to adding authentication headers to requests and automatically refreshing the authentication tokens.

πŸ“ components

Contains presentational components that are reused across the application.

πŸ“ containers

Contains each page–their layouts and related thunks and logic.

πŸ“ utils

Contains useful types, functions, and constants that are used throughout the application.