GoBlog is a website with blog support written in Go, GoBlog retrieves its content from Notion using it as a CMS, Under the hood GoBlog uses templ and Tailwind CSS to build the pages' HTML which is then managed by the application as a Webserver to provide updated content or Static Site Generator.
You can implement a Provider yourself or have a database in Notion to use the NotionProvider that provides the data GoBlog expects, follow these steps:
- Use this page as a template for your database
- Add a Notion Integration that has access to the database
- Set environment variables NOTION_API_KEY to the integration secret and NOTION_ARTICLE_DATABASE_ID to the database you created
- Install the dependencies with
make install-dependencies
- Start the web server with
make start
, there is a dev version available withmake dev
that uses air
GoBlog uses a couple of components, these components are represented as Go Packages and Types. This is an overview of the project's architecture represented as a UML Diagram:
As you can tell, components have their responsibilities and are de-coupled from one another, this gives us the ability to scale, update, and replace the components when needed without technical overhead.
website is the entry point for GoBlog, it compiles to a binary that can be executed in two paths:
- A Go Webserver that serves the website
- A Static Site Generator that builds every page and saves the resulting HTML in the specified path
website is dependent on app for its functionality.
app is a type defined in website package, app has three methods used by website to either build a Static Site or serve a web server:
- updateStore: this method tries to retrieve all pages from Provider, build the pages, and update Store with this fresh data, updateStore is dependent on another package(pages) that knows how to fetch and build different pages using Provider and it's own Page implementation.
- startWebServer: starts the web server serving website pages, this method creates an HTTP server and lets frontend.Routes() to register different routes.
- startSSG: updates store once and then starts the static site generation with frontend.SSG()
Frontend is what does the actual work of the webserver and SSG is a provider of data stored in Store, note that Store is updated in website and Frontend does not write to Store has two public methods:
- Routes: Registers all the page routes to an HTTP server
- SSG: Properly copies pages from store and Assets to the target SSG path
Store is any object that can store, load, and delete a page, store is kept updated by app in webserver mode, and the update function uses a concurrent approach to retrieve page data, build and update the store for faster updates
Store is initially implemented by Repository, Repository uses a BadgerDB under the hood for data persistance
Provider is any object that can provide the articles and their content from its source, along with special page data, it's used to update Store.
NotionProvider implements Provider giving access to a Notion Database containing articles as its source, the article's content is transformed to HTML by this object and provided to update Store.