Skip to content

fihry/social-network

Repository files navigation

Social Network

A comprehensive social networking platform built with modern web technologies, featuring user profiles, posts, groups, notifications, real-time chats, and more. This project is designed to replicate core functionalities of popular social networks like Facebook.

Table of Contents

Features

Core Functionality

  • User Authentication: Secure registration and login with session-based authentication using cookies
  • User Profiles: Complete profile management with avatars, nicknames, about sections, and follower/following relationships
  • Posts: Create, view, and interact with posts (like, comment)
  • Groups: Create and manage groups, invite members, and share group-specific content
  • Real-time Chats: Private messaging with WebSocket connections for instant communication
  • Notifications: Real-time notifications for interactions (likes, comments, follows, etc.)
  • Comments: Threaded commenting system on posts
  • Events: Create and manage events within groups
  • Media Upload: Support for image uploads (JPEG, PNG, GIF) with secure file handling

Technical Features

  • Responsive Design: Mobile-first approach with responsive UI
  • Real-time Updates: WebSocket integration for live chats and notifications
  • Database Migrations: Automated database schema management
  • Docker Support: Containerized deployment for easy setup
  • RESTful API: Well-structured backend API
  • Security: Input validation, authentication middleware, and secure file handling

Tech Stack

Backend

  • Language: Go 1.23
  • Framework: Custom HTTP server with Gorilla WebSocket
  • Database: SQLite with golang-migrate for schema management
  • Authentication: Session-based with cookies
  • Real-time: WebSocket for chats and notifications
  • Key Libraries:
    • github.com/gorilla/websocket: WebSocket connections
    • github.com/golang-migrate/migrate/v4: Database migrations
    • github.com/google/uuid: Unique identifier generation
    • golang.org/x/crypto: Password hashing

Frontend

  • Framework: Next.js 15.3.1 (React 19)
  • Styling: CSS Modules with global styles
  • State Management: React Context API
  • HTTP Client: Fetch API with custom service layer
  • Icons: React Icons
  • Key Libraries:
    • react-cookie: Cookie management for authentication
    • dotenv: Environment variable management

Infrastructure

  • Containerization: Docker & Docker Compose
  • Development Tools: ESLint, Make
  • Testing: Go testing framework, custom test utilities

Prerequisites

Before running this project, ensure you have the following installed:

  • Docker & Docker Compose: For containerized deployment
  • Node.js (v18+): For frontend development (optional, can use Docker)
  • Go (v1.23+): For backend development (optional, can use Docker)
  • Git: For version control

Installation

Quick Start with Docker (Recommended)

  1. Clone the repository:

    git clone <repository-url>
    cd social-network
  2. Start the application:

    docker-compose up --build
  3. Access the application:

Manual Installation

Backend Setup

  1. Navigate to backend directory:

    cd backend
  2. Install Go dependencies:

    go mod download
  3. Run migrations:

    go run main.go migrate
  4. Start the backend server:

    go run main.go

Frontend Setup

  1. Navigate to frontend directory:

    cd frontend
  2. Install Node.js dependencies:

    npm install
  3. Start the development server:

    npm run dev

Usage

User Registration

  1. Visit the application at http://localhost:3000
  2. Click on "Register" and fill in the required information:
    • Email
    • Password
    • First Name
    • Last Name
    • Date of Birth
    • Optional: Avatar, Nickname, About Me

Creating Posts

  1. Log in to your account
  2. Navigate to the home page or profile
  3. Click "Create Post"
  4. Add text content and optionally upload images
  5. Click "Post" to share

Joining Groups

  1. Browse available groups or create a new one
  2. Click "Join Group" to become a member
  3. Participate in group discussions and events

Real-time Chat

  1. Go to the chat section
  2. Select a user to start a conversation
  3. Send messages that appear instantly

Managing Profile

  1. Visit your profile page
  2. Update personal information, avatar, and bio
  3. View your posts, followers, and following

API Documentation

The backend provides a comprehensive REST API. Detailed documentation for each endpoint can be found in the following files:

Base URL

http://localhost:8080

Authentication

Most endpoints require authentication via session cookies. Include session cookies in your requests.

Project Structure

social-network/
├── backend/                    # Go backend application
│   ├── entity/                 # Data models and entities
│   ├── internal/               # Internal packages
│   │   ├── chat/               # Chat functionality
│   │   ├── comment/            # Comment system
│   │   ├── group/              # Group management
│   │   ├── post/               # Post management
│   │   ├── server/             # HTTP server setup
│   │   └── user/               # User management
│   ├── pkg/                    # Shared packages
│   │   ├── config/             # Configuration management
│   │   ├── database/           # Database connection & migrations
│   │   ├── sessions/           # Session management
│   │   └── utils/              # Utility functions
│   ├── main.go                 # Application entry point
│   ├── Dockerfile              # Backend Docker configuration
│   └── Makefile                # Backend build tasks
├── frontend/                   # Next.js frontend application
│   ├── src/
│   │   ├── app/                # Next.js app router pages
│   │   ├── components/         # React components
│   │   ├── context/            # React context providers
│   │   ├── services/           # API service functions
│   │   └── utils/              # Frontend utilities
│   ├── public/                 # Static assets
│   ├── package.json            # Node.js dependencies
│   ├── Dockerfile              # Frontend Docker configuration
│   └── next.config.mjs         # Next.js configuration
├── subject/                    # Project requirements and audit
├── docker-compose.yml          # Docker Compose configuration
├── Makefile                    # Root-level tasks
└── README.md                   # This file

Testing

Backend Testing

cd backend
go test ./...

Frontend Testing

cd frontend
npm run lint

Integration Testing

Use the provided test utilities and Docker Compose for full integration testing.

Contributing

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

Development Guidelines

  • Follow Go best practices for backend code
  • Use ESLint configuration for frontend code
  • Write tests for new features
  • Update documentation for API changes
  • Ensure Docker compatibility

License

This project is developed as part of an educational assignment. Please refer to the institution's guidelines for usage and distribution.

Authors

  • Developed as a collaborative project
  • Backend: Go implementation with SQLite
  • Frontend: Next.js with React

Note: This is an educational project demonstrating full-stack web development with modern technologies. It includes comprehensive features typical of social networking platforms while maintaining clean, maintainable code architecture.

About

A comprehensive social networking platform built with modern web technologies, featuring user profiles, posts, groups, notifications, real-time chats, and more. This project is designed to replicate core functionalities of popular social networks like Facebook.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors