Skip to content

Commit

Permalink
First version
Browse files Browse the repository at this point in the history
  • Loading branch information
hugoboos committed May 23, 2024
1 parent 911424b commit 85cdba2
Show file tree
Hide file tree
Showing 72 changed files with 6,301 additions and 0 deletions.
43 changes: 43 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
IMAGE_BASE=ghcr.io/minbzk/logboek-dataverwerkingen-demo

MUNERA_IMAGE=${IMAGE_BASE}/munera:latest
CURRUS_IMAGE=${IMAGE_BASE}/currus:latest
LAMINA_IMAGE=${IMAGE_BASE}/lamina:latest
LOGBOEK_IMAGE=ghcr.io/minbzk/logboek-dataverwerkingen-logboek:latest
CASSANDRA_IMAGE=cassandra:4.1
GRAFANA_IMAGE=grafana/grafana:10.3.6

## Munera - Logboek
#
MUNERA_LOGBOEK_PORT=9001
MUNERA_LOGBOEK_LISTEN_ADDRESS=":${MUNERA_LOGBOEK_PORT}"

## Munera
#
MUNERA_PORT=8080
MUNERA_INSTANCE_DIR=/var/lib/munera
MUNERA_ALLOWED_HOSTS=127.0.0.1,localhost
MUNERA_CURRUS_URL=http://currus:8081
MUNERA_LOGBOEK_ENDPOINT=munera-logboek:${MUNERA_LOGBOEK_PORT}


## Currus - Logboek
#
CURRUS_LOGBOEK_PORT=9002
CURRUS_LOGBOEK_LISTEN_ADDRESS=":${CURRUS_LOGBOEK_PORT}"

## Currus
#
CURRUS_LISTEN_ADDRESS=0.0.0.0:8081
CURRUS_LAMINA_URL=http://lamina:8082
CURRUS_LOGBOEK_ENDPOINT=currus-logboek:${CURRUS_LOGBOEK_PORT}

## Lamina - Logboek
#
LAMINA_LOGBOEK_PORT=9003
LAMINA_LOGBOEK_LISTEN_ADDRESS=":${LAMINA_LOGBOEK_PORT}"

## Lamina
#
LAMINA_LISTEN_ADDRESS=0.0.0.0:8082
LAMINA_LOGBOEK_ENDPOINT=lamina-logboek:${LAMINA_LOGBOEK_PORT}
40 changes: 40 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Build

on:
push:
branches:
- develop
workflow_dispatch:

env:
IMAGE_REGISTRY: ghcr.io
IMAGE_REPOSITORY: minbzk/logboek-dataverwerkingen-demo

jobs:
build-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
strategy:
fail-fast: false
matrix:
app:
- munera
- currus
- lamina
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Login to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.IMAGE_REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v5
with:
context: ./apps/${{ matrix.app }}
push: true
tags: ${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_REPOSITORY }}/${{ matrix.app }}:latest
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.DS_Store

*.pyc
__pycache__

venv

db.sqlite3
25 changes: 25 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
.PHONY: start
start:
docker compose up --detach --remove-orphans
@echo ""
@echo "Logboek dataverwerkingen demo is gestart."
@echo "Ga naar http://localhost:8080 voor de "Mijn Gemeente"-applicatie"
@echo "Inloggen kan met het account:"
@echo " Gebruikersnaam: burger"
@echo " Wachtwoord: demo123"
@echo ""
@echo "Bekijk het logboek:"
@echo " http://localhost:3000"


.PHONY: stop
stop:
docker compose stop

.PHONY: build
build:
docker compose build

