When working with these tools, keep in mind that make is sensitive to working directory. If you're in the wrong directory, make will not work as expected. Always make sure you're in the right directory when running make commands.
For future development, the database will be migrated to a more robust database such as PostgreSQL. This will require a few changes to the code, but the migration should be fairly simple. Practical difference for the programmer is the requirement of a running PostgreSQL server, for which a container can be used.
For initializing the database, simply navigate to the backend directory and run `make migrate`, which will create the database and the necessary tables.
The server works by serving the frontend as static files and providing an API for the frontend to communicate with, but when running the server, the frontend is not built. To build it, refer to the [frontend section](#building-for-production).
The frontend code might look very intimidating at first, but it's actually quite simple. The vast majority of the code is boilerplate and configuration.
The important parts resides in the `src` directory, which contains the actual React components and corresponding styles.
The frontend is built using Vite with React. Vite can initially seem like a convoluted mess of a build tool, but it's job essentially boils down to two things: bundling and hot reloading. The final output is static html, css, and javascript files that can be served by any web server.
First, you need to pull in the dependencies by running `npm install` in the frontend directory.
To spin up the development server, run `npm run dev`. This will start the development server on `localhost:3000`. Note that the backend server should be running for the frontend to work.
To **build** the frontend, resulting in a static bundle, you need to navigate to the frontend directory and run `npm run build`. This will create a static bundle in the `frontend/dist` directory, which the server can serve. The `frontend/dist` will have to be moved/renamed to `backend/static` for the full application to work. These steps are automated when building the final release container.
The release build for the backend is a simple binary that can be run on any machine. The release build for the frontend is a static bundle that can be served by any web server.
We combine the frontend and backend into a single container using Podman/Docker. The `Containerfile` (also known as a Dockerfile) in the container directory is used to build the container. To see exactly how the container is built, refer to the `Containerfile`.
To build and reploy a release container with Podman, issue the `just start-release` command anywhere in the project directory. This will build the container and run it on `localhost:8080`. The container will be running in the background, and you can manage it with Podman see the podman documentation for more information.