DEV Community

Cover image for How I built my open-source Social media scheduling tool... 🤯

How I built my open-source Social media scheduling tool... 🤯

Nevo David on September 03, 2024

I published Postiz, my open-source social media scheduling tool, on Reddit, and received much attention. I guess it was super needed in open-sourc...
Collapse
 
dhruvwill profile image
Dhruvil S Shah

Awesome!
just a small ques, why did you use redis for executing the schedules posts? can I use "cron" for the same ?

Collapse
 
nevodavid profile image
Nevo David

You can run a cron every second to check if something will be posted.
But it feels a bit overkill for me :)

Collapse
 
joaozitopolo profile image
Joao Polo

cron requires extra validation and control of items to be posted. Also, Redis preserves the schedule list and have retry options.
If your service (with cron) loose some event due a shutdown, you'll require an extra effort to detect these loosed events. Also, you'll need an extra effort to retry it.

Collapse
 
nevodavid profile image
Nevo David

Not exactly; you can save it in the DB, for example, and post it on Facebook at 5 pm.
Now you can run a cron every second, check what needs to be scheduled after 5 pm, and don't fail. You will need to lock the job everything, so you want to post it twice (that can be a bit dangerous).

Instead of a cron you might want to run a while(true) event.

Thread Thread
 
dhruvwill profile image
Dhruvil S Shah

I came across this package called "node-schedule" which is similar to schedule in python. I think it fits better to the usecase.
ex.
`const schedule = require('node-schedule');
const { TwitterApi } = require('twitter-api-v2');

// Initialize your Twitter client
const client = new TwitterApi({
appKey: 'YOUR_APP_KEY',
appSecret: 'YOUR_APP_SECRET',
accessToken: 'YOUR_ACCESS_TOKEN',
accessSecret: 'YOUR_ACCESS_SECRET',
});

// Function to post to Twitter
async function postToTwitter(content) {
try {
await client.v2.tweet(content);
console.log('Posted to Twitter successfully');
} catch (error) {
console.error('Error posting to Twitter:', error);
}
}

// Schedule a post
function schedulePost(date, content) {
schedule.scheduleJob(date, function() {
postToTwitter(content);
});
}

// Example usage
const futureDate = new Date(2024, 8, 15, 12, 0, 0); // September 15, 2024, at 12:00:00 PM
schedulePost(futureDate, 'This is a scheduled tweet for a specific date and time!');`

Thread Thread
 
nevodavid profile image
Nevo David

It's a fake scheduler that checks every second on javascript intervals.
It can work, but it's not saving and state, it means that if you close the app and open it again, you will lose all the information.

Thread Thread
 
dhruvwill profile image
Dhruvil S Shah

There must exist a good "real" scheduler for node.
someone suggested "agenda" which syncs with MongoDB

Thread Thread
 
nevodavid profile image
Nevo David

BullMQ with Redis :)

Collapse
 
cmacu profile image
Stasi Vladimirov

Great article, thanks. Some important aspects to make this a real platform include:

  • encryption for securely storing the authO tokens and other sensitive details
  • multi-tenancy. How do you keep data for each account independent from the rest of the accounts? -ability to scale on per tenant based (some tenants post once a month others post 1000 times a day)
  • user roles, permissions and authorization or who can do what in the app
  • integrations with other third parties such as marketing platforms, search engines, content management systems, CRM and ERP applications
  • customizations: the ability to define custom fields, handles, tags, lists, etc and create templates using them
  • templating engine: ability to create templates and adapt them to the various platforms and syntax requirements
  • asset management for image, video and other content
  • AI tools and integrations for suggestions and insights
  • reporting including trends, real time and various filtering

Keep up the good work and you can make this really good.

Collapse
 
oggo profile image
oggo

Very good points!

Collapse
 
nevodavid profile image
Nevo David

Thank you!!

Collapse
 
nevodavid profile image
Nevo David

Awesome, many stuff!
As a single developer, I will need some time.
But I see some really good ones!

Collapse
 
or_bendahan_38b85f8f334a profile image
Or Ben Dahan

Great article and very nice idea 👏
A small scheduler suggestion - for a stateless and scheduled jobs Im using Cloudwatch events that triggers a lambda function. (another option is to use SQS fifo queues between them to achieve atomic operations - not sure if needed in your case at this point but it's an option)

Collapse
 
nevodavid profile image
Nevo David

Yeah, those are more complex infrastructures.
You can also use RabbitMQ or Kafka if you have big streams.
I don't think it's necessary for social media scheduling tools :)

Collapse
 
nathandaly profile image
Nathan Daly

I love love the idea <3

Collapse
 
nevodavid profile image
Nevo David

Thank you!

Collapse
 
ashutosh_dev profile image
Ashutosh_dev

Image description
Responsiveness at its peak !

Collapse
 
nevodavid profile image
Nevo David

Haha!
Wanna help me fix it? :)

Collapse
 
jeffchavez_dev profile image
Jeff Chavez

Nice. I've been dreaming of this kind of project. Thanks for your effort in sharing this.

Collapse
 
nevodavid profile image
Nevo David

Thank you! :)
Happy Hacking

Collapse
 
yutamago profile image
Yutamago

The main thing to be careful about when using SQL is deadlocks. You don't want to update a row from multiple places simultaneously, as this will throw a deadlock, and the update will fail.

This statement is telling me you don't know much about SQL deadlocks yet.
Try reading more about it and how to avoid them. We're operating a massively huge SQL database and update the same rows in dozens of places simultaneously without seeing a single failed update, so it's at least possible.

Collapse
 
lxm7 profile image
Alex

"Try reading more about it and how to avoid them" - surely this is exactly what he has been doing looking at the post.
"We're operating a massively huge SQL database and update the same rows in dozens of places simultaneously without seeing a single failed update" - this statement isnt telling me much either

Collapse
 
nevodavid profile image
Nevo David

I didn't say it's impossible, but you must be careful with it.
If you don't use workers or your update takes too much time you will get a deadlock.

Collapse
 
st3adyp1ck profile image
Ilya Belous

This is an impressive project! 🎉 It's clear a lot of thought went into building Postiz, and I love how you've shared the technical breakdown so transparently. The approach you took with OAuth2 for handling social media integrations and how you've simplified the provider interface is brilliant! It makes adding new platforms seem much more manageable.

Using Redis for queue management is also a smart move—especially since you don't need a heavyweight solution like RabbitMQ or Kafka. BullMQ is a fantastic choice to complement Redis, and the horizontal scaling with workers makes perfect sense for a tool like this that has the potential to handle many jobs.

I'm also a big fan of Prisma! It really streamlines database interactions, and the flexibility it offers for future DB migrations is a huge plus. Postgres is rock solid, and it's great to hear you're having a smooth experience with it.

Congratulations on all the attention you're getting with Postiz! You've definitely hit a sweet spot in the open-source space. Looking forward to trying it out and contributing a star ⭐ Keep up the great work!

Collapse
 
nevodavid profile image
Nevo David

Thank you 🙏🏻

Collapse
 
stefanak-michal profile image
Michal Štefaňák

It is wrong this kind of tool has bussiness potential these days. I'm dissappointed. Anyway nicely done project.

Collapse
 
nevodavid profile image
Nevo David

What do you mean?

Collapse
 
stefanak-michal profile image
Michal Štefaňák

I'm not fan of how social media works. I don't even have meta or X account. A lot of people share a lot of useless stuff. This kind of tool simplify it, which leads to encouraging this behaviour. If you have nothing meaningful to share then don't share.

Thread Thread
 
nevodavid profile image
Nevo David

Cool!
But I think there is still good stuff on social media you just need to follow the right people :)

Thread Thread
 
chetak123 profile image
Ayushman

Really liked how you handled the above comment 👏

Thread Thread
 
nevodavid profile image
Nevo David

👏

Collapse
 
shricodev profile image
Shrijal Acharya

Love this project, @nevodavid. 💪
I recently built a similar tool in the CLI for automating Instagram posts. If you'd like to take a look: github.com/shricodev/insta-cron-po...

Collapse
 
nevodavid profile image
Nevo David

Nice Project!

Collapse
 
the_greatbonnie profile image
Bonnie

I would love to give Postiz a try.

Collapse
 
nevodavid profile image
Nevo David

Awesome!
Let me know how it goes!

Collapse
 
medic_qr_03ae0a9e422b702d profile image
Medic QR

Can I schedule LinkedIn posts with Postiz?

Collapse
 
nevodavid profile image
Nevo David

Of course :)

Collapse
 
medic_qr_03ae0a9e422b702d profile image
Medic QR

Just saw the ui. Amazing work man.
Gonna study the code.

Thread Thread
 
nevodavid profile image
Nevo David

❤️

Collapse
 
crazytonyi profile image
Anthony

Does it support icalendar/caldav? I'm intrigued

Collapse
 
nevodavid profile image
Nevo David

Not sure what are those :)

Collapse
 
crazytonyi profile image
Anthony

It is the protocol for calendar sharing, allowing for things like subscribing to a third party calendar from your Google calendar.
en.wikipedia.org/wiki/ICalendar

Thread Thread
 
nevodavid profile image
Nevo David

So you want to time your social media posts directly from your Google calendar?

Collapse
 
oggo profile image
oggo

Awesome!

Collapse
 
nevodavid profile image
Nevo David

🙏🏻

Collapse
 
depapp profile image
depa panjie purnama

hey, thanks for sharing open-source tool.
anyway i've built web that can summarize your open-source contributions,
here's the full article: dev.to/depapp/showcase-your-open-s...

Collapse
 
nevodavid profile image
Nevo David

❤️

Collapse
 
kin7777 profile image
kince marando

Awesome thanks

Collapse
 
nevodavid profile image
Nevo David

🙏🏻

Collapse
 
lico profile image
SeongKuk Han

Awesome, open source?? Wow. I hope your business grow up quickly.
Giving an opportunity to see a production-level code with the public is absolutely admirable. Respect, good luck!

Collapse
 
nevodavid profile image
Nevo David

Thank you so much ❤️

Collapse
 
mendozalz profile image
Lenin Mendoza

MI estrella en github esta asegurada. Tremendo, te felicito!

Collapse
 
guilleare profile image
Guillermo A

What did you use to generate the documentation for the application? docs.postiz.com/quickstart

Collapse
 
nevodavid profile image
Nevo David

It mintlify

Collapse
 
engrsakib profile image
Md Nazmus Sakib

great

Collapse
 
sunilkumrdash profile image
Sunil Kumar Dash

Great read! Wishing Postiz much more success ahead.

Collapse
 
nevodavid profile image
Nevo David

Thank you so much Sunil!

Collapse
 
martinbaun profile image
Martin Baun

Great read! Looking forward to more updates :)

Collapse
 
nevodavid profile image
Nevo David

❤️🙏🏻

Collapse
 
dev_mode profile image
Sanad

Looks amazing and useful! Keep up the great work.

Collapse
 
nevodavid profile image
Nevo David

Thank you so much!
And also for using it 🙏🏻

Collapse
 
johnwings21 profile image
johnwings21

Thank you for sharing your journey!
This is pretty impressive.

Collapse
 
nevodavid profile image
Nevo David

Thank you so much 😊

Collapse
 
mohammed_kareem profile image
Mohammad Kareem

the UI is honestly stunning i'm still in shock how pretty it looks
I'm very happy for you man

Collapse
 
nevodavid profile image
Nevo David

Thank you 🙏🏻

Collapse
 
uliyahoo profile image
uliyahoo

Awesome!

Collapse
 
nevodavid profile image
Nevo David

Thank you 🙏🏻

Collapse
 
william4411 profile image
william4411

It's my first time seeing an open-source social media scheduling tool.
Nice initiative.

Thank you!

Collapse
 
nevodavid profile image
Nevo David

Thank you! would you use it? :)

Collapse
 
brokarim profile image
Bro Karim

Checked out the repo and tech stack, really cool! Super interested in diving deeper

Collapse
 
nevodavid profile image
Nevo David

🚀

Collapse
 
moly_roy_bd82e0119954d72b profile image
Moly Roy

The range of games is impressive. Whether you enjoy spinning the reels or testing your skills in fish games, Cash Frenzy 777 provides plenty of options to choose from. The app is designed to be easy to navigate, which makes it simple to switch between games or explore new ones. You can also use the app without downloading online play and enjoy.

Collapse
 
nevodavid profile image
Nevo David

Spam.

Collapse
 
fazlay profile image
Fazlay Rabbi

Great post, David! I really appreciate how detailed and transparent you were in breaking down your process for building the social media scheduling tool. The decision to go with Node.js for the backend and Next.js for the frontend is smart, especially with the focus on performance and scalability. I’m curious how you handled third-party API rate limiting for social media platforms—was it tricky to manage across different services? Also, any plans to add more automation features to the tool in the future? Looking forward to seeing how this project evolves!

Collapse
 
abby_ng_8d7228a908dbe1128 profile image
Abby Ng

I was scammed by a Bitcoin investment online website in may. I lost about $650,000 to them and they denied all my withdrawal request, and gave me all sort of filthy request. It was a really hard time for me because that was all I had and they tricked me into investing the money with a guarantee that I will make profit from the investment. They took all my money and I did not hear from them anymore. I was able to recover all the money I lost just last month with the help of Proasset recovery. I paid 10% of the recovered funds as his service charge after I got all my money back. I am really grateful to him because I know a lot of people here have been scammed and need help. Contact him via; hackerrone90 at gmail com

Collapse
 
andrewbaisden profile image
Andrew Baisden

It's impressive to see and really motivating for everyone who has side projects that they want to monetize, I think.

Collapse
 
chandra_pantachhetri profile image
Chandra Panta Chhetri

I never heard of a social media scheduling tool. But thankfully it's open source so I'll be sure to check out the source :)