feat(domain): add core entities — Club, Member, WorkItem, Shift with state machine
- Create domain entities in WorkClub.Domain/Entities: Club, Member, WorkItem, Shift, ShiftSignup - Implement enums: SportType, ClubRole, WorkItemStatus - Add ITenantEntity interface for multi-tenancy support - Implement state machine validation on WorkItem with C# 14 switch expressions - Valid transitions: Open→Assigned→InProgress→Review→Done, Review→InProgress (rework) - All invalid transitions throw InvalidOperationException - TDD approach: Write tests first, 12/12 passing - Use required properties with explicit Guid/Guid? for foreign keys - DateTimeOffset for timestamps (timezone-aware, multi-tenant friendly) - RowVersion byte[] for optimistic concurrency control - No navigation properties yet (deferred to EF Core task) - No domain events or validation attributes (YAGNI for MVP)
This commit is contained in:
74
infra/k8s/base/backend-deployment.yaml
Normal file
74
infra/k8s/base/backend-deployment.yaml
Normal file
@@ -0,0 +1,74 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: workclub-api
|
||||
labels:
|
||||
app: workclub-api
|
||||
component: backend
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app: workclub-api
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: workclub-api
|
||||
component: backend
|
||||
spec:
|
||||
containers:
|
||||
- name: api
|
||||
image: workclub-api:latest
|
||||
imagePullPolicy: IfNotPresent
|
||||
ports:
|
||||
- name: http
|
||||
containerPort: 8080
|
||||
protocol: TCP
|
||||
startupProbe:
|
||||
httpGet:
|
||||
path: /health/startup
|
||||
port: http
|
||||
initialDelaySeconds: 5
|
||||
periodSeconds: 10
|
||||
timeoutSeconds: 5
|
||||
failureThreshold: 30
|
||||
livenessProbe:
|
||||
httpGet:
|
||||
path: /health/live
|
||||
port: http
|
||||
initialDelaySeconds: 10
|
||||
periodSeconds: 15
|
||||
timeoutSeconds: 5
|
||||
failureThreshold: 3
|
||||
readinessProbe:
|
||||
httpGet:
|
||||
path: /health/ready
|
||||
port: http
|
||||
initialDelaySeconds: 5
|
||||
periodSeconds: 10
|
||||
timeoutSeconds: 5
|
||||
failureThreshold: 2
|
||||
|
||||
resources:
|
||||
requests:
|
||||
cpu: 100m
|
||||
memory: 256Mi
|
||||
limits:
|
||||
cpu: 500m
|
||||
memory: 512Mi
|
||||
|
||||
env:
|
||||
- name: ASPNETCORE_ENVIRONMENT
|
||||
value: "Development"
|
||||
- name: ASPNETCORE_URLS
|
||||
value: "http://+:8080"
|
||||
- name: ConnectionStrings__DefaultConnection
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: workclub-secrets
|
||||
key: database-connection-string
|
||||
- name: Keycloak__Url
|
||||
valueFrom:
|
||||
configMapKeyRef:
|
||||
name: workclub-config
|
||||
key: keycloak-url
|
||||
16
infra/k8s/base/backend-service.yaml
Normal file
16
infra/k8s/base/backend-service.yaml
Normal file
@@ -0,0 +1,16 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: workclub-api
|
||||
labels:
|
||||
app: workclub-api
|
||||
component: backend
|
||||
spec:
|
||||
type: ClusterIP
|
||||
selector:
|
||||
app: workclub-api
|
||||
ports:
|
||||
- name: http
|
||||
port: 80
|
||||
targetPort: 8080
|
||||
protocol: TCP
|
||||
41
infra/k8s/base/configmap.yaml
Normal file
41
infra/k8s/base/configmap.yaml
Normal file
@@ -0,0 +1,41 @@
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: workclub-config
|
||||
labels:
|
||||
app: workclub
|
||||
data:
|
||||
log-level: "Information"
|
||||
cors-origins: "http://localhost:3000"
|
||||
api-base-url: "http://workclub-api"
|
||||
keycloak-url: "http://workclub-keycloak"
|
||||
keycloak-realm: "workclub"
|
||||
|
||||
# Database configuration
|
||||
database-host: "workclub-postgres"
|
||||
database-port: "5432"
|
||||
database-name: "workclub"
|
||||
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: postgres-init
|
||||
labels:
|
||||
app: workclub-postgres
|
||||
data:
|
||||
init.sql: |
|
||||
-- Create keycloak database and user
|
||||
CREATE DATABASE keycloak;
|
||||
CREATE USER keycloak WITH PASSWORD 'keycloakpass';
|
||||
GRANT ALL PRIVILEGES ON DATABASE keycloak TO keycloak;
|
||||
|
||||
-- Keycloak database permissions
|
||||
\c keycloak
|
||||
GRANT ALL PRIVILEGES ON SCHEMA public TO keycloak;
|
||||
ALTER SCHEMA public OWNER TO keycloak;
|
||||
|
||||
-- Application database permissions
|
||||
\c workclub
|
||||
GRANT ALL PRIVILEGES ON SCHEMA public TO app;
|
||||
ALTER SCHEMA public OWNER TO app;
|
||||
64
infra/k8s/base/frontend-deployment.yaml
Normal file
64
infra/k8s/base/frontend-deployment.yaml
Normal file
@@ -0,0 +1,64 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: workclub-frontend
|
||||
labels:
|
||||
app: workclub-frontend
|
||||
component: frontend
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app: workclub-frontend
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: workclub-frontend
|
||||
component: frontend
|
||||
spec:
|
||||
containers:
|
||||
- name: frontend
|
||||
image: workclub-frontend:latest
|
||||
imagePullPolicy: IfNotPresent
|
||||
ports:
|
||||
- name: http
|
||||
containerPort: 3000
|
||||
protocol: TCP
|
||||
readinessProbe:
|
||||
httpGet:
|
||||
path: /api/health
|
||||
port: http
|
||||
initialDelaySeconds: 5
|
||||
periodSeconds: 10
|
||||
timeoutSeconds: 5
|
||||
failureThreshold: 2
|
||||
livenessProbe:
|
||||
httpGet:
|
||||
path: /api/health
|
||||
port: http
|
||||
initialDelaySeconds: 10
|
||||
periodSeconds: 15
|
||||
timeoutSeconds: 5
|
||||
failureThreshold: 3
|
||||
|
||||
resources:
|
||||
requests:
|
||||
cpu: 100m
|
||||
memory: 256Mi
|
||||
limits:
|
||||
cpu: 500m
|
||||
memory: 512Mi
|
||||
|
||||
env:
|
||||
- name: NODE_ENV
|
||||
value: "production"
|
||||
- name: NEXT_PUBLIC_API_URL
|
||||
valueFrom:
|
||||
configMapKeyRef:
|
||||
name: workclub-config
|
||||
key: api-base-url
|
||||
- name: NEXT_PUBLIC_KEYCLOAK_URL
|
||||
valueFrom:
|
||||
configMapKeyRef:
|
||||
name: workclub-config
|
||||
key: keycloak-url
|
||||
16
infra/k8s/base/frontend-service.yaml
Normal file
16
infra/k8s/base/frontend-service.yaml
Normal file
@@ -0,0 +1,16 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: workclub-frontend
|
||||
labels:
|
||||
app: workclub-frontend
|
||||
component: frontend
|
||||
spec:
|
||||
type: ClusterIP
|
||||
selector:
|
||||
app: workclub-frontend
|
||||
ports:
|
||||
- name: http
|
||||
port: 80
|
||||
targetPort: 3000
|
||||
protocol: TCP
|
||||
25
infra/k8s/base/ingress.yaml
Normal file
25
infra/k8s/base/ingress.yaml
Normal file
@@ -0,0 +1,25 @@
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: Ingress
|
||||
metadata:
|
||||
name: workclub-ingress
|
||||
labels:
|
||||
app: workclub
|
||||
spec:
|
||||
rules:
|
||||
- host: localhost
|
||||
http:
|
||||
paths:
|
||||
- path: /
|
||||
pathType: Prefix
|
||||
backend:
|
||||
service:
|
||||
name: workclub-frontend
|
||||
port:
|
||||
number: 80
|
||||
- path: /api
|
||||
pathType: Prefix
|
||||
backend:
|
||||
service:
|
||||
name: workclub-api
|
||||
port:
|
||||
number: 80
|
||||
81
infra/k8s/base/keycloak-deployment.yaml
Normal file
81
infra/k8s/base/keycloak-deployment.yaml
Normal file
@@ -0,0 +1,81 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: workclub-keycloak
|
||||
labels:
|
||||
app: workclub-keycloak
|
||||
component: auth
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app: workclub-keycloak
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: workclub-keycloak
|
||||
component: auth
|
||||
spec:
|
||||
containers:
|
||||
- name: keycloak
|
||||
image: quay.io/keycloak/keycloak:26.1
|
||||
imagePullPolicy: IfNotPresent
|
||||
command:
|
||||
- start
|
||||
ports:
|
||||
- name: http
|
||||
containerPort: 8080
|
||||
protocol: TCP
|
||||
readinessProbe:
|
||||
httpGet:
|
||||
path: /health/ready
|
||||
port: http
|
||||
initialDelaySeconds: 10
|
||||
periodSeconds: 10
|
||||
timeoutSeconds: 5
|
||||
failureThreshold: 2
|
||||
|
||||
livenessProbe:
|
||||
httpGet:
|
||||
path: /health/live
|
||||
port: http
|
||||
initialDelaySeconds: 20
|
||||
periodSeconds: 15
|
||||
timeoutSeconds: 5
|
||||
failureThreshold: 3
|
||||
resources:
|
||||
requests:
|
||||
cpu: 100m
|
||||
memory: 256Mi
|
||||
limits:
|
||||
cpu: 500m
|
||||
memory: 512Mi
|
||||
env:
|
||||
- name: KC_DB
|
||||
value: postgres
|
||||
- name: KC_DB_URL_HOST
|
||||
value: workclub-postgres
|
||||
- name: KC_DB_URL_PORT
|
||||
value: "5432"
|
||||
- name: KC_DB_URL_DATABASE
|
||||
value: keycloak
|
||||
- name: KC_DB_USERNAME
|
||||
value: keycloak
|
||||
- name: KC_DB_PASSWORD
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: workclub-secrets
|
||||
key: keycloak-db-password
|
||||
- name: KEYCLOAK_ADMIN
|
||||
value: admin
|
||||
- name: KEYCLOAK_ADMIN_PASSWORD
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: workclub-secrets
|
||||
key: keycloak-admin-password
|
||||
- name: KC_HOSTNAME_STRICT
|
||||
value: "false"
|
||||
- name: KC_PROXY
|
||||
value: "edge"
|
||||
- name: KC_HTTP_ENABLED
|
||||
value: "true"
|
||||
16
infra/k8s/base/keycloak-service.yaml
Normal file
16
infra/k8s/base/keycloak-service.yaml
Normal file
@@ -0,0 +1,16 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: workclub-keycloak
|
||||
labels:
|
||||
app: workclub-keycloak
|
||||
component: auth
|
||||
spec:
|
||||
type: ClusterIP
|
||||
selector:
|
||||
app: workclub-keycloak
|
||||
ports:
|
||||
- name: http
|
||||
port: 80
|
||||
targetPort: 8080
|
||||
protocol: TCP
|
||||
14
infra/k8s/base/kustomization.yaml
Normal file
14
infra/k8s/base/kustomization.yaml
Normal file
@@ -0,0 +1,14 @@
|
||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
|
||||
resources:
|
||||
- backend-deployment.yaml
|
||||
- backend-service.yaml
|
||||
- frontend-deployment.yaml
|
||||
- frontend-service.yaml
|
||||
- postgres-statefulset.yaml
|
||||
- postgres-service.yaml
|
||||
- keycloak-deployment.yaml
|
||||
- keycloak-service.yaml
|
||||
- configmap.yaml
|
||||
- ingress.yaml
|
||||
37
infra/k8s/base/postgres-service.yaml
Normal file
37
infra/k8s/base/postgres-service.yaml
Normal file
@@ -0,0 +1,37 @@
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: workclub-postgres-headless
|
||||
labels:
|
||||
app: workclub-postgres
|
||||
component: database
|
||||
spec:
|
||||
type: ClusterIP
|
||||
clusterIP: None
|
||||
selector:
|
||||
app: workclub-postgres
|
||||
ports:
|
||||
- name: postgresql
|
||||
port: 5432
|
||||
targetPort: 5432
|
||||
protocol: TCP
|
||||
publishNotReadyAddresses: true
|
||||
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: workclub-postgres
|
||||
labels:
|
||||
app: workclub-postgres
|
||||
component: database
|
||||
spec:
|
||||
type: ClusterIP
|
||||
selector:
|
||||
app: workclub-postgres
|
||||
ports:
|
||||
- name: postgresql
|
||||
port: 5432
|
||||
targetPort: 5432
|
||||
protocol: TCP
|
||||
91
infra/k8s/base/postgres-statefulset.yaml
Normal file
91
infra/k8s/base/postgres-statefulset.yaml
Normal file
@@ -0,0 +1,91 @@
|
||||
apiVersion: apps/v1
|
||||
kind: StatefulSet
|
||||
metadata:
|
||||
name: workclub-postgres
|
||||
labels:
|
||||
app: workclub-postgres
|
||||
component: database
|
||||
spec:
|
||||
serviceName: workclub-postgres-headless
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app: workclub-postgres
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: workclub-postgres
|
||||
component: database
|
||||
spec:
|
||||
containers:
|
||||
- name: postgres
|
||||
image: postgres:16-alpine
|
||||
imagePullPolicy: IfNotPresent
|
||||
ports:
|
||||
- name: postgresql
|
||||
containerPort: 5432
|
||||
protocol: TCP
|
||||
livenessProbe:
|
||||
exec:
|
||||
command:
|
||||
- /bin/sh
|
||||
- -c
|
||||
- pg_isready -U app -d workclub
|
||||
initialDelaySeconds: 10
|
||||
periodSeconds: 15
|
||||
timeoutSeconds: 5
|
||||
failureThreshold: 3
|
||||
|
||||
readinessProbe:
|
||||
exec:
|
||||
command:
|
||||
- /bin/sh
|
||||
- -c
|
||||
- pg_isready -U app -d workclub
|
||||
initialDelaySeconds: 5
|
||||
periodSeconds: 10
|
||||
timeoutSeconds: 5
|
||||
failureThreshold: 2
|
||||
|
||||
resources:
|
||||
requests:
|
||||
cpu: 100m
|
||||
memory: 256Mi
|
||||
limits:
|
||||
cpu: 500m
|
||||
memory: 512Mi
|
||||
|
||||
env:
|
||||
- name: POSTGRES_DB
|
||||
value: workclub
|
||||
- name: POSTGRES_USER
|
||||
value: app
|
||||
- name: POSTGRES_PASSWORD
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: workclub-secrets
|
||||
key: postgres-password
|
||||
volumeMounts:
|
||||
- name: postgres-data
|
||||
mountPath: /var/lib/postgresql/data
|
||||
subPath: postgres
|
||||
- name: postgres-init
|
||||
mountPath: /docker-entrypoint-initdb.d
|
||||
|
||||
volumes:
|
||||
- name: postgres-init
|
||||
configMap:
|
||||
name: postgres-init
|
||||
items:
|
||||
- key: init.sql
|
||||
path: init.sql
|
||||
volumeClaimTemplates:
|
||||
- metadata:
|
||||
name: postgres-data
|
||||
spec:
|
||||
accessModes:
|
||||
- ReadWriteOnce
|
||||
storageClassName: standard
|
||||
resources:
|
||||
requests:
|
||||
storage: 10Gi
|
||||
Reference in New Issue
Block a user