# zvoook/lifeforge architecture

> Architecture diagram of the GitHub repository zvoook/lifeforge, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-06-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/zvoook/lifeforge
- Repository: https://github.com/zvoook/lifeforge

## Overview

1. **What this repo is**
   LifeForge is a Go learning repository centered on a **console task manager**. The currently functional product is the CLI app under `playground/TaskService`, which manages personal development tasks by area and persists them to JSON.

2. **Primary runnable entrypoint**
   The active application starts at `playground/TaskService/main.go` and is run with `go run ./playground/TaskService`. This is the main architecture to diagram today. The `cmd/api` and `internal/app` directories look like an embryonic production-style Go layout, but they are not the current core implementation based on the README.

3. **Domain model**
   The `task.go`, `task_status.go`, and `area.go` files define the core business concepts:
   - a task entity
   - task completion/status
   - a fixed set of development areas such as Backend, English, Guitar, Algorithms, and University  
   This indicates the system is strongly domain-driven around task tracking, not generic CRUD only.

4. **Console/UI layer**
   Files like `cli.go`, `handlers.go`, `readers.go`, and `formatters.go` form the presentation boundary:
   - `readers.go` gathers user input from the terminal
   - `handlers.go` likely maps commands to actions
   - `formatters.go` turns domain data into human-readable console output
   - `cli.go` coordinates the menu/interaction loop  
   This layer is the user-facing entry point and should be shown as the front edge of the system.

5. **Application/service layer**
   `service.go` is the main orchestration layer. It likely contains the use-case logic for:
   - creating tasks
   - listing tasks
   - filtering by area
   - finding by ID
   - completing tasks
   - changing priority
   - deleting tasks
   - clearing all tasks
   - producing dashboard summaries  
   This is the business-rule boundary between UI and persistence.

6. **Repository and persistence**
   `repository.go` and `storage.go` define persistence concerns. The README explicitly says the app uses a **JSON-memory task repository**, and `save.json` is the backing store. So the architecture is not a database-backed service; it is a file-backed local CLI with repository abstraction over JSON storage.

7. **Validation and error handling**
   `validation.go` and `errors.go` suggest input and business-rule validation are handled in the TaskService layer before persistence. That means invalid task IDs, empty fields, unsupported areas, or illegal state transitions should be caught before storage writes.

8. **Data flow through the system**
   The typical flow is:
   **console input → CLI/handlers → service validation and business logic → repository/storage → `save.json`**
   and then back in reverse for display:
   **repository data → service shaping → formatters → console output**  
   This is the key flow to diagram because it shows the app is a layered, single-process command-line system.

9. **Operational behavior**
   The app is local and stateful through a file, not a networked service. There are no visible external dependencies like HTTP, messaging, or cloud services in the active TaskService path. The persistence boundary is the local JSON file, which makes the whole system portable and simple to run.

10. **Secondary repo structure**
   `cmd/api/main.go` plus `internal/app/app.go` indicate a more standard Go application skeleton exists alongside the playground code. Architecturally, this suggests the project is evolving from a learning playground toward a cleaner production structure, but the README confirms the CLI implementation is the current working system.

11. **Technology and runtime**
   The stack is plain **Go** with standard command-line execution and file-based JSON persistence. The build artifact is an executable generated from the CLI package, so the deployment model is simply “compile and run locally.”

12. **How to draw the architecture**
   For an accurate diagram, show:
   - one **CLI entrypoint**
   - a **service layer** in the middle
   - a **repository/storage layer**
   - a **JSON file store** as the persistence target
   - domain objects for **tasks, status, and area**
   - supporting utilities for **reading, formatting, validation, and errors**  
   Keep `cmd/api` and `internal/app` as a separate, likely future-facing scaffold rather than the active runtime path.

