How abel2319/social_media_backend works
Project type and purpose
• This is a C++‐based backend service (“Social_Medial_Backend”) that listens on a socket, processes client requests, and reads/writes fragmented data across three remote PostgreSQL servers.
File structure
• Top‐level:
• README.md, database.sql (schema & fragmentation script)
• images/ (possibly UI mocks or data flow sketches)
• src/ (all C++ source + one header)
• src/:
• main.cpp – entry point, sets up socket listener and dispatch loop
• connexion.cpp – socket setup, accept(), read/write data
• classeUsers.cpp / classePub.cpp – classes modeling Users and Publications
• tools.cpp – helper routines (parsing, data‐structure manipulation)
• header.h – class declarations (fields, methods)
README
• Core features:
• Socket‐based C++ server
• PostgreSQL fragmentation across three remote machines
• No explicit data‐structure commentary, but “classes” imply encapsulated collections
a. Main components:
• Client(s) (e.g., mobile/web front end)
• Connection Manager (socket listener in connexion.cpp)
• Business Logic Layer
– UserManager (classeUsers)
– PublicationManager (classePub)
– Tools/Utils (tools.cpp)
• Database Cluster (3× Postgres instances, fragmentation layer)
b. Relationships & interactions:
• Client → Connection Manager (TCP socket)
• Connection Manager → Business Logic (invokes UserManager or PublicationManager)
• Business Logic → Database Cluster (via libpq or raw SQL over TCP)
• Tools provide shared data parsing, logging, in‐memory collections
c. Architectural patterns & principles:
• Modular classes for each domain entity (Users, Publications)
• Single Responsibility: connexion.cpp only handles networking, tools.cpp only utilities
• Repository‐like data access (classes encapsulate SQL queries)
d. Technologies & libraries:
• C++17/14, STL containers (vector, map, list) for in‐memory caching
• POSIX sockets or Boost.Asio for network I/O
• libpq/libpqxx or direct TCP for PostgreSQL connections
• SQL scripts (database.sql) to set up fragmentation
Data‐structure visualization (per your study goal)
• For each C++ class, extract its fields and map them to container types:
• classeUsers → e.g., std::vector<User>, std::map<userID,User>
• classePub → std::list<Publication> or std::unordered_map<pubID,Publication>
• tools.cpp → any specialized structures (e.g., priority queue for notifications)