{"id":51136974,"url":"https://github.com/peter7775/go-iching","last_synced_at":"2026-06-25T19:01:42.771Z","repository":{"id":361912137,"uuid":"1256407836","full_name":"peter7775/go-iching","owner":"peter7775","description":"A Go application for I Ching divination with a Fiber-based HTTP API, a browser frontend, and persistent reading storage.","archived":false,"fork":false,"pushed_at":"2026-06-19T19:03:01.000Z","size":4983,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2026-06-19T21:07:14.513Z","etag":null,"topics":["api-rest","fiber","go","golang","i-ching","postgresql","sqlite","ui"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/peter7775.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-06-01T18:47:00.000Z","updated_at":"2026-06-19T19:03:05.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/peter7775/go-iching","commit_stats":null,"previous_names":["peter7775/go-iching"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/peter7775/go-iching","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peter7775%2Fgo-iching","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peter7775%2Fgo-iching/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peter7775%2Fgo-iching/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peter7775%2Fgo-iching/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/peter7775","download_url":"https://codeload.github.com/peter7775/go-iching/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peter7775%2Fgo-iching/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34788254,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-25T02:00:05.521Z","response_time":101,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api-rest","fiber","go","golang","i-ching","postgresql","sqlite","ui"],"created_at":"2026-06-25T19:01:42.022Z","updated_at":"2026-06-25T19:01:42.765Z","avatar_url":"https://github.com/peter7775.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# I Ching App\n\nA Go application for I Ching divination (Wilhelm standart dataset, not AI blah-blah) with a Fiber-based HTTP API, a browser frontend, and persistent reading storage. The current project supports SQLite, PostgreSQL, and in-memory repositories.\n\n\n\u003cimg width=\"1196\" height=\"996\" alt=\"image\" src=\"https://github.com/user-attachments/assets/b229fa5d-9edf-4e09-be43-7c80e8adc5f6\" /\u003e\n\n## [Please provide a feedback](https://github.com/peter7775/go-iching/discussions/3#discussion-10208866)\n\n## Quick Start\n\n### Installation Options\n\n#### Option 1: Pre-built Binary (Recommended)\n\nDownload the latest release from [GitHub Releases](https://github.com/peter7775/go-iching/releases) and extract it for your platform.\n\n**Linux/macOS**:\n```bash\n# Download the binary (replace vX.Y.Z with the latest version)\nwget https://github.com/peter7775/go-iching/releases/download/vX.Y.Z/iching-api-linux-amd64-vX.Y.Z.tar.gz\n\n# Extract\ntar -xzf iching-api-linux-amd64-vX.Y.Z.tar.gz\n\n# Run\nchmod +x iching-api-linux-amd64\n./iching-api-linux-amd64\n```\n\n**Windows**:\n```cmd\n# Download and extract the ZIP file from GitHub Releases\n# Then run:\niching-api-windows-amd64.exe\n```\n\n**macOS (ARM64)**:\n```bash\n# For Apple Silicon (M1/M2/M3)\ntar -xzf iching-api-darwin-arm64-vX.Y.Z.tar.gz\nchmod +x iching-api-darwin-arm64\n./iching-api-darwin-arm64\n```\n\n#### Option 2: Build from Source\n\n**Prerequisites**:\n- Go 1.21 or later\n- Make\n\n**Steps**:\n```bash\n# Clone the repository\ngit clone https://github.com/peter7775/go-iching.git\ncd go-iching\n\n# Run the application\ngo run ./cmd/api\n```\n\nThe app will start on `http://localhost:8080` by default.\n\n#### Option 3: Docker\n\n```bash\n# Build Docker image\ndocker build -t iching-app .\n\n# Run container\ndocker run -p 8080:8080 \\\n  -e STORAGE=sqlite \\\n  -e SQLITE_PATH=iching.db \\\n  -v $(pwd)/data:/app/data \\\n  iching-app\n```\n\nAccess the app at `http://localhost:8080`.\n\n---\n\n## Configuration\n\nConfigure the application using environment variables:\n\n```env\n# Storage backend: sqlite, postgres, or memory (default: sqlite)\nSTORAGE=sqlite\n\n# SQLite configuration\nSQLITE_PATH=iching.db\n\n# PostgreSQL configuration (if STORAGE=postgres)\nPOSTGRES_DSN=postgres://user:password@localhost:5432/iching\n\n# Server address (default: :8080)\nADDR=:8080\n```\n\n### Storage Backend Details\n\n**SQLite** (Default - recommended for single-user):\n- No external dependencies\n- Readings stored in local database\n- Perfect for personal use or small deployments\n\n**PostgreSQL** (For shared/production deployments):\n- Supports multiple concurrent users\n- Requires PostgreSQL server\n- Connection via DSN: `postgres://user:password@host:port/database`\n\n**In-Memory** (Testing only):\n- No persistence\n- Useful for testing\n- Readings lost on restart\n\n---\n\n## Overview\n\nThe application is structured as a small web app. A Go backend handles reading generation and persistence, while the frontend is served as static files from `cmd/api/static`. The API currently exposes REST endpoints for CRUD operations on readings.\n\nEach stored reading includes:\n- question text\n- cast method\n- language\n- raw line values\n- primary and relating hexagram numbers\n- serialized interpretation\n- optional reflection rating, note, and timestamp\n- creation timestamp\n\n## Architecture\n\nMain components in the current project:\n\n- `cmd/api` — application entrypoint and startup logic\n- `internal/httpfiber` — Fiber app configuration and HTTP routes\n- `internal/service` — application and reading logic\n- `internal/storage/sqlite` — SQLite persistence for saved readings\n- `internal/storage/postgres` — PostgreSQL repository option\n- `internal/storage/memory` — in-memory fallback repository\n- `web/static` — browser UI served by the backend\n\n## API Endpoints\n\nThe current HTTP layer exposes these routes:\n\n| Method | Path | Description |\n|---|---|---|\n| GET | `/health` | Returns a simple health response |\n| GET | `/api/readings` | Returns the saved reading history |\n| GET | `/api/readings/:id` | Returns one saved reading by ID |\n| POST | `/api/readings` | Creates a reading from the request payload |\n| POST | `/api/readings/random` | Creates a randomized reading using coin casting mode |\n\n## Storage Backends\n\nThe repository is selected by application configuration. If `cfg.Storage` is set to `sqlite`, the app opens `cfg.SQLitePath` and uses the SQLite repository. If it is set to `postgres`, the app connects via the PostgreSQL DSN.\n\n### SQLite\n\nThe SQLite repository creates a `readings` table if it does not exist and stores both structured fields and serialized JSON payloads. The current schema includes `question`, `method`, `language`, and other fields.\n\nReads are ordered by `created_at DESC`, which means the latest saved readings appear first in history. The repository also supports loading a single reading by ID and updating reflection data.\n\n### PostgreSQL\n\nPostgreSQL is available as an alternative repository and is activated when the storage mode is `postgres`. The application opens the connection using `sql.Open(\"pgx\", cfg.PostgresDSN)`.\n\n### In-Memory Mode\n\nIn-memory storage is only a fallback. It is useful for tests or temporary runs, but readings are not persisted across process restarts.\n\n## Development\n\n### Run Locally\n\nStart the application with:\n\n```bash\ngo run ./cmd/api\n```\n\nThe current startup code loads configuration, initializes the selected repository, creates the reading service, builds the Fiber app, and starts listening on `cfg.Addr`. It also installs graceful shutdown handlers.\n\n### Build for Specific Platform\n\n**Windows x86_64**:\n```bash\nCGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -o iching.exe ./cmd/api\n```\n\n**Linux x86_64**:\n```bash\nCGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o iching-api ./cmd/api\n```\n\n**macOS (ARM64)**:\n```bash\nCGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -o iching-api ./cmd/api\n```\n\n## Release Management\n\n### Local Release Build\n\nTo build release packages for all platforms (Linux, Windows, macOS):\n\n```bash\nmake release-build\n```\n\nThis will:\n1. Run code quality checks (tidy, vet, lint, test)\n2. Build binaries for all platforms (x86_64 and ARM64 variants)\n3. Create compressed archives in `dist/` directory\n\nIndividual platform builds:\n```bash\nmake build-linux              # Linux x86_64\nmake build-linux-arm64        # Linux ARM64\nmake build-windows            # Windows x86_64\nmake build-windows-arm64      # Windows ARM64\nmake build-darwin             # macOS x86_64\nmake build-darwin-arm64       # macOS ARM64\n```\n\n### Publish a Release\n\n1. **Prepare code**: Ensure all changes are committed and tests pass\n   ```bash\n   make audit  # Runs tidy, vet, lint, test\n   ```\n\n2. **Create a release tag**: Tags should follow semantic versioning (e.g., `v0.1.0`, `v1.0.0-beta`)\n   ```bash\n   git tag -a v0.1.0 -m \"Release v0.1.0: Initial release\"\n   git push origin v0.1.0\n   ```\n\n3. **GitHub Actions**: When you push a tag starting with `v`, GitHub Actions automatically:\n   - Builds binaries for all platforms\n   - Creates compressed archives\n   - Creates a GitHub Release with all artifacts\n\n4. **Manual Release Build** (if not using GitHub Actions):\n   ```bash\n   git tag -a v0.1.0 -m \"Release v0.1.0\"\n   make release-build\n   ```\n\n### Distribution Files\n\nRelease packages include:\n- **Linux**: `iching-api-linux-amd64-vX.Y.Z.tar.gz`, `iching-api-linux-arm64-vX.Y.Z.tar.gz`\n- **Windows**: `iching-api-windows-amd64-vX.Y.Z.zip`, `iching-api-windows-arm64-vX.Y.Z.zip`\n- **macOS**: `iching-api-darwin-amd64-vX.Y.Z.tar.gz`, `iching-api-darwin-arm64-vX.Y.Z.tar.gz`\n\nEach archive contains:\n- Compiled binary for the platform\n- `static/` directory with web UI files\n\n## Browser Behavior\n\nThe application starts the server and logs the listening address. Open your browser and navigate to the address shown in the console (typically `http://localhost:8080`).\n\n## Notes\n\n- The current SQLite repository stores line data and interpretation data as JSON strings in the database\n- Reading history is returned in reverse chronological order\n- Reflection persistence is present at repository level through `SaveReflection(...)`, but the currently known HTTP layer does not yet expose dedicated reflection endpoints\n- The current repository scans `language` as a plain string, so nullable historical rows may require a migration or a repository fix if older data contains `NULL` in that column\n\n## License\n\nThis project is released under the Custom Attribution Software License v1.0.\n\n## Attribution\n\nIf you reuse, redistribute, or modify this software, you must keep the copyright notice and credit:\n\nPetr Štěpánek \u003cpetrstepanek99@proton.me\u003e\n\nSee [LICENSE](LICENSE) for full details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpeter7775%2Fgo-iching","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpeter7775%2Fgo-iching","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpeter7775%2Fgo-iching/lists"}