https://github.com/apexkv/facebook-clone
This is a clone project of facebook platform in microservies architecture
https://github.com/apexkv/facebook-clone
clone-project django djanogo-rest-framework facebook-clone microservices microservices-architecture mongodb mysql neo4j nextjs nodejs rabbitmq reactjs redis socket-io
Last synced: about 1 month ago
JSON representation
This is a clone project of facebook platform in microservies architecture
- Host: GitHub
- URL: https://github.com/apexkv/facebook-clone
- Owner: apexkv
- License: mit
- Created: 2024-08-23T02:49:13.000Z (9 months ago)
- Default Branch: main
- Last Pushed: 2025-01-09T21:11:20.000Z (4 months ago)
- Last Synced: 2025-04-10T03:55:28.361Z (about 1 month ago)
- Topics: clone-project, django, djanogo-rest-framework, facebook-clone, microservices, microservices-architecture, mongodb, mysql, neo4j, nextjs, nodejs, rabbitmq, reactjs, redis, socket-io
- Language: Python
- Homepage:
- Size: 29 MB
- Stars: 1
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# **Facebook-Clone Project**
## Table of Contents
1. [Overview](#overview)
2. [High-Level Architecture](#high-level-architecture)
3. [Folder Structure](#folder-structure)
4. [Key Features](#key-features)
5. [System Architecture](#system-architecture)
6. [Technologies Used](#technologies-used)
7. [Advantages of the Architecture](#advantages-of-the-architecture)
8. [Getting Started](#getting-started)
9. [References](#references)
10. [License](#license)
11. [Finally](#finally)## Overview
This Facebook Clone project is a fully functional social media platform built with a microservices architecture. It features user authentication, posts, comments, likes, chat functionality, friend connections, and a modern frontend interface. The project emphasizes scalability, data consistency, and performance.
---
#### **High-Level Architecture**
1. **Microservices**
- For detailed documentation of each microservice, please refer to the following:
1. [Users Microservice](./users/README.md)
2. [Posts Microservice](./posts/README.md)
3. [Friends Microservice](./friends/README.md)
4. [Chat Microservice](./chat/README.md)
5. [Frontend Service](./frontend/README.md)2. **Frontend**
- Built with **Next.js**, the frontend offers a seamless user experience with modern UI/UX principles and server-side rendering.
3. **Databases**
- **PostgreSQL**: Used for structured data in the Chat, Posts, and Users microservices.
- **Neo4j**: Used in the Friends microservice to handle graph-based relationships like friendships and friend suggestions.4. **Messaging and Caching**
- **RabbitMQ**: Ensures data consistency across microservices by facilitating event-driven communication.
- **Redis**:
- Used for caching frequently accessed data.
- Functions as the event store for channels in the Chat microservice to support real-time communication.5. **Containerization**
- All microservices and the frontend are fully containerized using Docker.
- A **Docker Compose** file orchestrates the services, ensuring seamless development and deployment.---
#### **Folder Structure**
```plaintext
facebook-clone/
│
├── users/ # Users Microservice
├── posts/ # Posts Microservice
├── friends/ # Friends Microservice
├── chat/ # Chat Microservice
├── frontend/ # Frontend Service
├── docker-compose.yml # Docker Compose configuration
├── README.md # Main Project Documentation
```#### **Key Features**
- **Authentication and Authorization**:
- User registration, login, and session management via the Users microservice.
- **Posts Management**:
- Users can create, delete and view posts.
- Features like commenting and liking posts are supported.- **Friendship Management**:
- Users can send and accept friend requests.
- Friend suggestions are generated using graph-based algorithms in Neo4j.- **Real-time Chat**:
- Secure, scalable real-time messaging using Django Channels and Redis.
- **Modern Frontend**:
- Built with Next.js for optimized performance and modern design.
- **Scalability and Consistency**:
- Event-driven communication ensures data consistency across microservices using RabbitMQ.
- Redis caching improves response times for high-demand endpoints.- **Containerization**:
- All components are containerized for consistent deployment across different environments.---
### **System Architecture**

#### **Technologies Used**
- **Backend Framework**: Django with Django Rest Framework
- **Frontend Framework**: Next.js
- **Databases**: PostgreSQL, Neo4j
- **Message Broker**: RabbitMQ
- **Cache**: Redis
- **Containerization**: Docker
- **Orchestration**: Docker Compose---
#### **Advantages of the Architecture**
1. **Scalability**: Each microservice can be scaled independently to handle growing user demands.
2. **Modularity**: Clear separation of concerns between different services simplifies maintenance and development.
3. **Data Consistency**: RabbitMQ ensures event-driven synchronization between services.
4. **Performance**: Redis caching improves the speed of frequently accessed data.
5. **Modern Development Practices**: The use of Docker and Docker Compose enables seamless deployment and development.## Getting Started
### 1. Clone the repository
```bash
git clone https://github.com/apexkv/facebook-clone.git
cd facebook-clone
```### 2. Configure environment variables for each service
- These environment variables configure the necessary services like the database, message broker (RabbitMQ), and other service dependencies. Please make sure to fill in the appropriate values based on your environment.
#### Users .env
```plaintext
# ./users/.envSECRET_KEY=ILKQ1giDu=
POSTGRES_DB=
POSTGRES_USER=
POSTGRES_PASSWORD=
POSTGRES_HOST=
POSTGRES_ROOT_PASSWORD=
POSTGRES_PORT=RABBITMQ_DEFAULT_USER=
RABBITMQ_DEFAULT_PASS=
RABBITMQ_HOST=CURRENT_QUEUE=users
QUEUE_LIST=friends,posts,chat
```#### Chat .env
```plaintext
# ./chat/.env# this secret key need to be same scret key in Users service secret key
SECRET_KEY=ILKQ1giDu=POSTGRES_DB=
POSTGRES_USER=
POSTGRES_PASSWORD=
POSTGRES_HOST=
POSTGRES_ROOT_PASSWORD=
POSTGRES_PORT=RABBITMQ_DEFAULT_USER=
RABBITMQ_DEFAULT_PASS=
RABBITMQ_HOST=CURRENT_QUEUE=chat
QUEUE_LIST=friends,posts,usersUSERS_SERVICE=http://users:8000
```#### Posts .env
```plaintext
# ./posts/.envSECRET_KEY=ILKQ1giDu=
POSTGRES_DB=
POSTGRES_USER=
POSTGRES_PASSWORD=
POSTGRES_HOST=
POSTGRES_ROOT_PASSWORD=
POSTGRES_PORT=RABBITMQ_DEFAULT_USER=
RABBITMQ_DEFAULT_PASS=
RABBITMQ_HOST=CURRENT_QUEUE=posts
QUEUE_LIST=friends,chats,usersUSERS_SERVICE=http://users:8000
```#### Friends .env
```plaintext
# ./friends/.envSECRET_KEY=ILKQ1giDu=
NEO4J_AUTH=
NEO4j_HOST=RABBITMQ_DEFAULT_USER=
RABBITMQ_DEFAULT_PASS=
RABBITMQ_HOST=QUEUE_LIST=chat,posts,users
CURRENT_QUEUE=friendsUSERS_SERVICE=http://users:8000
```### 3. Start Service Using Docker
```bash
docker compose up --build
```### 4. Now you can explorer the project in these endpoints
```
http://localhost:3000/ # nextjs frontendhttp://localhost:888/api/users/ # users microservice
http://localhost:888/api/posts/ # posts microservice
http://localhost:888/api/friends/ # friends microservice
http://localhost:888/api/chat/ # chat microservice
```---
### References
For more information on Docker and Docker Compose, visit their official documentation:
- [Docker](https://docs.docker.com/)
- [Docker Compose](https://docs.docker.com/compose/)# License
This project is licensed under the MIT License. See the [LICENSE](./LICENSE) file for details.
# Finally
Thank you for exploring this Facebook Clone project. If you have any feedback, feel free to create an issue or contribute to the repository. Happy coding! 😊