#!/usr/bin/env bash
set -e

DOC_DIR="./docs"
mkdir -p "$DOC_DIR"

echo "Installing Life Archive documentation into $DOC_DIR"
echo

make_md() {
  local name="$1"
  shift
  cat > "$DOC_DIR/$name" << 'EOF'
'"$@"'
EOF
  echo "Created $DOC_DIR/$name"
}

###############################################
# project.ideas.md
###############################################
make_md project.ideas.md '# Project Ideas – Life Archive Application
Status: Complete

## Core Purpose
A unified Life Archive system that captures, organizes, and displays a person’s life events — with photos, documents, and media — across categories, timeframes, and locations. Forms are dynamically generated from JSON definitions.

## Primary Goals
- Centralized life event repository  
- Dynamic JSON-defined forms  
- Multi-mode viewing (timeline, slideshow)  
- Smart filtering  
- Attachment management  
- Clean modular tech stack  

## Mission Statement
To preserve and present the story of a person’s life through structured events, rich media, and intuitive navigation.
'

###############################################
# architecture.md
###############################################
make_md architecture.md '# Architecture – Life Archive Application
Status: Complete

## Layers
1. Application Layer (PHP, AdminLTE, Bootstrap)
2. JSON Definition Layer
3. Database Layer (MySQL/MariaDB)
4. Media Storage Layer
5. Metadata & Caching Layer

## Core Concept
JSON defines forms → DB stores metadata → filesystem stores media → UI renders timeline/slideshow.
'

###############################################
# data-model.md
###############################################
make_md data-model.md '# Data Model – Life Archive Application
Status: Complete

## Tables
- persons  
- family_tree  
- categories  
- subcategories  
- life_events  
- life_event_attachments  
- locations  
- timeframes  

## Indexing
- person_id  
- category_id  
- event_date  
'

###############################################
# json.schema.md
###############################################
make_md json.schema.md '# JSON Schema – Life Archive Application
Status: Incomplete (needs reviewer confirmation)

## Form Definition Schema
```json
{
  "form_key": "string",
  "label": "string",
  "description": "string",
  "version": "1.0",
  "fields": []
}

