Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vinvoor #14

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
96 changes: 1 addition & 95 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,12 +1,3 @@
.config
*.o
*.pyc

# gtags
GTAGS
GRTAGS
GPATH

# emacs
.dir-locals.el

Expand All @@ -21,52 +12,6 @@ GPATH
# MacOS directory files
.DS_Store

# cache dir
.cache/

# Doc build artifacts
docs/_build/
docs/doxygen_sqlite3.db

# Downloaded font files
docs/_static/DejaVuSans.ttf
docs/_static/NotoSansSC-Regular.otf

# Components Unit Test Apps files
components/**/build/
components/**/build_*_*/
components/**/sdkconfig
components/**/sdkconfig.old

# Example project files
examples/**/build/
examples/**/build_*_*/
examples/**/sdkconfig
examples/**/sdkconfig.old

# Unit test app files
tools/unit-test-app/build
tools/unit-test-app/build_*_*/
tools/unit-test-app/sdkconfig
tools/unit-test-app/sdkconfig.old

# test application build files
tools/test_apps/**/build/
tools/test_apps/**/build_*_*/
tools/test_apps/**/sdkconfig
tools/test_apps/**/sdkconfig.old

TEST_LOGS/
build_summary_*.xml

# gcov coverage reports
*.gcda
*.gcno
coverage.info
coverage_report/

test_multi_heap_host

# VS Code Settings
.vscode/

Expand All @@ -78,44 +23,5 @@ test_multi_heap_host
*.sublime-project
*.sublime-workspace

# Clion IDE CMake build & config
# IDEA files
.idea/
cmake-build-*/

# Results for the checking of the Python coding style and static analysis
.mypy_cache
flake8_output.txt

# ESP-IDF default build directory name
build

# lock files for examples and components
dependencies.lock

# managed_components for examples
managed_components

# pytest log
pytest_embedded_log/
list_job*.txt
size_info*.txt
XUNIT_RESULT*.xml

# clang config (for LSP)
.clangd

