Skip to content

danilovid/LinkKeeper

Repository files navigation

LinkKeeper

Modern link management system with Telegram bot, REST API, and web interface support

CI Go Version License

LinkKeeper is a full-featured system for saving, organizing, and managing links with support for multiple interfaces: Telegram bot, REST API, and modern web interface.

✨ Features

πŸ”— Link Management

  • βœ… Save links with categories (resources)
  • βœ… View view statistics
  • βœ… Get random links
  • βœ… Filter by resources
  • βœ… Search links

πŸ€– Telegram Bot

  • βœ… Interactive menu with buttons
  • βœ… Save links via commands
  • βœ… Get random links
  • βœ… Filter by resource types (articles, videos)
  • βœ… Automatic user registration

🌐 REST API

  • βœ… Full CRUD for links
  • βœ… View statistics
  • βœ… RESTful architecture
  • βœ… CORS support

πŸ‘₯ User Management

  • βœ… Automatic registration on first use
  • βœ… Personalization via Telegram ID
  • βœ… User existence check

πŸ“± Web Interface

  • βœ… Modern React Native interface
  • βœ… Dark theme in GitHub/Cursor style
  • βœ… Responsive design
  • βœ… Statistics and analytics
  • βœ… Multiple UI variants

πŸ—οΈ Architecture

LinkKeeper is built on a microservices architecture:

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Frontend  │────▢│  API Service │────▢│ PostgreSQL  β”‚
β”‚ (React/Expo)β”‚     β”‚   (Go)       β”‚     β”‚  Database   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                            β”‚
                            β”‚
                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”
                    β”‚               β”‚
            β”Œβ”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”
            β”‚ Bot Service  β”‚ β”‚ User Service  β”‚
            β”‚    (Go)      β”‚ β”‚     (Go)      β”‚
            β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Services

  1. API Service (:8080) β€” main REST API for link management
  2. User Service (:8081) β€” Telegram user management
  3. Bot Service β€” Telegram bot for interactive management
  4. Frontend β€” web interface on React Native/Expo

πŸš€ Quick Start

Requirements

  • Go 1.23+
  • Node.js 18+
  • PostgreSQL 16+
  • Docker and Docker Compose (optional)
  • Telegram Bot Token (for bot)

Installation

  1. Clone the repository:
git clone https://github.com/danilovid/linkkeeper.git
cd linkkeeper
  1. Install dependencies:
# Go dependencies
go mod download
go mod vendor

# Frontend dependencies
cd frontend && npm install && cd ..
  1. Set up the database:
# Start PostgreSQL via Docker
task db:up

# Apply migrations
task db:migrate
  1. Configure environment variables:
export POSTGRES_DSN="postgres://postgres:postgres@localhost:5432/linkkeeper?sslmode=disable"
export TELEGRAM_TOKEN="your_telegram_bot_token"
export API_BASE_URL="http://localhost:8080"
export USER_SERVICE_URL="http://localhost:8081"

Running

Option 1: Docker Compose (recommended)

# Start all services
task start

# Or directly
docker-compose up -d

Option 2: Local Run

# Terminal 1: API Service
task api:run

# Terminal 2: User Service
task user:run

# Terminal 3: Bot Service
export TELEGRAM_TOKEN="your_token"
task bot:run

# Terminal 4: Frontend
task frontend:start

πŸ“– Usage

API Endpoints

Links

  • POST /api/v1/links β€” create link
  • GET /api/v1/links β€” list links
  • GET /api/v1/links/{id} β€” get link
  • GET /api/v1/links/random β€” random link
  • POST /api/v1/links/{id}/viewed β€” mark as viewed
  • DELETE /api/v1/links/{id} β€” delete link
  • GET /api/v1/stats β€” view statistics

Users

  • POST /api/v1/users β€” create/get user
  • GET /api/v1/users/{id} β€” get user
  • GET /api/v1/users/telegram/{telegram_id} β€” get by Telegram ID
  • GET /api/v1/users/telegram/{telegram_id}/exists β€” check existence

Telegram Bot

Commands:

  • /start β€” start working with bot
  • /save <url> β€” save link
  • /viewed <id> β€” mark link as viewed
  • /random [resource] β€” get random link

Buttons:

  • πŸ’Ύ Save link β€” save link
  • βœ… Mark viewed β€” mark as viewed
  • 🎲 Random β€” random link
  • πŸ“° Random article β€” random article
  • 🎬 Random video β€” random video

Frontend

Open http://localhost:19006 (or port specified by Expo)

Features:

  • View all links
  • Add new links
  • Search and filter
  • View statistics
  • Modern interface