Main entry points: [`playground/TaskService/service.go`](https://github.com/zvoook/lifeforge/blob/main/playground/TaskService/service.go) (Task service), [`playground/TaskService/cli.go`](https://github.com/zvoook/lifeforge/blob/main/playground/TaskService/cli.go) (CLI loop), [`playground/TaskService/repository.go`](https://github.com/zvoook/lifeforge/blob/main/playground/TaskService/repository.go) (Repository), [`playground/TaskService/task.go`](https://github.com/zvoook/lifeforge/blob/main/playground/TaskService/task.go) (Task)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_g_active["Active TaskService"]
  node_n_main(("Main<br/>entrypoint<br/>[main.go]"))
  node_n_cli["CLI loop<br/>ui orchestrator<br/>[cli.go]"]
  node_n_handlers["Handlers<br/>command routing<br/>[handlers.go]"]
  node_n_readers["Readers<br/>input adapter<br/>[readers.go]"]
  node_n_formatters["Formatters<br/>output adapter<br/>[formatters.go]"]
  node_n_service["Task service<br/>application service<br/>[service.go]"]
  node_n_validation["Validation<br/>rule checks<br/>[validation.go]"]
  node_n_errors["Errors<br/>[errors.go]"]
  node_n_repository[("Repository<br/>persistence boundary<br/>[repository.go]")]
  node_n_storage["Storage<br/>[storage.go]"]
  node_n_task["Task<br/>entity<br/>[task.go]"]
  node_n_status(("Status<br/>enum<br/>[task_status.go]"))
  node_n_area(("Area<br/>enum<br/>[area.go]"))
  node_n_save["save.json<br/>file store<br/>[save.json]"]
end

subgraph group_g_future["Future scaffold"]
  node_n_cmdapi_main(("API main<br/>entrypoint<br/>[main.go]"))
  node_n_internal_app["App shell<br/>application scaffold<br/>[app.go]"]
end

subgraph group_g_misc["Learning exercises"]
  node_n_day01(("Day01<br/>practice app<br/>[main.go]"))
  node_n_day02(("Day02<br/>practice app<br/>[main.go]"))
end

node_n_main -->|"starts"| node_n_cli
node_n_cli -->|"dispatches"| node_n_handlers
node_n_cli -->|"reads"| node_n_readers
node_n_handlers -->|"calls"| node_n_service
node_n_readers -->|"checks"| node_n_validation
node_n_service -->|"enforces"| node_n_validation
node_n_service -->|"returns"| node_n_errors
node_n_service -->|"persists"| node_n_repository
node_n_repository -->|"uses"| node_n_storage
node_n_storage -->|"writes"| node_n_save
node_n_repository -->|"manages"| node_n_task
node_n_task -->|"has"| node_n_status
node_n_task -->|"belongs to"| node_n_area
node_n_service -->|"shapes"| node_n_formatters
node_n_formatters -->|"prints"| node_n_cli
node_n_cmdapi_main -.->|"boots"| node_n_internal_app

click node_n_main "https://github.com/zvoook/lifeforge/blob/main/playground/TaskService/main.go"
click node_n_cli "https://github.com/zvoook/lifeforge/blob/main/playground/TaskService/cli.go"
click node_n_handlers "https://github.com/zvoook/lifeforge/blob/main/playground/TaskService/handlers.go"
click node_n_readers "https://github.com/zvoook/lifeforge/blob/main/playground/TaskService/readers.go"
click node_n_formatters "https://github.com/zvoook/lifeforge/blob/main/playground/TaskService/formatters.go"
click node_n_service "https://github.com/zvoook/lifeforge/blob/main/playground/TaskService/service.go"
click node_n_validation "https://github.com/zvoook/lifeforge/blob/main/playground/TaskService/validation.go"
click node_n_errors "https://github.com/zvoook/lifeforge/blob/main/playground/TaskService/errors.go"
click node_n_repository "https://github.com/zvoook/lifeforge/blob/main/playground/TaskService/repository.go"
click node_n_storage "https://github.com/zvoook/lifeforge/blob/main/playground/TaskService/storage.go"
click node_n_task "https://github.com/zvoook/lifeforge/blob/main/playground/TaskService/task.go"
click node_n_status "https://github.com/zvoook/lifeforge/blob/main/playground/TaskService/task_status.go"
click node_n_area "https://github.com/zvoook/lifeforge/blob/main/playground/TaskService/area.go"
click node_n_save "https://github.com/zvoook/lifeforge/blob/main/playground/TaskService/save.json"
click node_n_cmdapi_main "https://github.com/zvoook/lifeforge/blob/main/cmd/api/main.go"
click node_n_internal_app "https://github.com/zvoook/lifeforge/blob/main/internal/app/app.go"
click node_n_day01 "https://github.com/zvoook/lifeforge/blob/main/playground/day01/main.go"
click node_n_day02 "https://github.com/zvoook/lifeforge/blob/main/playground/day02/main.go"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_n_main,node_n_cli,node_n_handlers,node_n_readers,node_n_formatters,node_n_service,node_n_validation,node_n_errors,node_n_repository,node_n_storage,node_n_task,node_n_status,node_n_area,node_n_save toneBlue
class node_n_cmdapi_main,node_n_internal_app toneAmber
class node_n_day01,node_n_day02 toneMint
```

## Components

### Active TaskService

Current runnable console task manager implementation under playground/TaskService

- [Main](https://github.com/zvoook/lifeforge/blob/main/playground/TaskService/main.go): entrypoint · CLI application entrypoint · `playground/TaskService/main.go`
- [CLI loop](https://github.com/zvoook/lifeforge/blob/main/playground/TaskService/cli.go): ui orchestrator · Coordinates the menu and interaction flow · `playground/TaskService/cli.go`
- [Handlers](https://github.com/zvoook/lifeforge/blob/main/playground/TaskService/handlers.go): command routing · Maps user commands to task actions · `playground/TaskService/handlers.go`
- [Readers](https://github.com/zvoook/lifeforge/blob/main/playground/TaskService/readers.go): input adapter · Collects and parses terminal input · `playground/TaskService/readers.go`
- [Formatters](https://github.com/zvoook/lifeforge/blob/main/playground/TaskService/formatters.go): output adapter · Turns domain data into console output · `playground/TaskService/formatters.go`
- [Task service](https://github.com/zvoook/lifeforge/blob/main/playground/TaskService/service.go): application service · Orchestrates task use cases and business rules · `playground/TaskService/service.go`
- [Validation](https://github.com/zvoook/lifeforge/blob/main/playground/TaskService/validation.go): rule checks · Validates inputs and illegal state transitions · `playground/TaskService/validation.go`
- [Errors](https://github.com/zvoook/lifeforge/blob/main/playground/TaskService/errors.go): domain errors · Shared error definitions for task workflows · `playground/TaskService/errors.go`
- [Repository](https://github.com/zvoook/lifeforge/blob/main/playground/TaskService/repository.go): persistence boundary · Task repository abstraction · `playground/TaskService/repository.go`
- [Storage](https://github.com/zvoook/lifeforge/blob/main/playground/TaskService/storage.go): json storage · Reads and writes the backing JSON data · `playground/TaskService/storage.go`
- [Task](https://github.com/zvoook/lifeforge/blob/main/playground/TaskService/task.go): entity · Core task record · `playground/TaskService/task.go`
- [Status](https://github.com/zvoook/lifeforge/blob/main/playground/TaskService/task_status.go): enum · Task completion state · `playground/TaskService/task_status.go`
- [Area](https://github.com/zvoook/lifeforge/blob/main/playground/TaskService/area.go): enum · Fixed development areas · `playground/TaskService/area.go`
- [save.json](https://github.com/zvoook/lifeforge/blob/main/playground/TaskService/save.json): file store · Local persisted task data · `playground/TaskService/save.json`

### Future scaffold

Embryonic production-style Go layout not yet the main runtime path

- [API main](https://github.com/zvoook/lifeforge/blob/main/cmd/api/main.go): entrypoint · Future-facing command entrypoint scaffold · `cmd/api/main.go`
- [App shell](https://github.com/zvoook/lifeforge/blob/main/internal/app/app.go): application scaffold · Thin internal app bootstrap layer · `internal/app/app.go`

### Learning exercises

Other playground entrypoints not central to the task manager

- [Day01](https://github.com/zvoook/lifeforge/blob/main/playground/day01/main.go): practice app · Standalone playground exercise · `playground/day01/main.go`
- [Day02](https://github.com/zvoook/lifeforge/blob/main/playground/day02/main.go): practice app · Standalone playground exercise · `playground/day02/main.go`

## Connections

- Main → CLI loop: starts · Bootstraps the console application
- CLI loop → Handlers: dispatches · Routes menu actions to handlers
- CLI loop → Readers: reads · Collects user input
- Handlers → Task service: calls · Invokes task use cases
- Readers → Validation: checks · Validates raw input before use
- Task service → Validation: enforces · Applies business-rule validation
- Task service → Errors: returns · Uses shared error values for failures
- Task service → Repository: persists · Stores and loads tasks through repository abstraction
- Repository → Storage: uses · Delegates file-backed persistence
- Storage → save.json: writes · Persists state to the JSON file
- Repository → Task: manages · Stores task entities
- Task → Status: has · Task completion state
- Task → Area: belongs to · Task is categorized by area
- Task service → Formatters: shapes · Prepares data for display
- Formatters → CLI loop: prints · Formats output for the console UI
- API main → App shell: boots · Future scaffold runtime path
