{"id":13582288,"url":"https://github.com/gophertuts/reminders-cli","last_synced_at":"2025-04-06T14:30:51.221Z","repository":{"id":54156022,"uuid":"230811482","full_name":"gophertuts/reminders-cli","owner":"gophertuts","description":"Reminders CLI app in Go","archived":false,"fork":false,"pushed_at":"2022-12-11T18:45:47.000Z","size":63676,"stargazers_count":56,"open_issues_count":2,"forks_count":24,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-11-05T22:40:55.754Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gophertuts.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-12-29T22:39:32.000Z","updated_at":"2024-04-23T16:52:20.000Z","dependencies_parsed_at":"2023-01-27T05:00:46.499Z","dependency_job_id":null,"html_url":"https://github.com/gophertuts/reminders-cli","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gophertuts%2Freminders-cli","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gophertuts%2Freminders-cli/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gophertuts%2Freminders-cli/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gophertuts%2Freminders-cli/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gophertuts","download_url":"https://codeload.github.com/gophertuts/reminders-cli/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247495688,"owners_count":20948097,"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","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":[],"created_at":"2024-08-01T15:02:34.502Z","updated_at":"2025-04-06T14:30:51.216Z","avatar_url":"https://github.com/gophertuts.png","language":"Go","readme":"# Reminders CLI app\n\n## Overview\n\nIn this project we'll build a **multi component CLI application**\nwhich consists of mainly 3 parts: a `CLI client`, a `backend API` server\nand a `notifier service`.\n\nThe CLI client will take the input from command line\nand pass it to the backend API through its HTTP client.\n\nThe backend API server is an **HTTP server** which\nhas all the needed endpoints for **CRUD operations** on reminders.\nIt also has 2 background running workers: **background saver**\n\u0026 **background notifier**. Correspondingly saving the in-memory\ndata to the disk and notifying un-completed reminders.\n\nThe backend API server also communicates with the notifier service\nthrough its own HTTP client.\n\nSpeaking of the database layer, we'll be creating our own **file database storage**\nwith some optimized mechanism for this type of application.\n\nTa-dah 🥳 🚀\n\n\u003cimg src=\"https://github.com/gophertuts/reminders-cli/raw/master/cli-demo.gif?sanitize=true\"/\u003e\n\n## Medium article 📖\n\n- [Reminders CLI in Go](https://www.youtube.com/c/GopherTuts)\n\n## YouTube tutorials 🎥\n\n- [Reminders CLI in Go #1 - Project setup \u0026 bare bones](https://youtu.be/-9CbX2MncZg) - [[Download Code]](https://github.com/gophertuts/reminders-cli/raw/master/zips/reminders-cli-1.tar.gz)\n- [Reminders CLI in Go #2 - Notifier Service](https://youtu.be/rlsnqlSjUOc) - [[Download Code]](https://github.com/gophertuts/reminders-cli/raw/master/zips/reminders-cli-2.tar.gz)\n- [Reminders CLI in Go #3 - CLI Basics](https://youtu.be/PbKCvQuAPIQ) - [[Download Code]](https://github.com/gophertuts/reminders-cli/raw/master/zips/reminders-cli-3.tar.gz)\n- [Reminders CLI in Go #4 - Command Switch - Part 1](https://youtu.be/Vz2dBY_hAkw) - [[Download Code]](https://github.com/gophertuts/reminders-cli/raw/master/zips/reminders-cli-4.tar.gz)\n- [Reminders CLI in Go #5 - Command Switch - Part 2](https://youtu.be/Py10z9-61JQ) - [[Download Code]](https://github.com/gophertuts/reminders-cli/raw/master/zips/reminders-cli-5.tar.gz)\n\n\n## Requirements 🤓\n\n- [Go](https://golang.org/doc/install)\n- [Node.js](https://nodejs.org/en/download/)\n\nIn this tutorial we'll be writing a little bit of [Node.js](https://nodejs.org/en/download/)\naka the `Notifier Service` because it's the fastest\ncross platform OS notification system available for us.\n\nWe'll also be using [Yarn](https://yarnpkg.com/lang/en/docs/install/) package manager for this application.\n\nAnd that's all on the JavaScript (Node.js) side.\nThe rest is pure `Go code` also **without** any **third party packages**\nmeaning we'll write absolutely everything from scratch.\n\n## Components 🧩\n\n- **CLI Client**\n- **HTTP client** for communicating with the Backend API\n- **Backend API**\n- **HTTP client** for communicating with the Notifier service\n- **Notifier** service\n- Background **Saver worker**\n- Background **Notifier worker**\n- JSON file **Database** (`db.json`)\n- **Database config** file (`.db.config.json`)\n\n## CLI Client\n\n#### Features\n\n- `create` a reminder\n- `edit` a reminder\n- `fetch` a list of reminders\n- `delete` a list of reminders\n\n***Note:*** Only works if Backend API is up \u0026 running\n\n## Backend API\n\n#### Features\n\n- Does CRUD operations with incoming data from CLI client\n- Runs Background Saver worker, which saves in-memory data\n- Runs Background Notifier worker, which notifies un-completed reminders\n- It can work without the Notifier service, and will keep\nretrying unsent notifications until Notifier service is up\n- On backend API shutdown all the in-memory data is saved\n\n#### Endpoints\n\n- `GET /health`                 - responds with 200 when server is up \u0026 running \n- `POST /reminders/create`      - creates a new reminder and saves it to DB\n- `PUT /reminders/edit`         - updates a reminder and saves it to DB (if duration is updated, notification is resent)\n- `POST /reminders/fetch`       - fetches a list of reminders from DB\n- `DELETE /reminders/delete`    - deletes a list of reminders from DB\n\n## Background Saver\n\n#### Features\n\n- Saves in-memory reminders to the disk (`db.json`)\n- Saves db config to the disk (`.db.config.json`)\n\n## Background Notifier\n\n#### Features\n\n- Pushes un-completed reminders to the Notifier service\n\n## Notifier Service\n\n#### Features\n\n- Sends OS notifications\n\n#### Endpoints\n\n- `GET /health`                 - responds with 200 when server is up \u0026 running\n- `POST /notify`                - sends OS notification and retry response\n\n## File DB\n\n#### Features\n\n- Records are saved inside `db.json` file\n- Has a db config file (`.db.config.json`)\n- Has an auto increment ID generator\n\n## Installation ⚙\n\nBefore running any command or trying to compile the programs\nmake sure you first have all the needed dependencies installed:\n\n- [Golang](https://golang.org/doc/install)\n- [GoLint](https://github.com/golang/lint)\n- [Node.js](https://nodejs.org/en/download/)\n- [Node.js Ubuntu](https://tecadmin.net/install-latest-nodejs-npm-on-ubuntu/)\n- [Yarn](https://yarnpkg.com/lang/en/docs/install/)\n- [GitBash - WINDOWS ONLY](https://git-scm.com/download/win)\n- [Cygwin - WINDOWS ONLY](https://www.cygwin.com/)\n- [Make](https://sourceforge.net/projects/ezwinports/files/make-4.2.1-without-guile-w32-bin.zip/download)\n\n###### Configure `make` (WINDOWS ONLY):\n\n***Note:*** Make sure you have [GitBash](https://git-scm.com/download/win) installed\nbefore proceeding.\n\n1. Download the [Make](https://sourceforge.net/projects/ezwinports/files/make-4.2.1-without-guile-w32-bin.zip/download)\nexecutable\n\n2. Extract the contents form the zip\n\n3. Place the `bin/make.exe` inside `C:\\Program Files\\Git\\mingw64\\bin`\n\n4. If you're using **Goland** update your SHELL\n`Ctrl` + `Alt` + `S` `--\u003e` `Tools` `--\u003e` `Terminal` `--\u003e` `Shell Path` `--\u003e` `\"C:\\Program Files\\Git\\bin\\sh.exe\" --login -i`\n\n5. Restart Goland IDE\n\nFor more info refer to [GitBash - CygWin](https://gist.github.com/evanwill/0207876c3243bbb6863e65ec5dc3f058)\n\n---\n\n## Run 🎮\n\n#### `make` commands\n\n```bash\n# builds client \u0026 server binaries, formats \u0026 lints the code\nmake\n\n# builds the client binary\nmake client\n\n# builds the server binary\nmake server\n\n# formats the entire code base\nmake fmt\n\n# lints the entire code base\nmake lint\n\n# checks the entire code base for code issues\nmake vet\n```\n\n#### `server` flags\n\n```bash\n# display a helpful message of all available flags for the server binary\n./bin/server --help\n\n# runs the backend http server on the specified address\n# --backend flag needs to be provided to ./bin/client if address != :8080\n./bin/server --addr=\":9090\"\n\n# runs the http backend server with a different path to the database\n./bin/server --db=\"/path/to/db.json\"\n\n# runs the http backend server with a different path to the database config\n./bin/server --db-cfg=\"/path/to/.db.config.json\"\n\n# runs the http backend server with a different notifier service url\n./bin/server --notifier=\"http://localhost:8989\"\n```\n\n#### `client` commands \u0026 flags\n\n```bash\n# displays a helpful message about all the commands and flags available\n./bin/client --help\n\n# runs CLI client with a different backend api url\n./bin/client --backend=\"http://localhost:7777\"\n\n# creates a new reminder which will be notified after 3 minutes\n./bin/client create --title=\"Some title\" --message=\"Some msg!\" --duration=3m\n\n# edits the reminder with id: 13\n# note: if the duration is edited, the reminder gets notified again\n./bin/client edit --id=13 --title=\"Another title\" --message=\"Another msg!\"\n\n# fetches a list of reminders with the following ids\n./bin/client fetch --id=1 --id=3 --id=6\n\n# deleted the reminders with the following ids\n./bin/client delete --id=2 --id=4\n```\n\n---\n\n***Note:*** Before using `./bin/client` binary,\nmake sure to have `/bin/server` and `notifier/notifier.js` up \u0026 running\n\n**1st terminal**\n```bash\nnode notfier/notifier.js\n```\n\n**2nd terminal**\n```bash\n./bin/server\n```\n\n**3rd terminal**\n```bash\n./bin/client ...\n```\n\n## Resources 💎\n\n- [Handler](https://golang.org/pkg/net/http/#Handler)\n\n## Feedback 🐧\n\n[SteveHook TypeForm](https://feedback.gophertuts.com)\n\n## Community 💬\n\n[SteveHook Discord](https://discord.gg/tprewQu)\n\n---\n\n**Enjoy** 🚀🚀🚀\n\n\u003cimg src=\"https://github.com/gophertuts/go-basics/raw/master/gophertuts.svg?sanitize=true\" width=\"50px\"/\u003e\n","funding_links":[],"categories":["Go"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgophertuts%2Freminders-cli","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgophertuts%2Freminders-cli","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgophertuts%2Freminders-cli/lists"}