This codebase was created to demonstrate a fully fledged fullstack application built with React and Raj including CRUD operations, authentication, routing, pagination, and more.
We've gone to great lengths to adhere to the Raj community best practices.
For more information on how to this works with other frontends/backends, head over to the RealWorld repo.
This is a Create React App app. The code lives mainly in src
:
programs
has the application pages and the navigation headerrouting
contains the router and utilities for handling links and navigationremote
handles the API businessviews
contains the shared view componentserrors
contains the error handling
Notes:
-
Side-effects are pushed to the edge of the system. The asynchronous code lives in the
remote
androuter
services. These can be swapped out with dummy services in testing. -
Error handling is accomplished with a high-order-program (HOP). We wrap each program and the
withErrors
program manages the UI bits. This works because errors are not too important in RealWorld. An app with i18n requirements would have a fair amount of hand rolled error handling. -
The links and routes are not hard-coded. We can rename routing table entries and everything would still work. Using push-state would require little changes.
-
There are quite a few ways to write a REST API integration. The
remote
contains everything, but effects can be fragmented and local to programs. The approach taken here is good, not gospel.We do not request the user on every page transition. The
remote
has internal state for caching the current user. Since this state is hidden from the application code, it is fine.
yarn install
# development
yarn start
# build
yarn run build