- Activity Logging: Pencatatan aktivitas API
- Client Registration: Sistem registrasi client dengan API key otomatis dan JWT authentication
- Usage Analytics: Statistik penggunaan harian dan peringkat client teratas
- Real-time Streaming: Server-Sent Events (SSE) untuk update real-time
- Rate Limiting: Pembatasan request per jam menggunakan Redis (1000 req/hour default)
- Batch Processing: Pemrosesan log dalam batch dengan queue system
- Table Partitioning: Partisi MySQL otomatis berdasarkan bulan untuk performa optimal
- Multi-level Caching: LRU cache + Redis untuk response caching
- Durable Queue: File-based fallback storage untuk ketahanan data
- API Key Authentication: Secure API key generation dan hashing
- JWT Token: Bearer token authentication untuk protected endpoints
- Data Encryption: AES-256-GCM encryption untuk sensitive data
- IP Whitelist Protection: Konfigurasi IP whitelist untuk akses API yang aman
- HMAC Validation: API key hashing dengan HMAC-SHA256
- Go 1.24+
- MySQL 8.0+
- Redis 6.0+
go mod download
cp config/config.yaml.example config/config.yaml
### Configuration
```yaml
# config/config.yaml
mode: "development"
database:
driver: "mysql"
host: "localhost"
port: "3306"
user: "your_user"
password: "your_password"
dbname: "logdb"
max_open_cons: 10
max_idle_cons: 5
max_life_time: 5
redis:
host: "localhost"
port: "6379"
password: ""
db: 0
pool_size: 10
min_idle_conns: 5
server:
port: 3000
# IP Whitelist Configuration
security:
ip_whitelist:
enabled: true
allowed_ips:
- "127.0.0.1"
- "::1"
secret:
jwt_key: "your_jwt_secret_key_here"
aes_key: "your_base64_encoded_aes_key_here" # 32 bytes base64
# Development mode
make run
# Build binary
make build
./main
# Generate Swagger docs
make swagger
# Run tests
make test# Build dan jalankan semua services
make docker-up
# Atau dengan docker compose langsung
docker compose up --build
# Jalankan di background
docker compose up -d --build- Monthly Partitions: Otomatis membuat partisi per bulan
- Auto Cleanup: Menghapus partisi lama (default: >3 bulan)
- Future-proof: Partisi
p_futureuntuk data di masa depan
p_YYYYMM # Contoh: p_202511, p_202512, p_202601
- Single IP:
192.168.1.100 - IPv6:
2001:db8::1 - CIDR Range:
192.168.1.0/24 - IPv6 CIDR:
2001:db8::/32
X-Forwarded-For(load balancer/proxy)X-Real-IP(nginx)X-Client-IPCF-Connecting-IP(Cloudflare)RemoteAddr(fallback)
log-activity-system/
├── cmd/server/main.go # Entry point
├── config/config.yaml # Configuration
├── docs/ # Swagger documentation
├── internal/
│ ├── adapter/
│ │ ├── http/ # REST API handlers
│ │ ├── memory/ # Cache implementation
│ │ └── repository/ # Data access layer
│ ├── applications/
│ │ ├── dto/ # Request/Response models
│ │ ├── port/ # Interface definitions
│ │ └── service/ # Business logic
│ ├── domain/ # Domain entities
│ │ ├── client.go
│ │ ├── log-entry.go
│ │ └── errors.go
│ ├── infrastructure/
│ │ ├── presistence/ # Database & partitioning
│ │ ├── security/ # Crypto & JWT
│ │ ├── memory/ # Redis connection
│ │ └── ratelimit/ # Rate limiting
│ └── utils/ # Utilities
├── Makefile # Build commands
├── go.mod # Dependencies
└── README.md
- Gin Framework untuk HTTP router
- GORM untuk database ORM
- Redis untuk caching dan rate limiting
- JWT-Go untuk token authentication
- Swagger untuk API documentation