Skip to content

deeplukhi/Social-Recommendation-Engine

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

8 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🎯 Graph-Based Social Recommendation System

C++ License Build

A powerful graph-based recommendation engine built in C++ that leverages social connections and user interactions to provide intelligent recommendations. Perfect for e-commerce, social networks, and content platforms!


✨ Features

πŸ”₯ Core Capabilities

  • Graph-Based Recommendations: Uses adjacency lists for efficient relationship mapping
  • Multiple Algorithms:
    • Collaborative Filtering
    • Popularity-Based Recommendations
    • BFS-Based Recommendations
  • Social Network Analysis: Leverages user connections for better suggestions
  • File-based Storage: Persistent data storage with easy file management

πŸš€ Technical Highlights

  • Modern C++17 with clean OOP design
  • Modular Architecture for easy extension
  • Automatic Build System with Makefile
  • Cross-Platform (Windows/Linux/Mac support)
  • Efficient Graph Operations with adjacency list representation

πŸ“ Project Structure

GRAPHBASE_RECOMMENDATION_SYSTEM/
β”œβ”€β”€ πŸ“‚ src/
β”‚   β”œβ”€β”€ πŸ“‚ Algorithms/          # Recommendation algorithms
β”‚   β”‚   β”œβ”€β”€ CollaborativeFiltering.cpp
β”‚   β”‚   β”œβ”€β”€ Popularity.cpp
β”‚   β”‚   └── Recommendation.cpp
β”‚   β”œβ”€β”€ πŸ“‚ Graph/              # Graph data structure
β”‚   β”‚   β”œβ”€β”€ graph.cpp
β”‚   β”‚   └── graph.h
β”‚   β”œβ”€β”€ πŸ“‚ Models/             # Data models
β”‚   β”‚   β”œβ”€β”€ items.cpp
β”‚   β”‚   └── users.cpp
β”‚   β”œβ”€β”€ πŸ“‚ Storage/            # File handling
β”‚   β”‚   β”œβ”€β”€ FileManager.cpp
β”‚   β”‚   └── FileManager.h
β”‚   └── main.cpp               # Entry point
β”œβ”€β”€ πŸ“‚ tests/                  # Test cases
β”œβ”€β”€ πŸ“‚ data/                   # Sample data files
β”‚   β”œβ”€β”€ interactions.txt
β”‚   └── users.txt
β”œβ”€β”€ πŸ“‚ Utils/                  # Utility functions
β”œβ”€β”€ πŸ“œ makefile               # Build automation
└── πŸ“œ README.md              # This file

⚑ Quick Start

Prerequisites

  • C++ Compiler (g++/clang++/MSVC)
  • Make (for build automation)
  • Git (for version control)

Installation

  1. Clone the repository
git clone https://github.com/deeplukhi/GRAPHBASE_RECOMMENDATION_SYSTEM.git
cd GRAPHBASE_RECOMMENDATION_SYSTEM
  1. Build the project
make
  1. Run the application
make run

Build Commands

Command Description
make Build the project
make run Build and run the application
make test Run test cases
make clean Clean build files
make help Show available commands

🧠 How It Works

1. Data Representation

Users β†’ Graph Nodes
Interactions β†’ Graph Edges
Items β†’ Recommendation Targets

2. Algorithm Flow

graph TD
    A[Load Data] --> B[Build Graph]
    B --> C{Select Algorithm}
    C --> D[Collaborative Filtering]
    C --> E[Popularity Based]
    C --> F[BFS Based]
    D --> G[Generate Recommendations]
    E --> G
    F --> G
    G --> H[Output Results]
Loading

3. Sample Usage

// Load data
graph socialGraph;
FileManager::loadUsers("data/users.txt", socialGraph);
FileManager::loadInteractions("data/interactions.txt", socialGraph);

// Get recommendations for user 1
vector<int> recommendations = CollaborativeRecommendation::recommend(socialGraph, 1);

