Skip to content

nck974/diogenes

Repository files navigation

Diogenes

codecov

Logo

Diogenes is an inventory web application designed to help you manage and keep track of your possessions at home. It is completely self-hosted, and no data is collected from users. You have the flexibility to easily migrate your data using the API, which is detailed in the Open API documentation provided by the backend server.

This app is intended to assist you in cataloging everything you own, helping you avoid the clutter often associated with Diogenes Syndrome.

The application goal is to provide a faster and more user-friendly alternative to managing your belongings compared to a plain Excel spreadsheet

Usage

Docker

  1. Pull the project or download the docker-compose.yaml and .example.env.
  2. Create a copy of the example.env into a .env file with your own passwords (NOTE: Make sure the TOKEN_SECRET is at least 32 characters long).
  3. Add a certificate or create a self signed one for local network. Put them inside ssl/cert.pem and ssl/cert.key:
openssl req -new -x509 -days 365 -noenc -out ssl/cert.pem -keyout ssl/cert.key
  1. Start the containers with docker-compose up -d
  2. The latest images can be found in the diogenes and diogenes-ng

Users

  1. The default user is username: test1, password: test1.

  2. It can be modified by generating a new bcrypt hash which can be generated from a site like https://bcrypt-generator.com/:

  3. First copy the hash and username to the following command into a new file named token.tmp. (Make sure to copy it after {bcrypt}).

UPDATE public.users SET username='test1', password_hash='{bcrypt}$2a$12$8VhADH4b.DnQqSxPa/3BeOxgyl9lD2IT7NrynrZjBACTdJdny1ZNG', active=true WHERE id=1;
  1. Copy and execute the update in the container and then delete the file
docker cp token.tmp diogenes-db:/tmp
docker exec diogenes-db sh -c "psql diogenes_db -U <YOUR_POSTGRES_USER> -f /tmp/token.tmp"
docker exec -it diogenes-db rm /tmp/token.tmp
  1. To add an extra user change the command in the file to insert into and map the role in the table user_roles to the id of the new user.
INSERT INTO public.users
  (username, password_hash, active)
VALUES('test1', '{bcrypt}$2a$12$8VhADH4b.DnQqSxPa/3BeOxgyl9lD2IT7NrynrZjBACTdJdny1ZNG', true);

INSERT INTO public.user_roles
    (user_id, role_id)
VALUES(<ID_OF_THE_USER>, 1);

Development

Backend

This project was generated using as base start spring:

https://start.spring.io/#!type=maven-project&language=java&platformVersion=3.0.4&packaging=jar&jvmVersion=17&groupId=io.nck&artifactId=diogenes&name=diogenes&description=Demo%20project%20for%20Spring%20Boot&packageName=io.nck.diogenes&dependencies=web]
  1. Download maven apache-maven-3.9.1 and add it to the path.
  2. Configure the JAVA_HOME pointing to the folder of the JDK17.
    1. In windows with a ENVIRONMENT_VARIABLE (Can be added from path menu).
    2. In UNIX exporting with export JAVA_HOME.

Run tests

  1. Execute cd diogenes & .\mvnw test.

Coverage

  1. Execute cd diogenes && mvn test jacoco:report.
  2. The report will be generated in diogenes\target\site\jacoco\index.html.

Create backend docker container

  1. First build the image with cd diogenes && ./mvnw install.
  2. Build the container with cd .. && docker build -f docker/Dockerfile -t nck974/diogenes:0.0.8 .
  3. Generate a token in https://hub.docker.com and login with docker login -u <user>. Paste the generated token as password.
  4. Push the generated container with docker push nck974/diogenes:0.0.8.
  5. Create the latest tag and push it:
docker tag nck974/diogenes:0.0.8 nck974/diogenes:latest
docker push nck974/diogenes:latest
  1. Run the image with docker compose to pass the environment variables of the database.

Frontend

To run the app in development mode just access the folder diogenes-ng and start the app with ng serve.

Create frontend docker container

  1. Build the container with docker build -f docker/Dockerfile.angular -t nck974/diogenes-ng:0.0.8 .
  2. Generate a token in https://hub.docker.com and login with docker login -u <user>. Paste the generated token as password.
  3. Push the generated container with docker push nck974/diogenes-ng:0.0.8.
  4. Create the latest tag and push it:
docker tag nck974/diogenes-ng:0.0.8 nck974/diogenes-ng:latest
docker push nck974/diogenes-ng:latest
  1. Run the image with docker compose to pass the environment variables of the database.

Checking updates

  1. Install:
npm install -g npm-check-updates
  1. Then:
ncu -u

Reverse proxy

  1. Backend and frontend can be served using a custom reverse proxy or just use the one provided in the image. To do so build it with:

  2. Build the container with docker build -f docker/Dockerfile.nginx -t nck974/diogenes-reverse-proxy:0.0.2 .

  3. Generate a token in https://hub.docker.com and login with docker login -u <user>. Paste the generated token as password.

  4. Push the generated container with docker push nck974/diogenes-reverse-proxy:0.0.2.

  5. Create the latest tag and push it:

docker tag nck974/diogenes-reverse-proxy:0.0.2 nck974/diogenes-reverse-proxy:latest
docker push nck974/diogenes-reverse-proxy:latest

TOC generated from ecotrust-canada