# Personal Life Analytics App

A personal web application built with Laravel to track daily habits, visualize trends, and identify the factors that influence well-being, consistency, and decision-making.

## Overview

This project is a personal analytics tool rather than a simple habit tracker.

Its purpose is to collect structured daily data, organize it around a logical day, and turn it into meaningful statistics that help answer one core question:

> Which factors influence my day the most, and which decisions shape my outcomes over time?

The application is intentionally designed as a long-term personal tool with a clean and modular architecture.

## Tech Stack

- **Backend:** Laravel
- **Rendering:** Blade
- **Authentication:** Laravel Breeze
- **ORM:** Eloquent
- **Database:** MariaDB / MySQL
- **Schema management:** Laravel migrations

## Product Goals

- Track key daily signals without making data entry too heavy
- Visualize progress through graphs, averages, records, and streaks
- Preserve timestamps when they matter
- Build a reliable dataset for later correlation and pattern analysis
- Help guide better daily decisions through personal statistics

## Functional Scope

The data model is built around a **minimal daily entry** that acts as the anchor for the rest of the day's data.

### Core entities

- **Daily entries** – one logical day per user
- **Sleep records** – one main sleep record per day
- **Nap records** – zero or more naps linked to a day
- **Daily scores** – emotional, physical, and mental scores
- **Hydration entries** – timestamped hydration history
- **Presets** – reusable quick-entry values such as bottle sizes or nap durations
- **Activity sessions** – sport, reading, writing, and future activity types
- **Activity session metrics** – simple performance values linked to a session
- **Books** – personal reading references
- **Goals** – daily or weekly targets

## Example Use Cases

- Track the main sleep of a day even if it started the previous evening
- Add hydration quickly using presets such as “500 ml bottle”
- Record a running session with multiple metrics such as distance and average speed
- Track reading sessions linked to a book
- Compare trends over time and later explore correlations

## Versioning Plan

### V1 — Collection and Visualization

- Authentication
- Daily dashboard
- Sleep and naps
- Daily subjective scores
- Hydration tracking
- Presets
- Activity sessions
- Session metrics
- Books
- History
- Graphs, averages, records, and streaks
- Simple goals

### V2 — Analysis

- Cross-variable comparisons
- Basic correlations
- Time-based pattern analysis
- Early insight generation

### V3 — Automation and Enrichment

- Strava integration
- Automated sleep imports
- Data export
- More advanced insights and recommendations

## Architecture Principles

- Keep `daily_entries` minimal
- Split business domains into dedicated tables
- Preserve timestamps where behavioral analysis may matter
- Avoid overloading core tables with unrelated fields
- Start with clean collection and visualization before deeper analytics

## Current Status

The project is currently in the design phase.

The functional specifications and conceptual data model have been defined, and the next step is to implement the relational model and Laravel migrations.

## Philosophy

> First collect the data correctly.  
> Then visualize it clearly.  
> Only then start analyzing it.

## Local Docker Setup

This project can run locally with Docker Compose using Nginx, PHP-FPM, MySQL, and Vite.

### Requirements

- Docker
- Docker Compose v2

### Start the project

```bash
docker compose up --build
```

The services will be available at:

- Application: http://localhost:8080
- Vite dev server: http://localhost:5173
- MySQL from host: `127.0.0.1:3307`

The Docker environment overrides the database settings with:

```dotenv
DB_CONNECTION=mysql
DB_HOST=mysql
DB_PORT=3306
DB_DATABASE=life_analytics
DB_USERNAME=laravel
DB_PASSWORD=secret
```

### Run migrations

In another terminal:

```bash
docker compose exec app php artisan migrate
```

### Useful commands

```bash
docker compose exec app php artisan test
docker compose exec app composer install
docker compose exec node npm install
docker compose down
docker compose down -v
```

Use `docker compose down -v` only if you want to delete Docker volumes, including the local MySQL data.
