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
11 changes: 11 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
MIT License
===========

Copyright (c) Martin Komischke

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

26 changes: 0 additions & 26 deletions LICENSE.md

This file was deleted.

176 changes: 39 additions & 137 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,167 +1,69 @@
<div align="center">

# Fairly

**Split expenses and settle debts between individuals.** 💚

<!-- Badges -->
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![PHP Version](https://img.shields.io/badge/PHP-8.4-777BB4.svg?logo=php&logoColor=white)](https://www.php.net/)
[![Docker](https://img.shields.io/badge/Docker-Multi--stage-2496ED?logo=docker&logoColor=white)](https://www.docker.com/)
[![Kubernetes](https://img.shields.io/badge/Kubernetes-Helm-326CE5?logo=kubernetes&logoColor=white)](https://helm.sh/)
![app-ci-workflow](https://github.com/makomweb/fairly/actions/workflows/app-ci.yaml/badge.svg)
[![codecov](https://codecov.io/gh/makomweb/fairly/graph/badge.svg?token=O6WQ8USL6T)](https://codecov.io/gh/makomweb/fairly)
[![codecov](https://img.shields.io/codecov/c/github/makomweb/fairly?flag=core&logo=codecov&token=O6WQ8USL6T)](https://codecov.io/gh/makomweb/fairly?flags[0]=core)

</div>

## Goal
---

This is a full-stack, cloud-native web application for tracking and splitting expenses and settling debts among 2 individuals. It is built on PHP 8.4, Symfony 8, MySQL 8, and React 19, and uses **event sourcing** to maintain a complete audit trail of all financial transactions.
## 🎯 Purpose

It follows DDD principles to separate the application into generic, core, and supporting domains — enforced by [deptrac](https://github.com/deptrac/deptrac). This makes it easy to achieve full code coverage for the core domain.
A full-stack, cloud-native web application for tracking and splitting expenses and settling debts among 2 individuals. Built on **PHP 8.4**, **Symfony 8**, **MySQL 8**, and **React 19**, featuring **event sourcing** for a complete audit trail.

It also showcases Kubernetes deployment using Helm.
By strictly isolating the **Core** from infrastructure and framework code (enforced via [deptrac](https://github.com/deptrac/deptrac)), the business logic achieves **100% test coverage**.

## Screenshots
## 📸 Screenshots

<table>
<tr>
<td><img src="./images/login.png" alt="Login view" width="300px"></td>
<td><img src="./images/track.png" alt="Track view" width="300px"></td>
<td><img src="./images/calculate.png" alt="Calculate view" width="300px"></td>
<td><img src="./images/login.png" alt="Login view" width="260px"></td>
<td><img src="./images/track.png" alt="Track view" width="260px"></td>
<td><img src="./images/calculate.png" alt="Calculate view" width="260px"></td>
</tr>
</table>

## 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/)
## 🚀 Quick Start (Local Development)

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

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

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

## Contributing

See [CONTRIBUTING.md](./CONTRIBUTING.md) for:
- Running tests
- Code style and quality checks
- Database migrations
- Development workflow

## Architecture

```
Browser / Client
│
┌────────────────┼─────────────────┐
│ :8000 │ :8080 │ :5173 (dev)
▼ ▼ ▼
┌────────────┐ ┌──────────────┐ ┌───────────────┐
│ dashboard │ │ web (Nginx) │ │ npm-dev │
│ (Homer) │ │ │ │ (Vite/React/ │
└────────────┘ └──────┬───────┘ │ TypeScript) │
│ FastCGI └───────────────┘
│ :9000
▼
┌──────────────────┐ async ┌──────────────┐
│ app (PHP-FPM) │────messages────▶│ worker │
│ Symfony │ │ (Messenger) │
└──────────────────┘ └──────────────┘
│ │
└────────────────┬────────────────┘
│ SQL
▼
┌─────────────────┐
│ db (MySQL) │
└─────────────────┘

───────────────────────── Backend Layers ─────────────────────────

┌─────────────────────────────────────────────────────────────────┐
│ Supporting │ Controllers · Auth · Repositories · Async │
│ │ Normalizers · Instrumentation · EventListeners │
├──────────────┴──────────────────────────────────────────────────┤
│ Core │ ExpenseTracker · Calculator │
│ (Domain) │ Event Sourcing · Expenses · Compensation │
├──────────────┴──────────────────────────────────────────────────┤
│ Generic │ Symfony · Doctrine · Twig · DomPDF · Monolog |
| │ PhpParser · phpDocumenter · OpenAPI |
└─────────────────────────────────────────────────────────────────┘
Supporting depends on Core & Generic · Core has no deps
```

## Kubernetes Deployment
## 🚢 Kubernetes & Helm Deployment

Deploy production-ready with Helm:
```bash
# Build production images
# Build production images & deploy
make prod
helm upgrade --install app ./helm --set replicaCount.app=3 --set replicaCount.worker=2
```
For detailed Kubernetes setup, port-forwarding, and architecture, see [docs/KUBERNETES.md](./docs/KUBERNETES.md).

# Deploy with 3 app pods + 2 worker pods
helm install app ./helm --set replicaCount.app=3 --set replicaCount.worker=2
# or:
helm upgrade --install app ./helm

# Access the application via NodePort:
# Link: http://localhost:30190
# Or configure port forwarding via:
kubectl port-forward svc/app-fairly-web 8080:80
# Link: http://localhost:8080
## 🏛️ Architecture

# View logs for all pods with the PHP label (app + worker)
kubectl logs -f -l technology=php
```
* **Backend Layers:** Clear separation into 3 subdomains: *Core*, *Supporting*, and *Generic*.
* **Event Sourcing:** Full audit trail stored in MySQL.

### Kubernetes Architecture
For full system diagrams and deep-dive architecture insights, check out [docs/ARCHITECTURE.md](./docs/ARCHITECTURE.md).

```
┌────────────────────────────────────────────────────────────────────────┐
│ Kubernetes Cluster │
├────────────────────────────────────────────────────────────────────────┤
│ │
│ ┌──────────────────┐ ┌──────────────────┐ ┌──────────────────┐ │
│ │ nginx (web) │ │ app (PHP-FPM) │ │ worker │ │
│ │ Deployment │ │ Deployment │ │ (Messenger) │ │
│ │ NodePort:30190 │ │ Pod × 1 │ │ Pod × 1 │ │
│ │ Pods × 1 │─→│ FastCGI :9000 │ │ One-shot pattern │ │
│ └──────────────────┘ └──────────────────┘ └──────────────────┘ │
│ │ │ │ │
│ │ Serves SPA │ Business logic │ Async tasks │
│ │ EasyAdmin │ API endpoints │ from queue │
│ │ Static assets │ Session mgmt (DB) │ │
│ │ │ Event sourcing (DB) │ │
│ │ │ │ │
│ └───────────┬───────────┴───────────┬───────────┘ │
│ │ │ │
│ ┌──────▼───────────────────────▼──┐ │
│ │ MySQL StatefulSet │ │
│ │ PVC Storage (8Gi) │ │
│ │ - Event store │ │
│ │ - Sessions │ │
│ │ - Application data │ │
│ └─────────────────────────────────┘ │
│ △ │
│ │ init Job │
│ ┌──────┴──────┐ │
│ │ db-init │ │
│ │ (one-time) │ │
│ └─────────────┘ │
│ │
│ ┌──────────────────────────────────────────────────────────────┐ │
│ │ Grafana Alloy (k8s-monitoring) │ │
│ │ - Collects logs from all pods │ │
│ │ - Metrics collection & forwarding │ │
│ └──────────────────────────────────────────────────────────────┘ │
│ │
└────────────────────────────────────────────────────────────────────────┘
```
## 🤝 Contributing & Documentation

**Components:**
- **nginx (web)**: Serves React SPA frontend, static assets, EasyAdmin UI. Proxies API requests to PHP-FPM via FastCGI.
- **PHP-FPM (app)**: Symfony backend handling business logic, API endpoints, and session management. Stores sessions in MySQL.
- **Worker**: Processes async jobs via Messenger with one-shot pattern (processes single message per pod lifecycle, then restarts for fresh environment).
- **MySQL**: Persistent data storage with StatefulSet and PVC. Stores event sourcing audit trail, sessions, and application data.
- **db-init Job**: One-time database initialization (schema, fixtures, migrations).
- **Grafana Alloy**: Log collection and forwarding for observability across all cluster components.
* **[Contributing Guide](./docs/CONTRIBUTING.md):** Running tests, code style, and database migrations.
* **[Kubernetes Guide](./docs/KUBERNETES.md):** Pod structure, storage, and monitoring.
* **[Architecture Overview](./docs/ARCHITECTURE.md):** Detailed flowcharts and DDD boundaries.
18 changes: 18 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
fixes:
- "/var/www/project/src/::src/"

coverage:
status:
project:
default:
target: auto
core:
target: 100%
flags:
- core

flags:
core:
paths:
- src/Fairly/
carryforward: true
Loading
Loading