by fastify

Fastify example - clone twitter

144 Stars 33 Forks Last release: Not found MIT License 72 Commits 0 Releases

Available items

No Items, yet!

The developer of this repository has not created any items for sale yet. Need a bug fixed? Help with integration? A different license? Create a request here:

Fastify twitter clone

The aim of this project is to show how

can be used.

NB: This project should be considered WIP and it does not reflect the best way we think fastify should be used, but it's rather an experiment to help driving fastify.


For running this project on your machine: ```bash

terminal 1: Start frontend server

cd frontend && npm start

terminal 2: start backend

npm start -- --log-level trace --port 3001 ```

Open your browser at http://localhost:3000

NB this project need to access a mongodb and a redis instance. If you haven't them, please consider to use docker.



Fastify helps us to keep this segregation: the plugin system provides us a way to declare pieces of our business logic without exposing them to the whole application. If you looking for a guide to understand better how the plugin system works, please read this Plugin Guide

So, the backend is splitted into plugins: - user: user authentication / user database - tweet: tweet storage - follow: follow storage - timeline: timeline for homepage

The last three modules have a

hook to find which the user has made the request.

Each plugin has almost the same structure: -

is the fastify binding -
is the business logic -
has the schemas used for http validation and serialization (See

User plugin

This plugin registers some APIs in order to register, login, search and get a profile for an user.

It uses

to save users and exports a
to allow other plugins to access to an user profile.

Tweet plugin

This plugin stores tweets and allows you to retrieve the tweets of an user.

It uses

for storing the tweets and exports a client for tweets retrieving.

Follow plugin

This plugin tracks the following and the followers implementing the flow explained here.

It uses

for tracking which users follow the other ones and vice versa.

Timeline plugin

This plugin aggregates informations from

plugin in order to return the tweet timeline.

This plugin doesn't use any database to track that informations and uses tweetService and followService to build the response.


The frontend side has been done only to show a simple UI for avoiding the manual CURLs.

It is built using


No UX or UI study are made (please PR!)

Coming soon


  • [x] Search users
  • [x] Timeline
  • [x] Follow microservices for following and unfollowing other users
  • [x] Better test
  • [ ] Better
  • [x] Use Docker compose
  • [ ] Use
    for react serve side rendering
  • [x] Better UI
  • [ ] Even better UI

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.