# BMS Service - Bookmarks, Snippets & Notes Manager REST API service for managing bookmarks, code snippets, and markdown notes with hybrid persistence (SQLite + filesystem). ## 🚀 Features - **Bookmarks**: Save and organize web links with tags and descriptions - **Snippets**: Store code snippets with syntax highlighting support - **Notes**: Create and manage markdown notes with file-based storage - **Search**: Full-text search across notes - **Health Checks**: Built-in endpoint for monitoring database and storage health - **Persistence**: Hybrid storage (SQLite for metadata, filesystem for note content) ## 📋 Quick Start ### Local Development ```bash # Start the service docker compose up -d # Check health curl http://localhost:8081/health # View logs docker compose logs -f # Stop the service docker compose down ``` ### Production Deployment See [DEPLOYMENT.md](./DEPLOYMENT.md) for complete instructions including: - Traefik reverse proxy configuration - TLS/HTTPS setup - Production environment variables - Monitoring and troubleshooting Production URL: **https://bms.j4bitzs.cloud** ## 🔧 Configuration Environment variables: | Variable | Default | Description | |----------|---------|-------------| | `PORT` | `8080` | HTTP port | | `DATABASE_PATH` | `/data/bms.db` | SQLite database file | | `STORAGE_DIR` | `/data` | Notes storage directory | Copy `.env.example` to `.env` and customize as needed. ## 📊 API Endpoints ### Bookmarks - `POST /bookmarks` - Create bookmark - `GET /bookmarks` - List all bookmarks - `GET /bookmarks/{id}` - Get specific bookmark - `DELETE /bookmarks/{id}` - Delete bookmark ### Snippets - `POST /snippets` - Create snippet - `GET /snippets` - List all snippets - `GET /snippets/{id}` - Get specific snippet - `DELETE /snippets/{id}` - Delete snippet ### Notes - `POST /notes` - Create note - `GET /notes` - List all notes - `GET /notes/{id}` - Get specific note - `DELETE /notes/{id}` - Delete note - `GET /search?q=query` - Search notes ### System - `GET /health` - Health check (verifies DB and storage) ## 🏗️ Architecture - **Language**: Go 1.22 - **Framework**: Gorilla Mux - **Database**: SQLite 3 - **Container**: Multi-stage Docker build (Alpine-based, ~20MB) - **User**: Non-root (UID 1000) ## 📦 Data Persistence All data is stored in the `/data` volume: - `bms.db` - SQLite database (bookmarks, snippets, note metadata) - `notes/` - Markdown files for note content ## ✅ Health Checks The `/health` endpoint verifies: - Database connectivity and ping - Notes directory writability Returns `200 OK` when healthy, `503 Service Unavailable` when degraded. ## 🛠️ Development ```bash # Build locally go build -o bms-service . # Run locally (requires SQLite) PORT=8080 DATABASE_PATH=./bms.db STORAGE_DIR=./data ./bms-service # Build Docker image docker build -t bms-service:latest . ``` ## 📚 Project Structure ``` . ├── main.go # Application entry point ├── db/ │ └── database.go # Database initialization and migrations ├── models/ │ ├── bookmark.go │ ├── snippet.go │ └── note.go ├── handlers/ │ ├── bookmarks.go │ ├── snippets.go │ └── notes.go ├── Dockerfile # Multi-stage build ├── docker-compose.yml # Local development ├── docker-compose.prod.yml # Production with Traefik ├── .env.example # Environment template └── DEPLOYMENT.md # Deployment guide ``` ## 🔐 Security - Runs as non-root user (appuser, UID 1000) - No sensitive data in environment variables - TLS enforced in production (via Traefik) - Health checks don't expose sensitive information ## 📝 License MIT --- **Built for j4bitzs.cloud infrastructure**