# Vale
.vale/styles/*

# pio
.pio

# sqlite
*.db

.env

# vinscant
key.txt
mfrc522.py
webrepl_cli.py
36 changes: 29 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,35 @@ Features:

Goals:

- Support check-in and check-out, keeping track of how many hours(, minutes(, seconds)) you have been in the kelder
- Cool stats :D
- Support check-in and check-out, keeping track of how many hours(, minutes(, seconds)) you have been in the kelder
- Cool stats :D

Secret goals:

- Streaks
- Data
- More Data
- Skins
- Battlepass
- Streaks
- Data
- More Data
- Skins
- Battlepass

## Structure

- `Vinscant` -> Scanner
- `Vingo` -> Backend
- `Vinvoor` -> Frontend

## How to run (for development)

### Easy & Quick

- Install Docker and Docker Compose
- Run the script `./dev.sh` with optional flags:
- `-b`: Show the output of the backend.
- `-f`: Show the output of the frontend.
- If both flags or no flags are provided, the output of both the backend and frontend are shown.

The backend is accessible at `localhost:3000`, and the frontend at `localhost:5173`.

### Manual

- Each part has it's own `README.md` with instructions on how to run.
51 changes: 51 additions & 0 deletions dev.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/bin/sh

# Exit function

ctrl_c() {
echo "-------------------------------------"
echo "Stopping all containers..."
echo "-------------------------------------"
docker-compose -f docker-compose.yml stop
exit 0
}

trap ctrl_c INT

# Parse input

backend=false
frontend=false

while getopts 'bf' flag; do
case "${flag}" in
b) backend=true ;;
f) frontend=true ;;
*) echo "Unexpected option ${flag}" ;;
esac
done

# Check for the required files

if [ ! -f vingo/.env ]; then
cp vingo/dev.env vingo/.env
fi

# Start the docker containers

docker-compose -f docker-compose.yml up -d

echo "-------------------------------------"
echo "Following logs..."
echo "Press CTRL + C to stop all containers"
echo "-------------------------------------"

if [ "$backend" = true ] && [ "$frontend" = false ]; then
docker-compose -f docker-compose.yml logs -f zess-backend
elif [ "$backend" = false ] && [ "$frontend" = true ]; then
docker-compose -f docker-compose.yml logs -f zess-frontend
else
docker-compose -f docker-compose.yml logs -f zess-backend zess-frontend
fi

docker-compose -f docker-compose.yml stop
36 changes: 36 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
services:
zess-db:
image: postgres
environment:
- POSTGRES_PASSWORD=zess
- POSTGRES_USER=postgres
- POSTGRES_DB=zess
expose:
- 5432
network_mode: host

zess-backend:
build:
context: vingo
dockerfile: Dockerfile.dev
expose:
- 4000
volumes:
- ./vingo:/backend
- backend-cache:/root/.cache/go-build
depends_on:
- zess-db
network_mode: host

zess-frontend:
build:
context: vinvoor
dockerfile: Dockerfile.dev
expose:
- 5173
volumes:
- ./vinvoor:/frontend
network_mode: host

volumes:
backend-cache:
51 changes: 51 additions & 0 deletions vingo/.air.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
root = "."
testdata_dir = "testdata"
tmp_dir = "tmp"

[build]
args_bin = []
bin = "./tmp/main"
cmd = "go build -o ./tmp/main ."
delay = 1000
exclude_dir = ["assets", "tmp", "vendor", "testdata"]
exclude_file = []
exclude_regex = ["_test.go"]
exclude_unchanged = false
follow_symlink = false
full_bin = ""
include_dir = []
include_ext = ["go", "tpl", "tmpl", "html"]
include_file = []
kill_delay = "0s"
log = "build-errors.log"
poll = false
poll_interval = 0
post_cmd = []
pre_cmd = []
rerun = false
rerun_delay = 500
send_interrupt = false
stop_on_error = false

[color]
app = ""
build = "yellow"
main = "magenta"
runner = "green"
watcher = "cyan"

[log]
main_only = false
time = false

[misc]
clean_on_exit = false

[proxy]
app_port = 0
enabled = false
proxy_port = 0

[screen]
clear_on_rebuild = false
keep_scroll = true
2 changes: 2 additions & 0 deletions vingo/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.env
tmp/
10 changes: 10 additions & 0 deletions vingo/Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM golang:1.22.1-alpine3.19

WORKDIR /backend

RUN go install github.com/air-verse/air@latest
COPY .air.toml .

COPY go.mod go.sum ./

CMD go mod tidy && air -c .air.toml
2 changes: 2 additions & 0 deletions vingo/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Vingo

The webserver that keeps track of the scans :D

Register a scan by posting `card_serial;scan_key` to the `/scans` endpoint.
Expand All @@ -7,6 +8,7 @@ Register a scan by posting `card_serial;scan_key` to the `/scans` endpoint.
To register a card, click the "Start registering a new card" button in the cards view, after which the server will register the next scanned card for the user that initiated the request. Only 1 user can register a card at a time.

## How to run (for development)

- install go
- install docker
- `docker run --name zess-postgres -e POSTGRES_PASSWORD=zess -d -p 5432:5432 postgres`
Expand Down
6 changes: 6 additions & 0 deletions vinscant/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
key.txt
mfrc522.py
webrepl_cli.py

# ESP-IDF default build directory name
build
12 changes: 8 additions & 4 deletions vinscant/README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
ono

# Hardware:

- ESP32-S2
- RFID-RC522

Connect RFID-RC522 Rfid reader on these pins:

```
SDA/CS: 34
MOSI: 35
Expand All @@ -14,19 +16,21 @@ RST: 16
```

# Setup:

- If you're on windows and the board is not detected: install the ESP32-S2 toolchain from https://dl.espressif.com/dl/esp-idf/
- Or just install the usb chip driver for your board (eg. for CP2102N: https://www.silabs.com/developers/usb-to-uart-bridge-vcp-drivers?tab=downloads)
- Or just install the usb chip driver for your board (eg. for CP2102N: https://www.silabs.com/developers/usb-to-uart-bridge-vcp-drivers?tab=downloads)
- Install micropython
- Get binary for correct chip. Current: https://micropython.org/download/ESP32_GENERIC_S2/
- install using commands on that website
- Get binary for correct chip. Current: https://micropython.org/download/ESP32_GENERIC_S2/
- install using commands on that website
- connect to serial
- connect to wifi and setup webrepl (see https://docs.micropython.org/en/latest/esp8266/tutorial/repl.html)
- get `webrepl_cli.py` from https://github.com/micropython/webrepl
- copy `boot.py`, `main.py` and `key.txt` (with the correct key set on vingo) to the microcontroller using `upload_file.sh`
- download https://github.com/danjperron/micropython-mfrc522/blob/master/mfrc522.py and copy it to the microcontroller as well
- download https://github.com/danjperron/micropython-mfrc522/blob/master/mfrc522.py and copy it to the microcontroller as well
- beep boop

# Future additions

- Beeps
- Boops
- Status light based on server response
Expand Down
18 changes: 18 additions & 0 deletions vinvoor/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
module.exports = {
root: true,
env: { browser: true, es2020: true },
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:react-hooks/recommended',
],
ignorePatterns: ['dist', '.eslintrc.cjs'],
parser: '@typescript-eslint/parser',
plugins: ['react-refresh'],
rules: {
'react-refresh/only-export-components': [
'warn',
{ allowConstantExport: true },
],
},
}
Loading