chore: separate frontend from backend

This commit is contained in:
2025-11-13 23:28:01 +01:00
parent 9f1d4db0de
commit 17fbe1d507
91 changed files with 415 additions and 6985 deletions

View File

@@ -1,76 +1,134 @@
#+title: phundrak.com
#+title: phundrak.com frontend
#+author: Lucien Cartier-Tilet
#+email: lucien@phundrak.com
#+html: <a href="https://www.rust-lang.org/"><img src="https://img.shields.io/badge/Rust-Backend-orange.svg?style=flat-square&logo=Rust&logoColor=white" /></a>
#+html: <a href="https://nuxt.com/"><img src="https://img.shields.io/badge/Frontend-Nuxt%204-00DC82?logo=Nuxt.js&logoColor=white&style=flat-square"/></a>
#+html: <a href="https://vuejs.org/"><img src="https://img.shields.io/badge/Vue-3-42B883?logo=Vue.js&logoColor=white&style=flat-square"/></a>
#+html: <a href="https://phundrak.com"><img src="https://img.shields.io/badge/Website-phundrak.com-blue?style=flat-square&logo=buffer" /></a>
This is the frontend of =phundrak.com=, written with Nuxt.
* Introduction
This is the repository for my website [[https://phundrak.com][phundrak.com]] which contains the
code available on the =main= branch. Code available on the =develop=
branch is available at [[https://beta.phundrak.com][beta.phundrak.com]].
* Setup
* Architecture
The website follows a modern full-stack architecture:
** Environment
*** Nix Environment
If you use Nix, you can set up your environment using the [[file:flake.nix][=flake.nix=]]
file, which will give you the exact same development environment as I
use.
- *Backend*: Rust using the [[https://github.com/poem-web/poem][Poem]] web framework (located in [[file:backend/][backend/]])
- *Frontend*: Nuxt 4 + Vue 3 + TypeScript (located in [[file:frontend/][frontend/]])
** Backend
The backend is written in Rust and provides a RESTful API using the
Poem framework with OpenAPI support.
*** Running the Backend
To run the backend in development mode:
#+begin_src shell
cd backend
cargo run
#+begin_src bash
nix develop
#+end_src
To run tests:
#+begin_src shell
cd backend
cargo test
If you have [[https://direnv.net/][=direnv=]] installed, you can simply use it to automatically
enable this environment. However, I *strongly* recommend you to read the
content of the =flake.nix= file before doing so, as you should with any
Nix-defined environment you did not create.
#+begin_src bash
direnv allow .
#+end_src
For continuous testing and linting during development, use [[https://dystroy.org/bacon/][bacon]]:
#+begin_src shell
cd backend
bacon
*** Required Tools
To be able to work on this project, you need a Javascript package
manager, such as:
- =npm=
- =pnpm= (recommended)
- =yarn=
- =bun=
In my case, I use pnpm.
You can skip this if you are already using my Nix environment.
** Dependencies
Once you have your environment ready, you can now install the
projects dependencies.
#+begin_src bash
# npm
npm install
# pnpm
pnpm install
# yarn
yarn install
# bun
bun install
#+end_src
*** Building the Backend
To build the backend for production:
#+begin_src shell
cd backend
cargo build --release
* Running the Project
You are now ready to start the development server on
=http://localhost:3000=.
#+begin_src bash
# npm
npm run dev
# pnpm
pnpm dev
# yarn
yarn dev
# bun
bun run dev
#+end_src
The compiled binary will be available at =backend/target/release/backend=.
* Production
Once you are satisfied with the project, you can build the application in production mode.
** Frontend
The frontend is built with Nuxt 4, Vue 3, and TypeScript, providing a
modern single-page application experience.
#+begin_src bash
# npm
npm run build
*** Installing Dependencies
First, install the required dependencies using =pnpm=:
#+begin_src shell
cd frontend
# pnpm
pnpm build
# yarn
yarn build
# bun
bun run build
#+end_src
You can preview locally the production build too.
#+begin_src bash
# npm
npm run preview
# pnpm
pnpm preview
# yarn
yarn preview
# bun
bun run preview
#+end_src
Check out the [[https://nuxt.com/docs/getting-started/deployment][deployment documentation]] for more information.
* Known Issues
** =better-sqlite3= self-registration error
If you encounter an error stating that =better-sqlite3= does not
self-register when running =pnpm run dev=, this is typically caused by
the native module being compiled for a different Node.js version.
*Solution:* Rebuild the native module for your current Node.js version:
#+begin_src bash
# Rebuild just better-sqlite3
pnpm rebuild better-sqlite3
# Or rebuild all native modules
pnpm rebuild
# Or reinstall everything (nuclear option)
rm -rf node_modules
pnpm install
#+end_src
*** Running the Frontend
To run the frontend in development mode:
#+begin_src shell
cd frontend
pnpm dev
#+end_src
*** Building the Frontend
To build the frontend for production:
#+begin_src shell
cd frontend
pnpm build
#+end_src
The compiled version of the website can then be found in =frontend/.output=.
*Why this happens:* =better-sqlite3= contains native C++ code that
needs to be compiled for each specific Node.js version. When you
update Node.js or switch between versions, native modules need to be
rebuilt.