πŸ§ͺ Testing

Running Tests

# All tests
task test

# With coverage
task test:coverage

# Unit tests only
task test:unit

# Integration tests
task test:integration

Coverage Statistics

Component Coverage
User Service (Usecase) 100% βœ…
User Service (Repository) 86.4% βœ…
API Service (Usecase) 52.2% ⚠️
User Service (HTTP) 50.7% ⚠️
Overall ~70% ⚠️

Total tests: 38 unit + 3 integration

For more details: Testing Guide

πŸ”§ Development

Project Structure

LinkKeeper/
β”œβ”€β”€ cmd/                    # Service entry points
β”‚   β”œβ”€β”€ api-service/
β”‚   β”œβ”€β”€ bot-service/
β”‚   └── user-service/
β”œβ”€β”€ internal/               # Internal packages
β”‚   β”œβ”€β”€ api-service/        # API service
β”‚   β”œβ”€β”€ bot-service/        # Telegram bot
β”‚   └── user-service/       # User service
β”œβ”€β”€ pkg/                    # Shared packages
β”‚   β”œβ”€β”€ config/            # Configuration
β”‚   β”œβ”€β”€ database/          # Database
β”‚   β”œβ”€β”€ httpclient/        # HTTP client
β”‚   └── logger/            # Logging
β”œβ”€β”€ frontend/              # React Native application
β”œβ”€β”€ migrations/            # SQL migrations
β”œβ”€β”€ build/                 # Dockerfiles
β”œβ”€β”€ tests/                 # Integration tests
└── .github/workflows/     # CI/CD

Development Commands

# Show all available commands
task

# Code formatting
task fmt

# Linting
task lint

# Run CI checks locally
task ci:local

# Install pre-commit hooks
task hooks:install

Pre-commit Hooks

Automatically before each commit:

  • βœ… Code formatting
  • βœ… go vet
  • βœ… go mod tidy
  • βœ… Unit tests

Installation:

task hooks:install

🚒 CI/CD

GitHub Actions

Automatically runs on:

  • Push to main and develop
  • Pull requests

Pipeline includes:

  1. βœ… Tests (with race detector)
  2. βœ… Linting (golangci-lint)
  3. βœ… Formatting (go fmt)
  4. βœ… Build all services
  5. βœ… Docker images (main branch)

For more details: CI/CD Documentation

πŸ“š Documentation

All documentation is located in the docs/ directory:

πŸ› οΈ Technologies

Backend

  • Go 1.23+ β€” main language
  • PostgreSQL 16+ β€” database
  • GORM β€” ORM
  • Gorilla Mux β€” HTTP routing
  • Zerolog β€” logging
  • Telebot β€” Telegram Bot API

Frontend

  • React Native β€” mobile framework
  • Expo β€” development tools
  • TypeScript β€” typing

DevOps

  • Docker & Docker Compose β€” containerization
  • GitHub Actions β€” CI/CD
  • golangci-lint β€” linter
  • pre-commit β€” git hooks

πŸ” Configuration

Environment Variables

API Service

  • HTTP_ADDR β€” HTTP server address (default: :8080)
  • POSTGRES_DSN β€” PostgreSQL connection string

User Service

  • HTTP_ADDR β€” HTTP server address (default: :8081)
  • POSTGRES_DSN β€” PostgreSQL connection string

Bot Service

  • TELEGRAM_TOKEN β€” Telegram bot token (required)
  • API_BASE_URL β€” API service URL (default: http://localhost:8080)
  • USER_SERVICE_URL β€” User service URL (default: http://localhost:8081)
  • BOT_TIMEOUT_SECONDS β€” request timeout (default: 10)

🀝 Contributing

  1. Fork the project
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Guidelines

  • βœ… Follow Go code style
  • βœ… Add tests for new features
  • βœ… Update documentation
  • βœ… Use Conventional Commits

πŸ“ License

MIT License β€” see LICENSE file

πŸ‘€ Author

Danilovid

πŸ™ Acknowledgments

  • Telebot β€” excellent library for Telegram bots
  • GORM β€” powerful ORM for Go
  • Expo β€” tools for React Native development

πŸ“Š Project Status

  • βœ… API Service β€” ready
  • βœ… User Service β€” ready
  • βœ… Bot Service β€” ready
  • βœ… Frontend β€” ready
  • βœ… Tests β€” 38 unit + 3 integration
  • βœ… CI/CD β€” configured
  • ⚠️ Test coverage β€” 70% (target: 85%)

Made with ❀️ for convenient link management

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors