Skip to content

Instantly share code, notes, and snippets.

@komsit37
Created July 30, 2025 14:09
Show Gist options
  • Select an option

  • Save komsit37/9d7f7fcae1925169dc227e18ad8c4f0d to your computer and use it in GitHub Desktop.

Select an option

Save komsit37/9d7f7fcae1925169dc227e18ad8c4f0d to your computer and use it in GitHub Desktop.
example claude plan.md

EDINET Go Migration Plan

Overview

Migration of @gcp/doc-index/functions/src/edinet2/ to standalone Go application with dev container environment.

Tech Stack

  • Runtime: Go 1.21+
  • Web Framework: Gin
  • Database: PostgreSQL 15
  • Cache: Redis 7
  • Object Storage: MinIO (S3-compatible)
  • Development: Dev Container with Docker Compose

Project Structure

apps/edinet-go/
├── .devcontainer/
│   ├── devcontainer.json
│   └── docker-compose.yml
├── cmd/
│   └── server/
│       └── main.go
├── internal/
│   ├── config/
│   ├── handlers/
│   ├── services/
│   ├── models/
│   └── storage/
├── migrations/
├── logs/
├── tasks/
│   └── 1-migration-plan.md
├── go.mod
├── go.sum
├── Dockerfile
└── README.md

Migration Phases

Phase 1: Foundation Setup

Goal: Establish dev container environment with basic Go framework and essential infrastructure

1.1 Dev Container Setup

  • Create .devcontainer/devcontainer.json
    • Go 1.21+ with extensions
    • Database tools (psql, redis-cli, mc)
    • Air for hot reload
  • Create docker-compose.yml with services:
    • PostgreSQL 15 (port 5432)
    • Redis 7 (port 6379)
    • MinIO (port 9000/9001)
  • Configure service networking and volumes

1.2 Go Project Initialization

  • Initialize Go module: go mod init edinet-go
  • Add core dependencies:
    github.com/gin-gonic/gin
    github.com/lib/pq
    github.com/go-redis/redis/v8
    github.com/minio/minio-go/v7
    github.com/sirupsen/logrus
    github.com/stretchr/testify
    gopkg.in/natefinch/lumberjack.v2

1.3 Basic Application Framework

  • Create cmd/server/main.go with:
    • Configuration loading
    • Database connection
    • Redis connection
    • MinIO connection
    • Gin router setup
    • Graceful shutdown
  • Create internal/config/config.go:
    • Environment variable loading
    • Service connection strings
    • Logging configuration
  • Create storage layer (internal/storage/):
    • Database connection management
    • Redis client setup
    • MinIO client setup

1.4 File Logging System

  • Implement structured logging with logrus
  • Log rotation configuration
  • Different log levels (DEBUG, INFO, WARN, ERROR)
  • Request/response logging middleware
  • Error logging with stack traces

1.5 Health Check Endpoints

  • GET /health - Basic health check
  • GET /health/db - Database connection test
  • GET /health/redis - Redis connection test
  • GET /health/minio - MinIO connection test
  • GET /health/full - All services health check

1.6 Basic Tests

  • Unit tests for configuration loading
  • HTTP handler tests for health endpoints with mocks
  • Test framework setup with testify
  • Mock implementations for storage interfaces

1.7 Development Tools

  • Air configuration for hot reload
  • Makefile for common tasks:
    • make dev - Start dev environment
    • make test - Run tests
    • make build - Build application
    • make clean - Clean containers
    • make setup - Setup dev environment
    • make health - Check service health
  • Linting configuration (golangci-lint)
  • Git ignore configuration
  • Development workflow automation

1.8 Documentation

  • README.md with setup instructions
  • Environment variable documentation
  • Development workflow documentation
  • API endpoint documentation
  • Project structure documentation

Phase 1 Success Criteria

  • Dev container starts successfully
  • All services (PostgreSQL, Redis, MinIO) are accessible
  • Go application starts without errors
  • All health check endpoints return 200 OK
  • File logging works with proper rotation
  • All tests pass
  • Hot reload works during development

Phase 1 Status: ✅ COMPLETED

Implementation Date: January 2025
All deliverables: ✅ Complete
Success criteria: ✅ All met

Phase 1 Deliverables

  1. Working dev container environment
  2. Basic Go web server with Gin
  3. Database, Redis, and MinIO connections
  4. Health check endpoints
  5. File logging system
  6. Basic test suite
  7. Development tooling (Makefile, Air)
  8. Documentation

Next Phases (Preview)

  • Phase 2: Database schema and models
  • Phase 3: EDINET search API migration
  • Phase 4: XBRL download and processing
  • Phase 5: Document storage and caching
  • Phase 6: Performance optimization and monitoring
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment