{"id":17026577,"url":"https://github.com/jamiefdhurst/journal","last_synced_at":"2025-03-22T17:31:17.279Z","repository":{"id":57522504,"uuid":"53569218","full_name":"jamiefdhurst/journal","owner":"jamiefdhurst","description":"A simple blog available as an API, written in Go with accompanying tests and documentation. Can be used as a useful starting point for Go web projects.","archived":false,"fork":false,"pushed_at":"2025-01-08T21:14:05.000Z","size":723,"stargazers_count":4,"open_issues_count":15,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-18T13:51:15.837Z","etag":null,"topics":["golang","rest-api","sqlite","unit-testing"],"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/jamiefdhurst.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":"2016-03-10T08:47:37.000Z","updated_at":"2025-01-08T12:55:56.000Z","dependencies_parsed_at":"2022-09-26T18:01:51.473Z","dependency_job_id":"408e6d64-f99e-428a-b161-2c6d280de0d1","html_url":"https://github.com/jamiefdhurst/journal","commit_stats":null,"previous_names":[],"tags_count":42,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jamiefdhurst%2Fjournal","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jamiefdhurst%2Fjournal/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jamiefdhurst%2Fjournal/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jamiefdhurst%2Fjournal/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jamiefdhurst","download_url":"https://codeload.github.com/jamiefdhurst/journal/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244995084,"owners_count":20544284,"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":["golang","rest-api","sqlite","unit-testing"],"created_at":"2024-10-14T07:33:35.966Z","updated_at":"2025-03-22T17:31:16.836Z","avatar_url":"https://github.com/jamiefdhurst.png","language":"Go","readme":"# Journal\n\n![License](https://img.shields.io/github/license/jamiefdhurst/journal.svg)\n[![Build](https://github.com/jamiefdhurst/journal/actions/workflows/build.yml/badge.svg)](https://github.com/jamiefdhurst/journal/actions/workflows/build.yml)\n[![Latest Version](https://img.shields.io/github/release/jamiefdhurst/journal.svg)](https://github.com/jamiefdhurst/journal/releases)\n\nA simple web-based journal written in Go. You can post, edit and view entries,\nwith the addition of an API.\n\nIt makes use of a SQLite database to store the journal entries.\n\n[API Documentation](api/README.md)\n\n## Purpose\n\nJournal serves as an easy-to-read and simple Golang program for new developers \nto try their hand at modifying, extending and playing with. It deliberately has \nonly one dependency to ensure that the full end-to-end flow of the system can \nbe understood through standard Golang libraries.\n\nIt's also a nice little Journal that you can use to keep your thoughts in, or \nas a basic blog platform.\n\n## Installation and Setup (local method)\n\n1. Clone the repository.\n2. Make sure the `$GOPATH/data` directory exists.\n3. Run `go get ./...` to install dependencies\n4. Run `go build journal.go` to create the executable.\n5. Run `./journal` to load the application on port 3000. You should now be able\n    to fully access it at [http://localhost:3000](http://localhost:3000)\n\n## Installation and Setup (Docker method)\n\n_Please note: you will need Docker installed on your local machine._\n\n1. Clone the repository to your chosen folder.\n2. Build the container with `docker build -t journal:latest .`\n3. Run the following to load the application and serve it on port 3000. You\n    should now be able to fully access it at [http://localhost:3000](http://localhost:3000)\n\n    ```bash\n    docker run --rm -v ./data:/go/data -p 3000:3000 -it journal:latest\n    ```\n\n## Environment Variables\n\n* `J_ARTICLES_PER_PAGE` - Articles to display per page, default `20`\n* `J_CREATE` - Set to `0` to disable article creation\n* `J_DB_PATH` - Path to SQLite DB - default is `$GOPATH/data/journal.db`\n* `J_DESCRIPTION` - Set the HTML description of the Journal\n* `J_EDIT` - Set to `0` to disable article modification\n* `J_GA_CODE` - Google Analytics tag value, starts with `UA-`, or ignore to disable Google Analytics\n* `J_GIPHY_API_KEY` - Set to a GIPHY API key to use, or ignore to disable GIPHY\n* `J_PORT` - Port to expose over HTTP, default is `3000`\n* `J_TITLE` - Set the title of the Journal\n\nTo use the API key within your Docker setup, include it as follows:\n\n```bash\ndocker run --rm -e J_GIPHY_API_KEY=... -v ./data:/go/data -p 3000:3000 -it journal:latest\n```\n\n## Layout\n\nThe project layout follows the standard set out in the following document:\n[https://github.com/golang-standards/project-layout](https://github.com/golang-standards/project-layout)\n\n* `/api` - API documentation\n* `/internal/app/controller` - Controllers for the main application\n* `/internal/app/model` - Models for the main application\n* `/internal/app/router` - Implementation of router for given app\n* `/pkg/adapter` - Adapters for connecting to external services\n* `/pkg/controller` - Controller logic\n* `/pkg/database` - Database connection logic\n* `/pkg/router` - Router for handling services\n* `/test` - API tests\n* `/test/data` - Test data\n* `/test/mocks` - Mock files for testing\n* `/web/app` - CSS/JS source files\n* `/web/static` - Compiled static public assets\n* `/web/templates` - View templates\n\n## Development\n\n### Back-end\n\nThe back-end can be extended and modified following the folder structure above. \nTests for each file live alongside and are designed to be easy to read and as \nfunctionally complete as possible.\n\nThe easiest way to develop incrementally is to use a local go installation and \nrun your Journal as follows:\n\n```bash\ngo run journal.go\n```\n\nNaturally, any changes to the logic or functionality will require a restart of \nthe binary itself.\n\n#### Dependencies\n\nThe application currently only has one dependency:\n\n* [github.com/mattn/go-sqlite3](https://github.com/mattn/go-sqlite3)\n\nThis can be installed using the following commands from the journal folder:\n\n```bash\ngo get -v ./...\ngo install -v ./...\n```\n\n#### Templates\n\nThe templates are in `html/template` format in _web/templates_ and are used \nwithin each of the controllers. These can be modified while the binary stays \nloaded, as they are loaded on the fly by the application as it runs and serves \ncontent.\n\n### Front-end\n\nThe front-end source files are in _web/app_ and require some tooling and \ndependencies to be installed via `npm` such as gulp and webpack. You can then \nuse the following build targets:\n\n* `gulp sass` - Compiles the SASS source into CSS\n* `gulp webpack` - Uglifies and minifies the JS\n* `gulp` - Watches for changes in SASS/JS files and immediately compiles\n\n### Building/Testing\n\nAll pushed code is currently built using GitHub Actions to test PRs, build \npackages and create releases.\n\nTo test locally, simply use:\n\n```bash\ngo test -v ./...\n```\n\n### Building for Lambda\n\nThe application is designed to run as a Lambda connected to an EFS for SQLite \nstorage. This requires a different method of building to ensure it includes the \nappropriate libraries and is built for the correct architecture.\n\nTo build for Lambda, you will need the x86_64-unknown-linux-gnu cross compiler\n(if you're on a Mac):\n\n```bash\nbrew tap SergioBenitez/osxct\nbrew install x86_64-unknown-linux-gnu\n```\n\nTo build, simply run:\n\n```bash\nmake build\n```\n\nThis will produce a Lambda output: `lambda.zip`, that you can upload onto an \nAmazon Linux 2023 (al2023) runtime Lambda, if you configure the appropriate \nenvironment variables.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjamiefdhurst%2Fjournal","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjamiefdhurst%2Fjournal","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjamiefdhurst%2Fjournal/lists"}