keepercheky

KeeperCheky Development Guide

Estado Actual: v1.0.0-dev.17 - Desarrollo activo con la mayorΓ­a de features implementadas

πŸš€ Quick Start

βœ… What’s Implemented

Backend Services (Go)

Service Integrations

Frontend (Alpine.js + Tailwind)

API Endpoints

Features

Prerequisites

First-Time Setup

  1. Clone the repository
    git clone https://github.com/carcheky/keepercheky.git
    cd keepercheky
    
  2. Initialize development environment
    make init
    
  3. Start development server
    make dev
    
  4. Access the application
    • Open http://localhost:8000
    • You should see the KeeperCheky dashboard

πŸ› οΈ Development Workflow

The development environment uses Air for automatic hot-reload:

# Start with hot-reload



make dev

# The server will automatically restart when you edit:



# - Go files (*.go)



# - Templates (*.html)



# - Config files (*.yaml)



Using Docker Compose Watch (Docker 28+)

Docker 28+ includes a watch feature that syncs file changes:

# Start with compose watch



make dev-watch

What gets synced:

Useful Commands

# View logs



make logs

# Open shell in container



make shell

# Run tests



make test

# Format code



make fmt

# Stop server



make stop

# Clean everything



make clean

πŸ“ Project Structure

keepercheky/
β”œβ”€β”€ cmd/
β”‚   └── server/
β”‚       └── main.go              # Application entry point
β”œβ”€β”€ internal/                     # Private application code
β”‚   β”œβ”€β”€ config/                   # Configuration management
β”‚   β”‚   └── config.go
β”‚   β”œβ”€β”€ models/                   # Database models (GORM)
β”‚   β”‚   └── models.go
β”‚   β”œβ”€β”€ repository/               # Data access layer
β”‚   β”‚   └── repository.go
β”‚   β”œβ”€β”€ service/                  # Business logic
β”‚   β”‚   β”œβ”€β”€ clients/              # External service clients
β”‚   β”‚   β”œβ”€β”€ cleanup/              # Cleanup strategies
β”‚   β”‚   └── scheduler/            # Job scheduling
β”‚   β”œβ”€β”€ handler/                  # HTTP handlers (Fiber)
β”‚   β”‚   β”œβ”€β”€ handler.go
β”‚   β”‚   β”œβ”€β”€ dashboard.go
β”‚   β”‚   β”œβ”€β”€ media.go
β”‚   β”‚   └── ...
β”‚   └── middleware/               # HTTP middleware
β”‚       └── middleware.go
β”œβ”€β”€ web/
β”‚   β”œβ”€β”€ templates/                # Go html/template files
β”‚   β”‚   β”œβ”€β”€ layouts/
β”‚   β”‚   β”‚   └── main.html
β”‚   β”‚   └── pages/
β”‚   β”‚       β”œβ”€β”€ dashboard.html
β”‚   β”‚       └── ...
β”‚   └── static/                   # CSS, JS, images
β”‚       β”œβ”€β”€ css/
β”‚       β”œβ”€β”€ js/
β”‚       └── images/
β”œβ”€β”€ pkg/                          # Public/shared packages
β”‚   β”œβ”€β”€ logger/
β”‚   β”‚   └── logger.go
β”‚   └── utils/
β”œβ”€β”€ data/                         # Runtime data (gitignored)
β”‚   └── dev.db                    # SQLite database
β”œβ”€β”€ config/                       # Configuration files
β”‚   └── config.example.yaml
β”œβ”€β”€ .air.toml                     # Air configuration
β”œβ”€β”€ docker-compose.yml        # Development compose file
β”œβ”€β”€ Dockerfile.dev                # Development Dockerfile
β”œβ”€β”€ Makefile                      # Development commands
└── README.md

πŸ”§ Configuration

Environment Variables

The application uses environment variables with the prefix KEEPERCHEKY_:

# App



KEEPERCHEKY_APP_ENVIRONMENT=development
KEEPERCHEKY_APP_LOG_LEVEL=debug
KEEPERCHEKY_APP_DRY_RUN=true
KEEPERCHEKY_APP_LEAVING_SOON_DAYS=7

# Server



KEEPERCHEKY_SERVER_PORT=8000
KEEPERCHEKY_SERVER_HOST=0.0.0.0

# Database



KEEPERCHEKY_DATABASE_TYPE=sqlite
KEEPERCHEKY_DATABASE_PATH=./data/dev.db

Configuration File

Alternatively, create config/config.yaml:

app:
  environment: development
  log_level: debug
  dry_run: true
  leaving_soon_days: 7
  scheduler_enabled: false

server:
  port: "8000"
  host: "0.0.0.0"

database:
  type: sqlite
  path: ./data/dev.db

clients:
  radarr:
    enabled: false
    url: "http://radarr:7878"
    api_key: ""
  
  sonarr:
    enabled: false
    url: "http://sonarr:8989"
    api_key: ""
  
  jellyfin:
    enabled: false
    url: "http://jellyfin:8096"
    api_key: ""
    username: ""
    password: ""

πŸ§ͺ Testing

Running Tests

# All tests



make test

# With coverage



make test-coverage

# Specific package



go test -v ./internal/service/...

Writing Tests

Follow the standard Go testing conventions:

// internal/repository/repository_test.go
package repository

import (
    "testing"
    "github.com/stretchr/testify/assert"
)

func TestMediaRepository_GetAll(t *testing.T) {
    // Setup
    db := setupTestDB(t)
    defer db.Close()
    
    repo := NewMediaRepository(db)
    
    // Test
    media, err := repo.GetAll()
    
    // Assert
    assert.NoError(t, err)
    assert.NotNil(t, media)
}

🎨 Frontend Development

Alpine.js Components

Create reactive components in templates:

<div x-data="mediaList()" x-init="init()">
    <template x-for="item in media" :key="item.id">
        <div x-text="item.title"></div>
    </template>
</div>

<script>
function mediaList() {
    return {
        media: [],
        
        async init() {
            this.media = await this.fetchMedia();
        },
        
        async fetchMedia() {
            const response = await fetch('/api/media');
            return await response.json();
        }
    }
}
</script>

Tailwind CSS

Use Tailwind utility classes directly in templates:

<div class="bg-white shadow rounded-lg p-6">
    <h2 class="text-2xl font-bold text-gray-900">Title</h2>
</div>

πŸ› Debugging

VS Code Debugging

  1. Install the Go extension for VS Code
  2. Set breakpoints in your code
  3. Press F5 to start debugging
  4. Or use the β€œLaunch Package” configuration

Docker Debugging

# View container logs



make logs

# Open shell in container



make shell

# Inside container, you can:



go run ./cmd/server

Common Issues

Port already in use:

# Find and kill process using port 8000



lsof -ti:8000 | xargs kill -9

# Or use a different port



KEEPERCHEKY_SERVER_PORT=8001 make dev

Database locked:

# Stop all containers and clean



make clean
make init
make dev

πŸ“š Additional Resources

🀝 Contributing

  1. Create a new branch: git checkout -b feature/my-feature
  2. Make your changes
  3. Run tests: make test
  4. Format code: make fmt
  5. Commit: git commit -m "feat: add my feature"
  6. Push: git push origin feature/my-feature
  7. Create Pull Request

πŸ“ Coding Guidelines

See .github/copilot-instructions.md for detailed coding standards.

Key principles:


Happy coding! πŸš€

If you encounter any issues, check the main documentation or open an issue on GitHub.