Giter VIP home page Giter VIP logo

social-networking's Introduction

Sure! Below is the README.md file for your project.

# Social Network API

This is a social networking application API built using Django Rest Framework. The application includes user signup, login, search, friend requests, and friend listing functionalities.

## Features

- User Signup
- User Login
- Search Users by Email or Name
- Send/Accept/Reject Friend Requests
- List Friends
- List Pending Friend Requests
- Rate Limiting for Friend Requests (max 3 requests per minute)

## Technologies Used

- Django
- Django Rest Framework
- PostgreSQL
- Redis
- Docker
- JWT for Authentication

## Prerequisites

- Docker and Docker Compose installed on your machine

## Installation

### 1. Clone the repository

```bash
git clone https://github.com/yourusername/social_network_api.git
cd social_network_api

3. Build and Run the Docker Containers

docker-compose up --build

This command will build the Docker images and start the containers for the Django application, PostgreSQL database, and Redis.

4. Create a Superuser

After the containers are up, create a superuser to access the Django admin interface:

docker-compose exec web python manage.py createsuperuser

5. Access the Application

  • The Django application will be running at http://localhost:8000.
  • The Django admin interface will be accessible at http://localhost:8000/admin.

API Endpoints

You can use Postman to test the API endpoints. Import the provided Postman collection to get started quickly.

Postman Collection

Import the SocialNetworkAPI.postman_collection.json file into Postman to get all the configured endpoints.

Endpoints

User Signup

  • URL: http://localhost:8000/api/signup/
  • Method: POST
  • Body:
    {
      "email": "[email protected]",
      "password": "testpassword"
    }

User Login

  • URL: http://localhost:8000/api/login/
  • Method: POST
  • Body:
    {
      "email": "[email protected]",
      "password": "testpassword"
    }

Search Users

  • URL: http://localhost:8000/api/search/?q=searchterm
  • Method: GET
  • Headers:
    Authorization: Bearer <access_token>
    

Send Friend Request

  • URL: http://localhost:8000/api/friend-request/
  • Method: POST
  • Headers:
    Authorization: Bearer <access_token>
    
  • Body:
    {
      "to_user": "[email protected]"
    }

Accept Friend Request

  • URL: http://localhost:8000/api/friend-request/accept/
  • Method: POST
  • Headers:
    Authorization: Bearer <access_token>
    
  • Body:
    {
      "from_user": "[email protected]"
    }

Reject Friend Request

  • URL: http://localhost:8000/api/friend-request/reject/
  • Method: POST
  • Headers:
    Authorization: Bearer <access_token>
    
  • Body:
    {
      "from_user": "[email protected]"
    }

List Friends

  • URL: http://localhost:8000/api/friends/
  • Method: GET
  • Headers:
    Authorization: Bearer <access_token>
    

List Pending Friend Requests

  • URL: http://localhost:8000/api/friend-requests/pending/
  • Method: GET
  • Headers:
    Authorization: Bearer <access_token>
    

Containerize the Application

The application is containerized using Docker. The Docker setup includes a web service for the Django application, a database service for PostgreSQL, and a Redis service.

Docker Setup

  • Dockerfile: Defines the image for the Django application.
  • docker-compose.yml: Configures the services and networking.

Rate Limiting

Friend requests are rate-limited to a maximum of 3 requests per minute.

social-networking's People

Contributors

pinkleshparjapati avatar

Watchers

Pinklesh Parjapati avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.