// Display results
cout << "Recommended items: ";
for (int item : recommendations) {
    cout << item << " ";
}

πŸ”§ Algorithms Explained

🎯 Collaborative Filtering

Finds users with similar preferences and recommends items they liked.

Formula:

similarity(u,v) = (common items) / sqrt(total items of u * total items of v)

πŸ“ˆ Popularity-Based

Recommends trending items based on overall popularity.

Features:

  • Most viewed items
  • Most purchased items
  • Trending this week

πŸ•ΈοΈ BFS-Based

Uses Breadth-First Search to explore social connections and find relevant items.

Advantages:

  • Considers social influence
  • Discovers hidden connections
  • Excellent for social networks

πŸ“Š Sample Data Format

users.txt

UserID:1 Name:Alice
UserID:2 Name:Bob
UserID:3 Name:Charlie

interactions.txt

UserID:1 ItemID:101 Interaction:view
UserID:1 ItemID:102 Interaction:purchase
UserID:2 ItemID:101 Interaction:view
UserID:3 ItemID:103 Interaction:purchase

πŸ§ͺ Testing

Run comprehensive tests:

make test

Add your own test cases in the tests/ directory. The build system automatically detects new test files!


🎬 Live Demonstration

Actual System Output

Here's a real example of the recommendation system in action:

PS C:\Users\HP\OneDrive\Desktop\DSA PROJECTS\GRAPHBASE_RECOMMENDATION_SYSTEM --UPDATE> make run

---
    MOVIE RECOMMENDATION SYSTEM
---

[βœ”] Loading previous user interactions...
[βœ”] Data loaded successfully!

Enter your name: deepv12
Welcome, deepv12 🐱
Your User ID: 82

⭐ How many favorite movies would you like to add? 2

πŸ’¬ Enter movie names (use ' _' instead of space):
β†’dark
   [Added] dark
β†’narcos
   [Added] narcos

πŸ”” Generating personalized recommendations...

πŸ“„ Recommended Movies For You
---
chernoBy1
alice_in_borderland
squid_game
stranger_things

Key Features Demonstrated:

  • βœ… User registration and ID assignment
  • βœ… Favorite movie collection
  • βœ… Personalized recommendation generation
  • βœ… Clean, user-friendly interface

πŸ› οΈ Extending the System

Adding a New Algorithm

  1. Create new files in src/Algorithms/:
// NewAlgorithm.h
#pragma once
#include "../Graph/graph.h"

class NewAlgorithm {
public:
    static vector<int> recommend(graph& g, int userId);
};

// NewAlgorithm.cpp
#include "NewAlgorithm.h"

vector<int> NewAlgorithm::recommend(graph& g, int userId) {
    // Your implementation
}
  1. The Makefile automatically includes your new files!

Adding New Data Fields

Modify the models in src/Models/ and update the FileManager for data persistence.


πŸ“ˆ Performance

Operation Time Complexity Space Complexity
Graph Building O(E) O(V + E)
Collaborative Filtering O(VΒ²) O(V)
Popularity Ranking O(V log V) O(V)
BFS Recommendations O(V + E) O(V)

V = Number of vertices (users)
E = Number of edges (interactions)


🀝 Contributing

We welcome contributions! Here's how:

  1. Fork the repository
  2. Create a feature branch
git checkout -b feature/amazing-feature
  1. Commit changes
git commit -m 'Add amazing feature'
  1. Push to branch
git push origin feature/amazing-feature
  1. Open a Pull Request

πŸ“ License

This project is licensed under the MIT License - see the LICENSE file for details.

🌟 Star History

Star History Chart


πŸ“ž Support

Found a bug? Have a feature request?
Open an Issue


⭐ Star this repo if you find it useful! ⭐

Built with ❀️ and C++

About

A powerful graph-based recommendation engine built in C++ that leverages social connections and user interactions to provide intelligent recommendations. Perfect for e-commerce, social networks, and content platforms!

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors