Skip to content

ABouziani/social-network

Repository files navigation

🌐 Social Network Application

A feature-rich social network application designed to mimic core functionalities of platforms like Facebook, built with a Go backend and a Vue.js frontend, using SQLite for data persistence. The entire application is containerized using Docker for easy setup and deployment.


✨ Features

This application implements the following core functionalities:

User Management & Authentication

  • Registration/Login: Users can create an account with email, password, first name, last name, and date of birth. Optional fields include Avatar/Image, Nickname, and "About Me".
  • Authentication: Uses Sessions and Cookies to maintain user login state.

Profiles & Following

  • Profiles: Displays user information, activity (posts), followers, and following lists.
  • Profile Privacy: Supports Public and Private profiles. Private profiles are only visible to their followers.
  • Following: Users can follow/unfollow others. Following a private profile requires a follow request that must be accepted. Following a public profile is instant.

Content Creation & Privacy

  • Posts & Comments: Users can create posts and comments, optionally including an image or GIF.
  • Post Privacy: Posts can be set to Public, Almost Private (followers only), or Private (select followers only).

Groups & Events

  • Group Creation: Users can create groups with a title and description.
  • Joining Groups: Members can be invited or can request to join (requires creator approval).
  • Group Content: Groups have their own posts and comments, visible only to members.
  • Events: Group members can create events with a Title, Description, and Day/Time. Users can RSVP with "Going" or "Not Going".

Real-Time Communication

  • Private Chat: Users can send real-time private messages to users they follow or are followed by, using WebSockets.
  • Group Chat: Common chat room for all group members, also using WebSockets.
  • Emojis: Support for sending emojis in chats.

Notifications

  • A dedicated notification system for real-time alerts on:
    • Private profile follow requests.
    • Group invitations.
    • Requests to join groups (for the group creator).
    • Group event creations.

🛠️ Tech Stack

Component Technology Description
Backend Go (Golang) Handles API requests, business logic, authentication, and WebSocket connections.
Frontend Vue.js Client-side rendering for the user interface and interactivity.
Database SQLite Lightweight, file-based SQL database for data persistence.
Containerization Docker Used to package and run the Backend and Frontend in separate, isolated containers.
Migrations golang-migrate Used to manage and apply database schema changes.

🚀 Getting Started

These instructions will guide you through setting up and running the project using Docker and Docker Compose.

Prerequisites

You need to have Docker and Docker Compose installed on your system.

🏃 Running the Application

  1. Clone the repository:

    git clone [[your_repo_link](https://github.com/ABouziani/social-network.git)]
    cd [social-network]
  2. Build and Run with Docker Compose: Execute the following command in the root directory of the project. This command will:

    • Build the backend Docker image (using Dockerfile.backend).
    • Build the frontend Docker image (using Dockerfile.frontend).
    • Create and start both containers as defined in docker-compose.yml.
    docker-compose up --build

    Note: The Go backend will automatically run the SQLite database migrations (golang-migrate) on startup before starting the server. This ensures the necessary tables are created.

  3. Access the Application:

    • The Frontend (Vue.js) will be available at: http://localhost:[FRONTEND_PORT] (Check docker-compose.yml for the exact port, e.g., http://localhost:8080).
    • The Backend (Go API) will be running and listening on a separate port for internal communication (e.g., [BACKEND_PORT]).
  4. Stop the Application: To stop and remove the running containers, press Ctrl+C in the terminal where docker-compose up is running, then execute:

    docker-compose down

⚙️ Backend Details (Go & SQLite)

Database Migrations

The database schema is managed via the golang-migrate package.

  • Migration files are stored in a dedicated directory within the Go project (backend/pkg/db/migrations/sqlite/).
  • The logic in the database package (sqlite.go) handles the connection and automatic application of these migrations upon application startup.

Image Handling

Image files (JPEG, PNG, GIF) are handled by:

  1. Storing the actual image files on the backend file system (e.g., a dedicated assets/images folder within the container volume).
  2. Storing the file path or a unique identifier in the SQLite database.

Real-Time Communication (WebSockets)

A dedicated Go package manages WebSockets connections. This enables:

  • Instant Private Messaging: Messages are pushed immediately to the recipient.
  • Instant Group Chat: Messages are broadcast to all group members in real-time.
  • Live Notifications: Real-time delivery of notifications across the application.

🎨 Frontend Details (Vue.js)

The Vue.js application is responsible for the user interface and interactivity.

  • It uses the Fetch API to make HTTP requests to the Go backend API.
  • It uses a WebSocket client library to establish and manage the persistent, real-time connections required for chat and notifications.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors