{"id":15322057,"url":"https://github.com/nccapo/go-notification","last_synced_at":"2025-10-09T08:32:15.895Z","repository":{"id":247407226,"uuid":"825748057","full_name":"nccapo/go-notification","owner":"nccapo","description":"Notification MicroService based on Go, NATS and WebSocket, application is Development mode","archived":true,"fork":false,"pushed_at":"2024-08-24T19:52:05.000Z","size":99,"stargazers_count":15,"open_issues_count":0,"forks_count":3,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-02-27T09:31:02.793Z","etag":null,"topics":["go","golang","microservice","microservices","nats","sql","sqlite","websocket"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nccapo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-07-08T12:20:43.000Z","updated_at":"2025-02-14T19:49:58.000Z","dependencies_parsed_at":"2024-07-08T16:22:37.265Z","dependency_job_id":"958155e1-a233-4d5e-98c1-6345fd48861f","html_url":"https://github.com/nccapo/go-notification","commit_stats":null,"previous_names":["nicolas-ggd/go-notification","nccapo/go-notification"],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/nccapo/go-notification","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nccapo%2Fgo-notification","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nccapo%2Fgo-notification/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nccapo%2Fgo-notification/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nccapo%2Fgo-notification/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nccapo","download_url":"https://codeload.github.com/nccapo/go-notification/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nccapo%2Fgo-notification/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279001052,"owners_count":26082991,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-09T02:00:07.460Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["go","golang","microservice","microservices","nats","sql","sqlite","websocket"],"created_at":"2024-10-01T09:14:02.142Z","updated_at":"2025-10-09T08:32:15.613Z","avatar_url":"https://github.com/nccapo.png","language":"Go","readme":"# REPOSITORY IS NO LONGER ACTIVE\n## Notification Microservice\nThis microservice is designed to handle system notifications using Go, NATS, and WebSocket. Clients can connect via WebSocket and receive notifications either for all users or for specific clients.\n\ngo-notification is a microservice designed to handle system notifications, making sure your users receive important alerts efficiently. With features like WebSocket connectivity, priority-based message handling, and easy integration with NATS, this service is perfect for apps that need robust notification handling.\n\n## Features\n- WebSocket Connectivity: It lets clients access the service over WebSocket.\n- Broadcast Notifications: Messages are sent to all connected clients.\n- Targeted Notifications: Messages are sent to specific clients.\n- Priority Notifications: Notifications have different types and priorities (error, warning, info).\n- Easy Configuration: Command-line arguments can be used to configure the application.\n\n## Installation\n1. Clone repository:\n\n   ```bash\n     git clone https://github.com/Nicolas-ggd/go-notification.git\n   ```\n\n2. Navigate to the project directory:\n   ```bash\n     cd go-notifications\n   ```\n   \n3. Install dependencies:\n\n   ```bash\n     go mod download\n   ```\n   \n4. Install NATS (if not already installed):\n\n   NATS is a lightweight, high-performance messaging system. You can install NATS using the following methods:\n\n   - Homebrew (macOS):\n   ```bash\n     brew install nats-server\n   ```\n   - Docker run:\n\n   ```bash\n    docker run -d --name nats-server -p 4222:4222 nats\n   ```\n   \n   Or see full [NATS installation documentation](https://nats.io/download/)\n\n## Configuration\nConfigure the service using command-line arguments:\n- nats-url: The URL of the NATS server (default: nats://nats:4222).\n- http-server-port: The port for the HTTP server (default: 8741).\n\nExample:\n```bash\n  go run ./cmd/gonotification http-server-port=5432 nats-url=nats://127.0.0.1:4222\n```\n\n## Usage\nStart the service with the following command:\n```bash\n  go run ./cmd/gonotification http-server-port=5432 nats-url=nats://127.0.0.1:4222\n```\n\nBefore starting, you can run all tests:\n```bash\n  make test\n```\n## Environment Variables\nThis application uses `.env` file for Github Actions, so you need to configure environment variables, follow these steps:\n\n1. Copy the .env.example file to .env and fill in your environment variables:\n\n   ```shell\n   cp .env.example .env\n   nano .env\n   ```\n\nCheck `.env.example` file to known which environment variable you need to deploy applicaiton\n\n2. After creating environment file, load the environment variables:\n\n   ```shell\n   ./load_env.sh\n   ```\n   \n## Sending Notifications\n\n1. Command line notification request using NATS:\n   Send a message to all connected clients\n\n   ```shell\n   nats req NOTIFICATION.send-to-all '{\"type\": \"error\", \"message\": \"example\", \"time\": \"2024-04-17T09:00:00Z\"}'\n   ```\n\n   Send a message to specific clients\n\n   ```shell\n   nats req NOTIFICATION.send-to-clients '{\"type\": \"warning\", \"message\": \"example\", \"time\": \"2024-04-17T09:00:00Z\", \"clients\": [\"1\", \"2\"]}'\n   ```\n   \n2. Broadcast Notification:\n   Send a message to all connected clients.\n\n   ```json\n   {\n     \"type\": \"error\",\n     \"message\": \"This is a broadcast go-notification.\",\n     \"time\": \"2024-04-17T09:00:00Z\"\n   }\n   ```\n   \n   #### Response JSON should be like:\n   ```json\n    {\n      \"id\": 1,\n      \"type\": \"error\",\n      \"message\": \"This is a broadcast go-notification.\",\n      \"time\": \"2024-04-17T09:00:00Z\"\n    }\n   ```\n\n3. Targeted Notification:\n   Send a message to specific clients.\n\n   ```json\n   {\n     \"type\": \"warning\",\n     \"clients\": [\"1\", \"2\"],\n     \"message\": \"This is a targeted go-notification.\",\n     \"time\": \"2024-04-17T09:00:00Z\"\n   }\n   ```\n\n   #### Response JSON should be like:\n      ```json\n       {\n         \"id\": 1,\n         \"type\": \"warning\",\n         \"message\": \"This is a broadcast go-notification.\",\n         \"time\": \"2024-04-17T09:00:00Z\"\n       }\n      ```\n\n## Notification Types and Priorities\nThere are three types of system notifications, each with a different priority level:\n- Error: Highest priority. These notifications are sent first.\n- Warning: Medium priority. These notifications are sent after error notifications.\n- Info: Lowest priority. These notifications are sent last.\n\nIf there is a list of notification that are received simultaneously, the client will receive this list in the following order as [described](#notification-types-and-priorities)\n\nThis illustration shows Notification list before and after sorting according to priority types:\n\u003cimg width=\"971\" alt=\"Screenshot 2024-07-15 at 12 27 46\" src=\"https://github.com/user-attachments/assets/ecc4947b-9b78-4e07-91b5-2273090a8a16\"\u003e\n\n- Notification whose type is error is evaluated with priority 1\n- Notification of warning type is evaluated with priority 2\n- Notification of info type is evaluated with priority 3\n\n**Note**: that ordering and sending notifications by priority only works when you send multiple notifications in the application at the same time.\n\n## Example Client\nHere's a simple example of a client connecting to the WebSocket server and handling messages:\n\n**NOTE**: Client side isn't stable yet, application is during the development\n```javascript\nconst socket = new WebSocket('ws://localhost:8080/ws');\n\nsocket.onopen = function(event) {\n  console.log('Connected to WebSocket server.');\n};\n\nsocket.onmessage = function(event) {\n  const message = JSON.parse(event.data);\n  console.log('Received:', message);\n};\n\nsocket.onclose = function(event) {\n  console.log('Disconnected from WebSocket server.');\n};\n\nsocket.onerror = function(error) {\n  console.error('WebSocket Error:', error);\n};\n```\n\n## Contributing\nContributions are welcome! Please open an issue or submit a pull request for any improvements or bug fixes.\n\n## License\nThis project is licensed under the MIT License.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnccapo%2Fgo-notification","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnccapo%2Fgo-notification","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnccapo%2Fgo-notification/lists"}