Skip to content
Merged
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
20 changes: 13 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ VERSION = 0.1.1
help:
@echo "📋 Available targets:\n"
@echo "🏗️ Build & Setup:"
@echo " make build Build development image, boot stack, and open browser"
@echo " make image Build development Docker image"
@echo " make start Build development image, boot stack, initialize db, and open browser"
@echo " make dev Build development Docker image"
@echo " make prod Build production Docker images (app + web)"
@echo " make up Boot the Docker stack"
@echo " make down Shut down the Docker stack"
@echo " make init Initialize app (composer, database, fixtures)"
Expand All @@ -30,12 +31,17 @@ help:
@echo " make clear Clear all caches"
@echo " make open Open application in browser\n"

build: image up open
start: build up init open

build:
@echo "🏗️ Building development image(s)..."
docker build . -f ./build/php/Dockerfile --target dev --no-cache -t ${APP_NAME}-dev:${VERSION}

prod:
@echo "🛳️ Building procution image(s)..."
docker build . -f ./build/php/Dockerfile --target prod --no-cache -t ${APP_NAME}:${VERSION}
docker build . -f ./build/nginx/Dockerfile --no-cache -t ${APP_NAME}-web:${VERSION}

image:
@echo "🏗️ Building development image..."
docker build . -f ./build/php/Dockerfile --target dev -t ${APP_NAME}-dev:${VERSION}

up:
@echo "🚀 Booting Docker stack..."
docker compose up -d --remove-orphans
Expand Down
125 changes: 123 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,108 @@ Track shared costs, calculate who owes whom, and manage group finances effortles

Follows DDD principles for separting the application into generic, core, and supporting domains - enforced by [deptrac](https://github.com/deptrac/deptrac).

## Kubernetes Deployment

This application is fully containerized and deployable to Kubernetes. Use the Helm chart to deploy:

```bash
# Deploy to Kubernetes (requires kind, minikube, or Docker Desktop with K8s enabled)
helm install app ./helm

# Access the application
kubectl port-forward svc/app-split-fairly-web 8080:80
# → http://localhost:8080

# Or via NodePort (if enabled)
# → http://localhost:30190
```

### Kubernetes Architecture

```
┌─────────────────────────────────────────────────────────────┐
│ Kubernetes Cluster │
├─────────────────────────────────────────────────────────────┤
│ │
│ ┌──────────────────┐ ┌──────────────────┐ │
│ │ nginx (web) │ │ app (PHP-FPM) │ │
│ │ Split-Fairly │ │ Deployment │ │
│ │ NodePort:30190 │─→│ Pods × 1 │ │
│ └──────────────────┘ └──────────────────┘ │
│ │ │ │
│ │ Serves SPA │ Processes requests │
│ │ EasyAdmin │ Event sourcing │
│ │ │ Session management │
│ │ ┌─────▼──────┐ │
│ │ │ worker │ │
│ │ │ Pod × 1 │ │
│ │ │ Async jobs │ │
│ │ └────────────┘ │
│ │ │ │
│ └───────────┬───────────┘ │
│ │ │
│ ┌──────▼──────┐ │
│ │ MySQL │ │
│ │ StatefulSet │ │
│ │ PVC Storage │ │
│ └─────────────┘ │
│ △ │
│ │ init Job │
│ ┌──────┴──────┐ │
│ │ db-init │ │
│ │ (one-time) │ │
│ └─────────────┘ │
│ │
└─────────────────────────────────────────────────────────────┘
```

**Components:**
- **nginx (web)**: Serves React SPA frontend, EasyAdmin assets, proxies API to PHP
- **PHP-FPM (app)**: Symfony backend, handles business logic & API endpoints
- **Worker**: Processes async jobs via Messenger (background tasks)
- **MySQL**: Persistent data storage with PVC
- **db-init Job**: One-time database initialization (schema + fixtures)

**Access:** `http://localhost:30190` (direct) or `http://localhost:8080` (port-forward)

### Getting Started with Kubernetes

```bash
# Prerequisites: Docker Desktop (or kind/minikube) with Kubernetes enabled

# Build production images
make prod

# Deploy to cluster
helm upgrade --install app ./helm

# Watch pods come up
kubectl get pods -w

# View application logs
kubectl logs deployment/app-split-fairly-app -f
kubectl logs deployment/app-split-fairly-worker -f

# Access the application
# - Direct: http://localhost:30190
# - Port-forward: kubectl port-forward svc/app-split-fairly-web 8080:80

# Login credentials (auto-loaded from fixtures)
# Email: admin@example.com
# Password: secret
```

## Local Development (Docker Compose)

For development without Kubernetes:

```bash
make start # Build images, start services, and open in browser
make help # Show all available targets
```

Visit `http://localhost:8000` in your browser.

## Architecture diagram

```
Expand Down Expand Up @@ -53,19 +155,38 @@ Follows DDD principles for separting the application into generic, core, and sup

## Prerequisites

### For Docker Compose (Local Development)
- [Make](https://www.gnu.org/software/make/)
- [Docker](https://www.docker.com/)
- [Docker Compose](https://docs.docker.com/compose/)

### For Kubernetes Deployment
- [Make](https://www.gnu.org/software/make/)
- [Docker](https://www.docker.com/)
- [Kubernetes](https://kubernetes.io/) (kind, minikube, or Docker Desktop)
- [Helm 3](https://helm.sh/)

## Getting Started

### Quick Start (Docker Compose)

```bash
make build # Build image, start services, and open in browser
make init # Initialize database and load fixtures
make start # Build image, start services, and open in browser
make help # to show all targets
```

Visit `http://localhost:8000` in your browser.

### Kubernetes Deployment

```bash
make prod # Build production images
helm install app ./helm # Deploy to Kubernetes
kubectl port-forward svc/app-split-fairly-web 8080:80 # Access app
```

Visit `http://localhost:8080` (or `http://localhost:30190` directly if NodePort is enabled).

## Screenshots

<table>
Expand Down
2 changes: 1 addition & 1 deletion backend/.env
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# https://symfony.com/doc/current/best_practices.html#use-environment-variables-for-infrastructure-configuration

###> symfony/framework-bundle ###
APP_ENV=dev
APP_ENV=prod
APP_SECRET=
APP_SHARE_DIR=var/share
APP_VERSION=0.0.1
Expand Down
2 changes: 1 addition & 1 deletion backend/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"ext-ctype": "*",
"ext-iconv": "*",
"doctrine/doctrine-bundle": "^3.2.2",
"doctrine/doctrine-fixtures-bundle": "^4.3",
"doctrine/doctrine-migrations-bundle": "^4.0",
"doctrine/orm": "^3.6.2",
"dompdf/dompdf": "^3.1",
Expand Down Expand Up @@ -104,7 +105,6 @@
},
"require-dev": {
"deptrac/deptrac": "^4.5",
"doctrine/doctrine-fixtures-bundle": "^4.3.1",
"friendsofphp/php-cs-fixer": "^3.93.1",
"phpstan/phpstan": "^2.1.38",
"phpunit/phpunit": "^12.5.8",
Expand Down
Loading