Skip to content

Esaban17/ChatAPI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Chat API

This project is a back-end API for a secure real-time chat application. It provides functionalities for user management, private messaging, and secure file sharing. The application ensures the confidentiality of communications through end-to-end encryption and also uses compression for file transfers.

Features

  • Real-time Chat: Utilizes SignalR for instant messaging between users.
  • End-to-End Encryption: Implements a combination of Diffie-Hellman key exchange and SDES encryption to secure messages. All messages are stored in an encrypted format in the database.
  • Secure File Sharing: Allows users to share files that are encrypted with SDES and compressed using the LZW algorithm before being transferred.
  • User and Contact Management: Provides endpoints for user registration, login, and managing contact lists.

Project Structure

The solution is divided into three main projects:

  • ChatAPI: The main ASP.NET Core Web API project that exposes the endpoints for the chat application. It handles all the business logic, including user authentication, message handling, and file processing.
  • Encryptors: A class library project that contains the implementations of the encryption algorithms used in the application, such as Caesar cipher, Diffie-Hellman, and SDES.
  • Compressor: A class library project that contains the implementation of the LZW compression algorithm.

Getting Started

Prerequisites

Installation and Setup

  1. Clone the repository:

    Clone this repository to your local machine and navigate to the project's root directory.

  2. Configure the database connection:

    Open the ChatAPI/appsettings.json file and modify the ChatDatabaseSettings section with your MongoDB connection string and database name.

    "ChatDatabaseSettings": {
      "ConnectionString": "mongodb://localhost:27017",
      "DatabaseName": "ChatDB"
    }
  3. Run the application:

    Navigate to the ChatAPI directory and use the dotnet run command to start the server.

    cd ChatAPI
    dotnet run

    The API will be running on the port specified in the Properties/launchSettings.json file (typically https://localhost:5001 or http://localhost:5000).

API Endpoints

The following are the main endpoints provided by the ChatController:

Chat

  • GET /api/chat/{sender}/{receiver}: Retrieves the decrypted chat history between two users.
  • POST /api/chat/send/private/{senderCode}: Sends a private text message to a user. The message is encrypted before being stored.
  • POST /api/chat/send/private/file: Uploads a file, which is then encrypted and compressed.
  • GET /api/chat/{id}/download: Downloads a file, which is decompressed and decrypted on the server before being sent to the client.

User

  • GET /api/user: Retrieves a list of all users.
  • GET /api/user/username/{username}: Retrieves a specific user by their username.
  • GET /api/user/{id}: Retrieves a specific user by their ID.
  • POST /api/user: Registers a new user.
  • POST /api/user/login: Logs in a user.
  • PUT /api/user/{id}: Updates a user's information.
  • DELETE /api/user/{id}: Deletes a user.
  • GET /api/user/image/{photo}: Retrieves a user's profile picture.
  • POST /api/user/upload/{id}: Uploads a profile picture for a user.

Contact

  • GET /api/contact/{id}: Retrieves a specific contact by their ID.
  • GET /api/contact/{username}: Retrieves a list of contacts for a specific user.
  • POST /api/contact: Creates a new contact.

Invitation

  • GET /api/invitation/{id}: Retrieves a specific invitation by its ID.
  • GET /api/invitation/{username}: Retrieves a list of invitations for a specific user.
  • POST /api/invitation: Creates a new invitation.
  • POST /api/invitation/action: Accepts or declines an invitation.

WebSocket

  • socket: The SignalR hub endpoint for real-time communication.

About

Aplicación Web API C# para Chat

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages