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

Nevo David @nevodavid

About: Founder of Postiz, an open-source social media scheduling tool. Running Gitroom, the best place to learn how to grow open-source tools.

Joined:
Feb 23, 2022

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

Publish Date: Sep 3 '24
553 87

I published Postiz, my open-source social media scheduling tool, on Reddit, and received much attention.

I guess it was super needed in open-source.
I have received multiple questions from developers on how I built it.

So today, I will take you through the infrastructure and things you need to consider.

Social Media


It all starts with oAuth (oAuth2)

The core of every social media scheduling tool is oAuth. Let me explain.

oAuth is a standard way for different platforms to give you access to their users to perform a limited-scope action.

For example, you can ask Facebook to give you access to post on a user timeline or read their analytics.

oAuth is limited by time but can be refreshed, and the core of every scheduling tool is:

  1. Collect oAuths of different platforms.
  2. Refresh them when needed.
  3. Use them to post on a user timeline.

Since you want to build a generic platform that you can easily add more and more social platforms, you want to build an interface like this (simplified version):



export interface Provider {
  generateAuthUrl(): Promise<GenerateAuthUrlResponse>;
  authenticate(params: {code: string; codeVerifier: string; refresh?: string;}): Promise<AuthTokenDetails>;
  refreshToken(refreshToken: string): Promise<AuthTokenDetails>;
post(token: string, info: MessageInformation): Promise<PostDetails>;
}


Enter fullscreen mode Exit fullscreen mode

generateAuthUrl — This function generates a URL for the user to authenticate on a platform (like LinkedIn). It gives you a code you can later convert to a token to post on a user's timeline.

authenticate - Takes the code of the user, converts it to a token, and creates the user in the database (and saves their token along with the token expiry date)

refreshToken - Takes the user token and expiry date and refreshes it if needed.

post— This function takes the user token and message details and posts them to the user's timeline (it can be a picture, text, video, etc.).

Once you have that, you must catch a user's POST request in an authentication request, map it to the right provider that implements IAuthenticator, and return the generateAuthUrl.

The generateAuthUrl gets a "return URL," which the user will return once they have completed authentication. In that URL, you use the authenticate function.


Scheduling the posting

Platforms mostly will not give you a way to schedule their posts with an API.

Even if they did, it would be hard to manage some who do and some who don't, so it's better to view it as a platform for those who don't.

To do this, you need to implement a queue.

Example: Post to Facebook: "I love Postiz" and process it in 1 week from now.

You have many options for queues.
Some of the most popular are RabbitMQ, SQS, and ActiveMQ

They are perfect when you have tons of jobs, and if you have streaming Petabytes of data, Kafka can probably help.

But in my case, I don't need a "real" queue.

So, I used Redis (Pub-sub). You push some key inside of Redis and add an expiry date. Once the expiry date passes, it triggers Redis and sends a notification (to some service)

There is a great company called BullMQ that simplifies the process with Redis and your app (it's free and fully open-sourced)

Archtecture

Below are "Workers". They are microservices of your application that process and post the "job" on social media.

They are separated because they are smaller than the main application and might need to be scaled depending on your number of jobs.

We call this "Horizontal scaling," as we will need to add more workers as our application grows.


The DB

Usually, you would need to save a post in the DB with multiple statuses—DRAFT, SCHEDULED, COMPLETED, and ERROR—so you can track what happened to it.

In my case, I used Prisma.
Prisma is an ORM that wraps and queries your database using terms like One-to-one, Many-to-many, and one-to-many.

It's a known approach that exists for you in all the languages.
I like it because it keeps a consistent response structure and allows me to change to a different DB in the future (easy migration). I don't have even one raw query in my project (good or bad)

I am using PostgreSQL because it's trending now (according to a StackOverflow survey)

StackOverflow survey

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.


Help me out

Postiz is trending on GitHub. It's 100% free, and I will try to give you value as much as possible.

Already crafted a small roadmap from all the requests.

I was hoping you could help me with a star that will help me (well, I can't even describe how much)

Star Postiz

Comments 87 total

  • Bonnie
    BonnieSep 3, 2024

    I would love to give Postiz a try.

    • Nevo David
      Nevo DavidSep 3, 2024

      Awesome!
      Let me know how it goes!

  • Sunil Kumar Dash
    Sunil Kumar DashSep 3, 2024

    Great read! Wishing Postiz much more success ahead.

  • johnwings21
    johnwings21Sep 3, 2024

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

  • Sanad
    SanadSep 3, 2024

    Looks amazing and useful! Keep up the great work.

    • Nevo David
      Nevo DavidSep 3, 2024

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

  • william4411
    william4411Sep 3, 2024

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

    Thank you!

    • Nevo David
      Nevo DavidSep 5, 2024

      Thank you! would you use it? :)

  • SeongKuk Han
    SeongKuk HanSep 3, 2024

    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!

  • Martin Baun
    Martin BaunSep 3, 2024

    Great read! Looking forward to more updates :)

  • uliyahoo
    uliyahooSep 3, 2024

    Awesome!

  • Stasi Vladimirov
    Stasi VladimirovSep 3, 2024

    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.

    • Nevo David
      Nevo DavidSep 3, 2024

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

    • oggo
      oggoSep 4, 2024

      Very good points!

  • Bro Karim
    Bro KarimSep 3, 2024

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

  • Shrijal Acharya
    Shrijal AcharyaSep 3, 2024

    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...

  • Muhammad Talha Javed
    Muhammad Talha JavedSep 3, 2024

    Muhammad Talha Javed, hailing from Kotla Panah in Sargodha, is a pioneering entrepreneur and the founder of Cyfrow Solutions, a thriving IT hub. His journey from a small village to becoming the number one freelancer of DigiSkills is an inspiration for many.

    • Nevo David
      Nevo DavidSep 4, 2024

      You do know that SEO comments no-related to the article will punish your website by Google.

  • kince marando
    kince marandoSep 4, 2024

    Awesome thanks

  • Michal Štefaňák
    Michal ŠtefaňákSep 4, 2024

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

    • Nevo David
      Nevo DavidSep 4, 2024

      What do you mean?

      • Michal Štefaňák
        Michal ŠtefaňákSep 4, 2024

        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.

        • Nevo David
          Nevo DavidSep 4, 2024

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

          • Ayushman
            AyushmanSep 4, 2024

            Really liked how you handled the above comment 👏

  • Yutamago
    YutamagoSep 4, 2024

    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.

    • Nevo David
      Nevo DavidSep 4, 2024

      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.

    • Alex
      AlexSep 5, 2024

      "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

  • Mariya
    MariyaSep 4, 2024

    🎉 iPhone 15 Pro Max Giveaway! 📱🎊

    Image description
    Hey everyone! We’re excited to announce our iPhone 15 Pro Max Giveaway! 🚀✨ This is your chance to win the latest and greatest in smartphone technology. Don’t miss out!
    How to Enter:
    Follow us on [Go Here] 📲
    Like this post ❤️
    Tag 2 friends who would love to win this phone too! 👥
    Share this post to your story for an extra entry! 🌟
    Bonus: Leave a comment telling us what feature you’re most excited about in the iPhone 15 Pro Max! 💬🔍
    Giveaway ends: [9-22-2024] ⏰
    Winner will be announced on: [09-23-2024] 📅
    Good luck, and may the best person win! 🍀🏆

    Giveaway #iPhone15ProMax #TechLovers #WinBig

  • Mohammad Kareem
    Mohammad KareemSep 4, 2024

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

  • oggo
    oggoSep 4, 2024

    Awesome!

  • Medic QR
    Medic QRSep 4, 2024

    Can I schedule LinkedIn posts with Postiz?

  • Emily
    EmilySep 4, 2024

    Image description
    I am so happy that I got this smartwatch completely free! If you win, you can get it too, and it will be delivered directly to your address. Don't miss your chance to win more exciting gifts including smartwatches!

  • Emily
    EmilySep 4, 2024

    Image description

    I am so happy that I got this smartwatch completely free! If you win, you can get it too, and it will be delivered directly to your address. Don't miss your chance to win more exciting gifts including smartwatches!

    [(sites.google.com/d/1O8g25fdO9_baEp...)

  • Ilya Belous
    Ilya BelousSep 4, 2024

    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!

  • Anthony
    AnthonySep 4, 2024

    Does it support icalendar/caldav? I'm intrigued

    • Nevo David
      Nevo DavidSep 4, 2024

      Not sure what are those :)

      • Anthony
        AnthonySep 6, 2024

        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

        • Nevo David
          Nevo DavidSep 6, 2024

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

  • Lenin Mendoza
    Lenin MendozaSep 4, 2024

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

  • Guillermo A
    Guillermo ASep 4, 2024

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

  • depa panjie purnama
    depa panjie purnamaSep 5, 2024

    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...

  • Md Nazmus Sakib
    Md Nazmus SakibSep 5, 2024

    great

  • Nathan Daly
    Nathan DalySep 5, 2024

    I love love the idea <3

  • Dhruvil S Shah
    Dhruvil S ShahSep 5, 2024

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

    • Nevo David
      Nevo DavidSep 5, 2024

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

    • Joao Polo
      Joao PoloSep 6, 2024

      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.

      • Nevo David
        Nevo DavidSep 6, 2024

        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.

        • Dhruvil S Shah
          Dhruvil S ShahSep 6, 2024

          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!');`

          • Nevo David
            Nevo DavidSep 6, 2024

            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.

            • Dhruvil S Shah
              Dhruvil S ShahSep 6, 2024

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

  • Faizan Raza
    Faizan RazaSep 5, 2024

    To check the CCs style you can visit (stickwarmod.com/) which provides stick war legacy mod apk

  • Jeff Chavez
    Jeff ChavezSep 6, 2024

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

  • Abby Ng
    Abby NgSep 6, 2024

    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

  • Or Ben Dahan
    Or Ben DahanSep 7, 2024

    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)

    • Nevo David
      Nevo DavidSep 7, 2024

      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 :)

  • Moly Roy
    Moly RoySep 7, 2024

    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.

  • Aishikhan
    AishikhanSep 7, 2024

    Good Work and coding

    Methstreams

  • Ashutosh_dev
    Ashutosh_devSep 7, 2024

    Image description
    Responsiveness at its peak !

    • Nevo David
      Nevo DavidSep 7, 2024

      Haha!
      Wanna help me fix it? :)

  • Andrew Baisden
    Andrew BaisdenSep 13, 2024

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

  • Fazlay Rabbi
    Fazlay RabbiSep 18, 2024

    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!

  • Chandra Panta Chhetri
    Chandra Panta ChhetriOct 7, 2024

    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 :)

  • DevOps Fundamental
    DevOps FundamentalJun 23, 2025

    Good idea, Nice to read that

Add comment