Before you begin, ensure you have met the following requirements:
- Python: Make sure you have Python 3.6 or higher installed. You can download it from python.org.
- PostgreSQL: Install PostgreSQL on your machine. You can find the installation instructions at postgresql.org.
- Docker: If you plan to use Docker, make sure you have Docker and Docker Compose installed. You can download Docker from docker.com.
- Git: Ensure you have Git installed to clone the repository. You can download it from git-scm.com.
-
Clone the repository: git clone [repository_url] cd [repository_name]
-
Create a virtual environment and activate it: python -m venv venv source venv/bin/activate # On Windows use: venv\Scripts\activate
-
Install dependencies: pip install -r requirements.txt
-
Set up the PostgreSQL database:
- Create a database and user in PostgreSQL, and update your Django
settings.py
with the appropriate credentials.
- Create a database and user in PostgreSQL, and update your Django
-
Run migrations: python manage.py migrate
-
Start the development server: python manage.py runserver
-
Clone the repository: git clone [repository_url] cd [repository_name]
-
Build the Docker images: docker-compose build
-
Start the containers: docker-compose up
-
Run migrations inside the Docker container: docker-compose exec web python manage.py migrate
-
POST /api/signup/
- Description: Register a new user.
- Request:
{ "email": "[email protected]" }
- Response:
{ "message": "User created successfully." }
-
POST /api/login/
- Description: Log in an existing user.
- Request:
{ "email": "[email protected]", "password": "your_password" }
- Response:
{ "token": "your_jwt_token" }
- GET /api/users/
- Description: Search for users by email or name.
- Query Parameters:
q
(search term) - Response:
{ "results": [ { "id": 1, "name": "John Doe", "email": "[email protected]" }, ... ] }
-
POST /api/send_request/
- Description: Send a friend request to another user.
- Request:
{ "recipient_email": "[email protected]" }
- Response:
{ "message": "Friend request sent." }
-
GET /api/pending_requests/
- Description: View pending friend requests received by the user.
- Response:
{ "pending_requests": [ { "id": 1, "sender_email": "[email protected]" }, ... ] }
-
POST /api/reject_request/
- Description: Reject a friend request.
- Request:
{ "request_id": 1 }
- Response:
{ "message": "Friend request rejected." }
-
POST /api/accept_request/
- Description: Accept a friend request.
- Request:
{ "request_id": 1 }
- Response:
{ "message": "Friend request accepted." }
-
GET /api/view_friends/
- Description: View the list of friends.
- Response:
{ "friends": [ { "id": 1, "name": "John Doe", "email": "[email protected]" }, ... ] }
-
POST /api/block_user/
- Description: Block a user, preventing them from sending friend requests or viewing your profile.
- Request:
{ "user_email": "[email protected]" }
- Response:
{ "message": "User blocked successfully." }
-
POST /api/unblock_user/
- Description: Unblock a previously blocked user.
- Request:
{ "user_email": "[email protected]" }
- Response:
{ "message": "User unblocked successfully." }
-
GET /api/blocked_users/
- Description: View the list of blocked users.
- Response:
{ "blocked_users": [ { "id": 1, "name": "Blocked User", "email": "[email protected]" }, ... ] }
- Database: PostgreSQL was chosen for its advanced features like full-text search and efficient handling of large datasets.
- Authentication: JWT was implemented for secure and stateless authentication, allowing for easy token refreshing.
- Caching: Redis was used to optimize response times and reduce database load, particularly for frequently accessed data.