From 0614b23d59d2ec0f777bc4b932b6aece4aa76ad9 Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Mon, 17 Mar 2025 18:23:33 +0100 Subject: [PATCH] Initial commit --- README.md | 37 ++++++++++++++++ moneymgr_backend/.gitignore | 3 ++ moneymgr_backend/Cargo.lock | 7 +++ moneymgr_backend/Cargo.toml | 6 +++ moneymgr_backend/docker-compose.yml | 48 +++++++++++++++++++++ moneymgr_backend/docker/dex/dex.config.yaml | 26 +++++++++++ moneymgr_backend/src/main.rs | 3 ++ 7 files changed, 130 insertions(+) create mode 100644 README.md create mode 100644 moneymgr_backend/.gitignore create mode 100644 moneymgr_backend/Cargo.lock create mode 100644 moneymgr_backend/Cargo.toml create mode 100644 moneymgr_backend/docker-compose.yml create mode 100644 moneymgr_backend/docker/dex/dex.config.yaml create mode 100644 moneymgr_backend/src/main.rs diff --git a/README.md b/README.md new file mode 100644 index 0000000..7aae107 --- /dev/null +++ b/README.md @@ -0,0 +1,37 @@ +# MoneyMgr + +## Setup dev env +1. Install prerequisites: + 1. docker + 2. docker-compose + 3. rust + 4. node + +2. Start services +``` +cd moneymgr_backend +mkdir -p storage/{db,redis-data,redis-conf,minio} +docker compose up +``` + +3. Install Diesel CLI: + +```bash +sudo apt install libpq5 libpq-dev pkg-config libssl-dev cmake +cargo install diesel_cli --no-default-features --features postgres +``` + + +4. Initialize database: + +```bash +diesel migration run +``` + +> Note: You can access the database directly using this command: +> +> ```bash +> PGPASSWORD=pass psql -h localhost -p 5432 -U user -d moneymgr +> ``` + + diff --git a/moneymgr_backend/.gitignore b/moneymgr_backend/.gitignore new file mode 100644 index 0000000..f0767f5 --- /dev/null +++ b/moneymgr_backend/.gitignore @@ -0,0 +1,3 @@ +target +.idea +storage diff --git a/moneymgr_backend/Cargo.lock b/moneymgr_backend/Cargo.lock new file mode 100644 index 0000000..bc2b05d --- /dev/null +++ b/moneymgr_backend/Cargo.lock @@ -0,0 +1,7 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "moneymgr_backend" +version = "0.1.0" diff --git a/moneymgr_backend/Cargo.toml b/moneymgr_backend/Cargo.toml new file mode 100644 index 0000000..b20cac3 --- /dev/null +++ b/moneymgr_backend/Cargo.toml @@ -0,0 +1,6 @@ +[package] +name = "moneymgr_backend" +version = "0.1.0" +edition = "2024" + +[dependencies] diff --git a/moneymgr_backend/docker-compose.yml b/moneymgr_backend/docker-compose.yml new file mode 100644 index 0000000..84a69b0 --- /dev/null +++ b/moneymgr_backend/docker-compose.yml @@ -0,0 +1,48 @@ +services: + minio: + image: minio/minio + user: "1000" + environment: + - MINIO_ROOT_USER=topsecret + - MINIO_ROOT_PASSWORD=topsecret + volumes: + - ./storage/minio:/data + command: [ "minio", "server", "/data", "--console-address", ":9090" ] + ports: + - 9000:9000 + - 9090:9090 + expose: + - 9000 + + db: + image: postgres + user: "1000" + ports: + - "5432:5432" + expose: + - 5432 + environment: + - POSTGRES_USER=user + - POSTGRES_PASSWORD=pass + - POSTGRES_DB=moneymgr + volumes: + - ./storage/db:/var/lib/postgresql/data + + oidc: + image: dexidp/dex + user: "1000" + ports: + - 9001:9001 + volumes: + - ./docker/dex:/conf:ro + command: [ "dex", "serve", "/conf/dex.config.yaml" ] + + redis: + image: redis:alpine + user: "1000" + command: redis-server --requirepass ${REDIS_PASS:-secretredis} + ports: + - 6379:6379 + volumes: + - ./storage/redis-data:/data + - ./storage/redis-conf:/usr/local/etc/redis/redis.conf \ No newline at end of file diff --git a/moneymgr_backend/docker/dex/dex.config.yaml b/moneymgr_backend/docker/dex/dex.config.yaml new file mode 100644 index 0000000..5d4a047 --- /dev/null +++ b/moneymgr_backend/docker/dex/dex.config.yaml @@ -0,0 +1,26 @@ +issuer: http://127.0.0.1:9001/dex + +storage: + type: memory + +web: + http: 0.0.0.0:9001 + +oauth2: + # Automate some clicking + # Note: this might actually make some tests pass that otherwise wouldn't. + skipApprovalScreen: false + +connectors: + # Note: this might actually make some tests pass that otherwise wouldn't. + - type: mockCallback + id: mock + name: Example + +# Basic OP test suite requires two clients. +staticClients: + - id: foo + secret: bar + redirectURIs: + - http://localhost:5173/web/oidc_cb + name: Project diff --git a/moneymgr_backend/src/main.rs b/moneymgr_backend/src/main.rs new file mode 100644 index 0000000..e7a11a9 --- /dev/null +++ b/moneymgr_backend/src/main.rs @@ -0,0 +1,3 @@ +fn main() { + println!("Hello, world!"); +}