zazaian

zazaian

Critique my approach to building a blogging engine

Hey all,

So I’ve decided to build a little blogging platform to integrate into an existing Phoenix application that I’ve built. For now the Phoenix app is just a little web server serving a single page app with react and a postgres database on the backend to collect some contact information from users. Not much to it.

To drive traffic to the site I want to add some blog functionality at the Site Unavailable endpoint. Originally I was going to use something like Ghost to save time, but decided to get more hands on. Of the existing Elixir blogging solutions my favorite is Nabo, but after digging through the source code I’ve decided to roll my own and open source the solution.

Ultimately my goal is to be able to iterate this code over several sites that I’m building, all of which will have some kind of content/blogging component. Some of these might be entirely focused on serving written content. These will likely all be Elixir apps that depend on Phoenix for web service in some way.

My options as I see them are:

  • Write a non-OTP blogging kernel library that has modules for fundamental interactions for Article, Category, Tag, Comment, etc, and all the good stuff that could then be included/imported/used inside of any elixir/Phoenix platform. I guess it would have to make some presumptions about what the corresponding repository tables would look like, probably including some generators or something of the like. However the goal would be to abstract all of the common business logic surrounding writing blogs that’s a pain in the ass to write over and over again.

  • Write a library as an OTP application that does fundamentally the same thing, but that is intended from the outset to be an OTP application could then just be hooked into any existing Elixir/OTP application. I guess this would behave more as a standalone solution, and could probably just even be dependent on Phoenix. It seems like this would probably be less flexible than writing a set of tools that are fundamentally independent of how/where they’re being implemented, but would probably be easier than integrating them into an independent Phoenix app every time I want to deploy a new blog, which is probably what I’d end up doing.

This may all be a bit fuzzy as I’m presenting it from 10,000 ft, and I understand a lot of this is a matter of taste, but I thought it might be useful to solicit some opinions here before I commit to one approach or another. Hopefully this is something that will become useful to the community at large, so it seemed to make sense to open this question up to the community from the outset.

Do either of these seem more useful/accessible to you? Is there anything in particular you’d like to see come out of the Elixir community in terms of libraries to support publishing content?

Thanks in advance for any feedback.

~ Mike Zazaian

Most Liked

OvermindDL1

OvermindDL1

Correct.

When something is configurable like that with potential to be used multiple times, it’s always best to make it an OTP library that can be integrated into another OTP Application. You can of course have it have an OTP Application as well that is default enabled/disabled too if you want, but configurability is important. :slight_smile:

As an example, my TaskAfter library does this, you can see the docs how you can set it up for a global or local installation (or both) just by defining a config entry or not. If global then it has it’s own application that starts everything up, if global is disabled then it just doesn’t start anything. It’s pretty simple code if you want to look at it. :slight_smile:

OvermindDL1

OvermindDL1

I’d for for it being an OTP library rather than an OTP application, this way someone could potentially even spool up multiple ones with different settings if they so wish. :slight_smile:

Plus integrating it in someone’s existing setup would just be a single-liner in their parent supervisor anyway. ^.^

zazaian

zazaian

@OvermindDL1 as always you are a force to be reckoned with. When you say OTP library, do you just mean a library leaning on Genserver to manage state internally, and providing its own parent supervisor for spooling up? Is the distinction here that the application wouldn’t have to be started by the OTP application controller, but could just be integrated into any supervisor tree?

Thanks a ton for your feedback here. As always it’s highly valued.

Where Next?

Popular in Discussions Top

pillaiindu
In django there is a cache framework backed by memcached. Rails also puts a lot of emphasis on caching, and even the idea of russian-doll...
New
arpan
Hello everyone :wave: Today I am very excited to announce a project that I have been working on for almost 3 months now. The project is...
New
AlexMcConnell
The reason that Rails is as popular as it is is because it’s very easy for relatively inexperienced developers to get a lot of work done....
588 19652 166
New
CharlesO
Erlang :list.nth simple, but 1 - based nth(1, [H|_]) -> H; nth(N, [_|T]) when N > 1 -> nth(N - 1, T). Elixir Enum.at … coo...
New
saif
Hello everyone, Long time lurker first time poster here. I’ve recently begun working on Elixir full-time again! :raised_hands: It’s been...
New
chulkilee
Here are the list of HTTP client libraries/wrappers, and some thoughts on HTTP client in general. I’d like to hear from others how they w...
New
dogweather
I wrote this comment on r/haskell, and it’s not popular there. :wink: But I think I’m on to something… Haskell reminds me of Java, and e...
New
sashaafm
Piggy backing a bit on @dvcrn topic BEAM optimization for functions with static return type?, I’ve been trying to understand in a deeper ...
New
Qqwy
Looking at the stacks that existing large companies have used, WhatsApp internally uses Mnesia to store the messages, while Discord uses ...
New
sergio
Kind of like when jquery came out, it was super necessary. Existing drag and drop libraries have a bunch of baggage to support old browse...
New

Other popular topics Top

TunkShif
This post is an instruction guide to help you setup your Neovim for Elixir development from scratch. It includes general information on h...
274 41989 114
New
lessless
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
New
gshaw
What is the idiomatic way of matching for not nil in Elixir? E.g., First way: defp halt_if_not_signed_in(conn, signed_in_account) when...
New
Patoshizzle
After calling mix ecto.create I get this error: 17:00:32.162 [error] GenServer #PID<0.412.0> terminating ** (Postgrex.Error) FATAL...
New
AngeloChecked
What learn first? Rust or Elixir Hi Elixir community! I’m here because i want learn a new language. I’m a junior developer and mainly i ...
New
gausby
I asked this very same question on twitter and got some interesting feedback, but I thought it would be a good question to ask here as we...
1207 39467 209
New
sergio_101
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
Brian
What is the proper way to load a module from a file in to IEX? In the python world, doing something like this pretty standard: from ....
New
AstonJ
Seen any cool LiveView demos, sample apps or examples? Please post them here! :003:
New

Latest on Elixir Forum

We're in Beta

About us Mission Statement