updates
Some checks failed
Build Quartz Notes / build (push) Failing after 2m40s

This commit is contained in:
2026-06-04 14:47:44 +01:00
parent 58909ef3f1
commit 5d3ed14275
97 changed files with 3890 additions and 2266 deletions

View File

@@ -0,0 +1,102 @@
---
note type:
- note
- server
date: 2026-06-03
done: true
---
# Introduction
The original backend was written using FastAPI and has now been archived.
In replacement, I have written a Java Spring Boot backend that handles all of the API calls the domain `zainezq.com` uses.
Here is the repository for the backend:
[Link to the backend repository](https://gitea.zainezq.com/zaine/org_backend)
# Structure
The backend is structured as a typical Spring Boot application. It consists of several packages that handle different aspects of the application:
- ****Controllers****: These classes handle incoming HTTP requests and map them to appropriate service methods.
- ****Services****: These classes contain the business logic of the application.
- ****Repositories****: These classes interact with the database to perform CRUD operations.
- ****Models****: These classes represent the data structures used in the application.
The full list of API endpoints can be viewed using Swagger UI, which is available at the `/swagger-ui.html` endpoint once the application is running.
# Running the Application
The application is built using Maven. To run the application, you can utilise the `Makefile` provided in the repository.
The project is packaged as a Docker container, making it easy to deploy. You can build and run the Docker container using the following commands:
``` bash
docker compose build org_backend
docker compose up -d org_backend
# Alternatively:
docker compose down && docker compose build --no-cache && docker compose up -d
# To check logs
docker logs -f org_backend
```
# Bruno
Bruno is used for testing the backend API endpoints. It is a simple HTTP client that allows you to send requests to the backend and view the responses. I used the OpenAPI specification to generate Bruno tests for each endpoint.
# Authentication
The backend exposes public `/api/auth/register` and `/api/auth/login` endpoints. The website has a login page only; users are created through the API, then the login page stores the returned JWT in the browser.
Protected requests include:
``` text
Authorization: Bearer <jwt-token>
```
# Future?
## Integration with `notes.zainezq.com`
As the API is primarily used by `zainezq.com`, I want to think of ways that `notes.zainezq.com` could also use it. This website is used to store all my notes, and they are exported using `org-publish` in Emacs. Perhaps I could write an Emacs Lisp package that interacts with the backend API to store and retrieve notes.
Flow of how a note would be written:
1. User writes a note in `notes.zainezq.com` as org mode.
2. When the note is saved, a POST request is sent to the backend API with the note content.
3. The backend API stores the note in the database.
4. This will trigger a function that republishes the notes website to include the new note.
****Need to think more about this.****
# Update
The org-backend is no longer hosted using docker, it is now using systemd. The backend is still built using Maven, but it is now deployed as a standalone application rather than a Docker container.
Here are the commands needed:
``` bash
# To build the application
mvn clean package -DskipTests
# To run the application
java -jar target/org_backend-1.0.0-SNAPSHOT.jar
# systemctl commands
sudo systemctl start org_backend
sudo systemctl stop org_backend
sudo systemctl restart org_backend
sudo systemctl status org_backend
# To check logs
journalctl -u org_backend -f
```