diff --git a/COMMIT_MESSAGE_SUGGESTION.txt b/COMMIT_MESSAGE_SUGGESTION.txt new file mode 100644 index 0000000..ebc768a --- /dev/null +++ b/COMMIT_MESSAGE_SUGGESTION.txt @@ -0,0 +1,23 @@ +docs: organize documentation into docs/ directory and translate README to English + +- Move all documentation files to docs/ directory +- Create docs/README.md as documentation index +- Update all internal links in documentation +- Translate main README.md to English +- Update documentation links in main README + +Files moved: +- ARCHITECTURE_TESTING.md +- CI_CD.md +- CI_FIXES.md +- GOFMT_FIX.md +- LINTER_FIXES.md +- README_TESTING_CI.md +- TESTIFY_FIX.md +- TESTING.md +- TEST_SUMMARY.md +- USER_SERVICE_README.md +- COMMIT_MESSAGE.txt + +This improves project organization by keeping the root directory clean +and making it easier to find and navigate documentation. diff --git a/README.md b/README.md index a8668e0..0a79783 100644 --- a/README.md +++ b/README.md @@ -1 +1,391 @@ # LinkKeeper + +> Modern link management system with Telegram bot, REST API, and web interface support + +[![CI](https://github.com/danilovid/linkkeeper/workflows/CI/badge.svg)](https://github.com/danilovid/linkkeeper/actions) +[![Go Version](https://img.shields.io/badge/Go-1.23+-00ADD8?logo=go)](https://golang.org) +[![License](https://img.shields.io/badge/license-MIT-blue.svg)](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:** +```bash +git clone https://github.com/danilovid/linkkeeper.git +cd linkkeeper +``` + +2. **Install dependencies:** +```bash +# Go dependencies +go mod download +go mod vendor + +# Frontend dependencies +cd frontend && npm install && cd .. +``` + +3. **Set up the database:** +```bash +# Start PostgreSQL via Docker +task db:up + +# Apply migrations +task db:migrate +``` + +4. **Configure environment variables:** +```bash +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) + +```bash +# Start all services +task start + +# Or directly +docker-compose up -d +``` + +#### Option 2: Local Run + +```bash +# 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 ` β€” save link +- `/viewed ` β€” 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 + +```bash +# 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](./docs/TESTING.md) + +## πŸ”§ 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 + +```bash +# 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: +```bash +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](./docs/CI_CD.md) + +## πŸ“š Documentation + +All documentation is located in the [`docs/`](./docs/) directory: + +- [Testing Guide](./docs/TESTING.md) β€” comprehensive testing documentation +- [CI/CD Documentation](./docs/CI_CD.md) β€” CI/CD pipeline details +- [Test Coverage Summary](./docs/TEST_SUMMARY.md) β€” coverage statistics +- [Testing & CI Quick Start](./docs/README_TESTING_CI.md) β€” quick start guide +- [User Service Documentation](./docs/USER_SERVICE_README.md) β€” User Service details +- [Documentation Index](./docs/README.md) β€” complete documentation index +- [Frontend Documentation](./frontend/README.md) β€” Frontend documentation + +## πŸ› οΈ 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](LICENSE) file + +## πŸ‘€ Author + +**Danilovid** + +- GitHub: [@danilovid](https://github.com/danilovid) + +## πŸ™ Acknowledgments + +- [Telebot](https://github.com/tucnak/telebot) β€” excellent library for Telegram bots +- [GORM](https://gorm.io/) β€” powerful ORM for Go +- [Expo](https://expo.dev/) β€” 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** diff --git a/ARCHITECTURE_TESTING.md b/docs/ARCHITECTURE_TESTING.md similarity index 100% rename from ARCHITECTURE_TESTING.md rename to docs/ARCHITECTURE_TESTING.md diff --git a/CI_CD.md b/docs/CI_CD.md similarity index 100% rename from CI_CD.md rename to docs/CI_CD.md diff --git a/CI_FIXES.md b/docs/CI_FIXES.md similarity index 100% rename from CI_FIXES.md rename to docs/CI_FIXES.md diff --git a/COMMIT_MESSAGE.txt b/docs/COMMIT_MESSAGE.txt similarity index 100% rename from COMMIT_MESSAGE.txt rename to docs/COMMIT_MESSAGE.txt diff --git a/GOFMT_FIX.md b/docs/GOFMT_FIX.md similarity index 100% rename from GOFMT_FIX.md rename to docs/GOFMT_FIX.md diff --git a/LINTER_FIXES.md b/docs/LINTER_FIXES.md similarity index 100% rename from LINTER_FIXES.md rename to docs/LINTER_FIXES.md diff --git a/docs/README.md b/docs/README.md new file mode 100644 index 0000000..0e1723a --- /dev/null +++ b/docs/README.md @@ -0,0 +1,54 @@ +# Documentation + +This directory contains all project documentation. + +## πŸ“š Available Documentation + +### Testing & Quality +- **[TESTING.md](./TESTING.md)** β€” Comprehensive testing guide +- **[TEST_SUMMARY.md](./TEST_SUMMARY.md)** β€” Test coverage statistics +- **[README_TESTING_CI.md](./README_TESTING_CI.md)** β€” Testing and CI quick start guide + +### CI/CD +- **[CI_CD.md](./CI_CD.md)** β€” CI/CD pipeline documentation +- **[CI_FIXES.md](./CI_FIXES.md)** β€” CI fixes and improvements +- **[GOFMT_FIX.md](./GOFMT_FIX.md)** β€” gofmt check fixes +- **[TESTIFY_FIX.md](./TESTIFY_FIX.md)** β€” Testify dependency fixes +- **[LINTER_FIXES.md](./LINTER_FIXES.md)** β€” Linter errors fixes + +### Architecture & Development +- **[ARCHITECTURE_TESTING.md](./ARCHITECTURE_TESTING.md)** β€” Architecture and testing details +- **[USER_SERVICE_README.md](./USER_SERVICE_README.md)** β€” User Service documentation + +### Other +- **[COMMIT_MESSAGE.txt](./COMMIT_MESSAGE.txt)** β€” Example commit message template + +## πŸ”— Quick Links + +- [Main README](../README.md) β€” Project overview and quick start +- [Frontend Documentation](../frontend/README.md) β€” Frontend documentation + +## πŸ“– Documentation Structure + +``` +docs/ +β”œβ”€β”€ README.md # This file +β”œβ”€β”€ TESTING.md # Testing guide +β”œβ”€β”€ TEST_SUMMARY.md # Coverage statistics +β”œβ”€β”€ CI_CD.md # CI/CD documentation +β”œβ”€β”€ README_TESTING_CI.md # Testing & CI quick start +β”œβ”€β”€ USER_SERVICE_README.md # User Service docs +β”œβ”€β”€ ARCHITECTURE_TESTING.md # Architecture details +β”œβ”€β”€ CI_FIXES.md # CI fixes +β”œβ”€β”€ GOFMT_FIX.md # gofmt fixes +β”œβ”€β”€ TESTIFY_FIX.md # Testify fixes +β”œβ”€β”€ LINTER_FIXES.md # Linter fixes +└── COMMIT_MESSAGE.txt # Commit template +``` + +## 🎯 Getting Started + +1. **New to the project?** Start with the [Main README](../README.md) +2. **Want to run tests?** Check [TESTING.md](./TESTING.md) +3. **Setting up CI/CD?** Read [CI_CD.md](./CI_CD.md) +4. **Contributing?** See [README_TESTING_CI.md](./README_TESTING_CI.md) diff --git a/README_TESTING_CI.md b/docs/README_TESTING_CI.md similarity index 94% rename from README_TESTING_CI.md rename to docs/README_TESTING_CI.md index de5a0d6..8828288 100644 --- a/README_TESTING_CI.md +++ b/docs/README_TESTING_CI.md @@ -85,10 +85,10 @@ Located in `.pre-commit-config.yaml` ### βœ… Documentation -- `TESTING.md` - Comprehensive testing guide -- `CI_CD.md` - CI/CD documentation -- `TEST_SUMMARY.md` - Coverage summary -- `README_TESTING_CI.md` - This file +- [TESTING.md](./TESTING.md) - Comprehensive testing guide +- [CI_CD.md](./CI_CD.md) - CI/CD documentation +- [TEST_SUMMARY.md](./TEST_SUMMARY.md) - Coverage summary +- [README_TESTING_CI.md](./README_TESTING_CI.md) - This file ## Testing Stack @@ -129,10 +129,11 @@ LinkKeeper/ β”œβ”€β”€ .pre-commit-config.yaml # ✨ Pre-commit hooks β”œβ”€β”€ Makefile # ✨ Make commands β”œβ”€β”€ Taskfile.yml # Updated with test tasks -β”œβ”€β”€ TESTING.md # ✨ Testing guide -β”œβ”€β”€ CI_CD.md # ✨ CI/CD guide -β”œβ”€β”€ TEST_SUMMARY.md # ✨ Coverage summary -└── README_TESTING_CI.md # ✨ This file +β”œβ”€β”€ docs/ +β”‚ β”œβ”€β”€ TESTING.md # ✨ Testing guide +β”‚ β”œβ”€β”€ CI_CD.md # ✨ CI/CD guide +β”‚ β”œβ”€β”€ TEST_SUMMARY.md # ✨ Coverage summary +β”‚ └── README_TESTING_CI.md # ✨ This file ``` ## Development Workflow @@ -432,7 +433,7 @@ Types: ## Support If you have questions: -1. Check documentation (TESTING.md, CI_CD.md) +1. Check documentation ([TESTING.md](./TESTING.md), [CI_CD.md](./CI_CD.md)) 2. Look at existing tests for examples 3. Ask team members 4. Create an issue diff --git a/TESTIFY_FIX.md b/docs/TESTIFY_FIX.md similarity index 100% rename from TESTIFY_FIX.md rename to docs/TESTIFY_FIX.md diff --git a/TESTING.md b/docs/TESTING.md similarity index 100% rename from TESTING.md rename to docs/TESTING.md diff --git a/TEST_SUMMARY.md b/docs/TEST_SUMMARY.md similarity index 97% rename from TEST_SUMMARY.md rename to docs/TEST_SUMMARY.md index 01fde65..3050727 100644 --- a/TEST_SUMMARY.md +++ b/docs/TEST_SUMMARY.md @@ -270,8 +270,8 @@ go tool cover -func=coverage.out ## Documentation -- See `TESTING.md` for detailed testing guide -- See `CI_CD.md` for CI/CD documentation +- See [TESTING.md](./TESTING.md) for detailed testing guide +- See [CI_CD.md](./CI_CD.md) for CI/CD documentation - See `.github/workflows/ci.yml` for pipeline configuration - See `.golangci.yml` for linter configuration @@ -289,7 +289,7 @@ ci: update GitHub Actions workflow ## Contact & Support For questions about testing: -1. Check `TESTING.md` documentation +1. Check [TESTING.md](./TESTING.md) documentation 2. Review existing tests for examples 3. Ask in team chat 4. Create an issue if you find problems diff --git a/USER_SERVICE_README.md b/docs/USER_SERVICE_README.md similarity index 100% rename from USER_SERVICE_README.md rename to docs/USER_SERVICE_README.md