.PHONY: clean
clean:
docker compose down --volumes --remove-orphans
28 changes: 28 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,34 @@
Een demo hoe de standaard [Logboek dataverwerkingen](https://github.com/MinBZK/logboek-dataverwerkingen) ingezet kan worden.


## Componenten

Deze demo bestaat uit de volgede componenten (te vinden in de `apps` directory):

- **[munera](./apps/munera)**: een fictive Mijn Gemeente-omgeving waar burgers gemeentezaken kunnen regelen;
- **[currus](./apps/currus)**: een API voor het beheren van parkeervergunningen;
- **[lamina](./apps/lamina)**: een API voor het beschiknbaar stellen van registratiegegevens van voertuigen.


## Gebruik

Voor het starten van de demo zijn Docker en [Docker Compose](https://docs.docker.com/compose/install/) nodig.

1. Maak een kopie van deze repository:
```sh
git clone https://github.com/MinBZK/logboek-dataverwerkingen-demo.git

cd logboek-dataverwerkingen-demo
```

1. Start de demo:
```sh
make start
```

1. Navigeer naar <http://localhost:8080/>. Aanmelden kan met de gebruikersnaam `burger02` en wachtwoord `demo123`.


## License

Licensed under EUPL v1.2
20 changes: 20 additions & 0 deletions apps/currus/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
FROM golang:1.22.3-alpine AS build

WORKDIR /app

RUN apk add --no-cache git

COPY go.mod go.sum .
RUN go mod download -x

COPY server server
COPY main.go .

RUN go install -ldflags "-s -w" -v .


FROM alpine:3.20.0

COPY --from=build /go/bin/ /usr/local/bin

ENTRYPOINT ["/usr/local/bin/currus"]
3 changes: 3 additions & 0 deletions apps/currus/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Currus

Een parkeervergunningen demo-API.
19 changes: 19 additions & 0 deletions apps/currus/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
module github.com/MinBZK/logboek-dataverwerkingen-demo/apps/currus

go 1.22

require (
github.com/MinBZK/logboek-dataverwerkingen-logboek/libs/logboek-go v0.0.0-20240523101530-e69b156ed96c
github.com/go-chi/chi/v5 v5.0.12
github.com/go-chi/render v1.0.3
)

require (
github.com/ajg/form v1.5.1 // indirect
golang.org/x/net v0.25.0 // indirect
golang.org/x/sys v0.20.0 // indirect
golang.org/x/text v0.15.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240521202816-d264139d666e // indirect
google.golang.org/grpc v1.63.2 // indirect
google.golang.org/protobuf v1.34.1 // indirect
)
30 changes: 30 additions & 0 deletions apps/currus/go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
github.com/MinBZK/logboek-dataverwerkingen-logboek/libs/logboek-go v0.0.0-20240523101530-e69b156ed96c h1:mWHjmPKbsRuOUschV8AUCxOIFEWjWQcFD5GS/4TcRx4=
github.com/MinBZK/logboek-dataverwerkingen-logboek/libs/logboek-go v0.0.0-20240523101530-e69b156ed96c/go.mod h1:DmEj9fpw5HlQ7J8vn2nAZ/LlXHw7EA5WIpm161lUvRk=
github.com/ajg/form v1.5.1 h1:t9c7v8JUKu/XxOGBU0yjNpaMloxGEJhUkqFRq0ibGeU=
github.com/ajg/form v1.5.1/go.mod h1:uL1WgH+h2mgNtvBq0339dVnzXdBETtL2LeUXaIv25UY=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/go-chi/chi/v5 v5.0.12 h1:9euLV5sTrTNTRUU9POmDUvfxyj6LAABLUcEWO+JJb4s=
github.com/go-chi/chi/v5 v5.0.12/go.mod h1:DslCQbL2OYiznFReuXYUmQ2hGd1aDpCnlMNITLSKoi8=
github.com/go-chi/render v1.0.3 h1:AsXqd2a1/INaIfUSKq3G5uA8weYx20FOsM7uSoCyyt4=
github.com/go-chi/render v1.0.3/go.mod h1:/gr3hVkmYR0YlEy3LxCuVRFzEu9Ruok+gFqbIofjao0=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
golang.org/x/net v0.25.0 h1:d/OCCoBEUq33pjydKrGQhw7IlUPI2Oylr+8qLx49kac=
golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM=
golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y=
golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/text v0.15.0 h1:h1V/4gjBv8v9cjcR6+AR5+/cIYK5N/WAgiv4xlsEtAk=
golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240521202816-d264139d666e h1:Elxv5MwEkCI9f5SkoL6afed6NTdxaGoAo39eANBwHL8=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240521202816-d264139d666e/go.mod h1:EfXuqaE1J41VCDicxHzUDm+8rk+7ZdXzHV0IhO/I6s0=
google.golang.org/grpc v1.63.2 h1:MUeiw1B2maTVZthpU5xvASfTh3LDbxHd6IJ6QQVU+xM=
google.golang.org/grpc v1.63.2/go.mod h1:WAX/8DgncnokcFUldAxq7GeB5DXHDbMF+lLvDomNkRA=
google.golang.org/protobuf v1.34.1 h1:9ddQBjfCyZPOHPUiPxpYESBLc+T8P3E+Vo4IbKZgFWg=
google.golang.org/protobuf v1.34.1/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
49 changes: 49 additions & 0 deletions apps/currus/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package main

import (
"flag"
"log"
"os"

"github.com/MinBZK/logboek-dataverwerkingen-demo/apps/currus/server"
)

type options struct {
listenAddress string
apiBasePath string
laminaURL string
logboekEndpoint string
}

func parseFlags() *options {
o := &options{}
flag.StringVar(&o.listenAddress, "listen-address", envValue("LISTEN_ADDRESS", "127.0.0.1:8081"), "Listen address")
flag.StringVar(&o.laminaURL, "lamina-url", envValue("LAMINA_URL", "http://127.0.0.1:8082"), "Base URL to Lamina")
flag.StringVar(&o.logboekEndpoint, "logboek-endpoint", envValue("LOGBOEK_ENDPOINT", "127.0.0.1:9000"), "Address of a logboek server")

flag.Parse()

return o
}

func main() {
o := parseFlags()

srv, err := server.New(o.listenAddress, o.apiBasePath, o.laminaURL, o.logboekEndpoint)
if err != nil {
log.Fatalf("Creating server: %v", err)
}

log.Println("Starting server...")
if err := srv.Start(); err != nil {
log.Fatal(err)
}
}

func envValue(key, defaultValue string) string {
value := os.Getenv(key)
if value == "" {
return defaultValue
}
return value
}
55 changes: 55 additions & 0 deletions apps/currus/server/db.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package server

import (
"time"
)

var permits = []*ParkingPermit{
{"2cdB1AxNITm0A01PfMIlLiyUsoe", "686242", "999995042", "H358BH", newDate(2023, 10, 10), newDate(2024, 10, 9)},
{"2cdB19Dd3PM9Snrk2EIiuO0u115", "278322", "999995042", "9ZTJ69", newDate(2024, 1, 8), newDate(2024, 8, 10)},
{"2cdB1Fd1USUEdVG45oPqgTviipn", "302957", "999993161", "ZV326K", newDate(2023, 10, 10), newDate(2024, 10, 9)},
{"2cdB18iPqsH00bvQxsjxjtMablt", "846739", "999993914", "XRBS57", newDate(2023, 10, 10), newDate(2024, 10, 9)},
}

type DB struct {
permits map[string][]*ParkingPermit
}

func NewDB() *DB {
db := &DB{
permits: make(map[string][]*ParkingPermit),
}

for _, p := range permits {
db.permits[p.OwnerBSN] = append(db.permits[p.OwnerBSN], p)
}

return db
}

type ParkingPermit struct {
ID string `json:"id"`
PermitNumber string `json:"permit_number"`
OwnerBSN string `json:"owner_bsn"`
RegistrationNumber string `json:"registration_number"`
ValidFrom time.Time `json:"valid_from"`
ValidTo time.Time `json:"valid_to"`
}

func (db *DB) ListParkingPermits(bsn string) []*ParkingPermit {
return db.permits[bsn]
}

func (db *DB) GetParkingPermit(bsn, id string) *ParkingPermit {
for _, p := range db.permits[bsn] {
if p.ID == id {
return p
}
}

return nil
}

func newDate(year int, month time.Month, day int) time.Time {
return time.Date(year, month, day, 0, 0, 0, 0, time.Local)
}
Loading

0 comments on commit 85cdba2

Please sign in to comment.