BackendServer

WebAPI

Repository Structure

Explore the main components of our project:

  1. MongoDB Documentation: Detailed information about the MongoDB collections and structures used in the project.

  2. Mobile Integration Documentation: Learn how the mobile app integrates with our API, facilitating seamless communication.

All data types are application/json unless specified otherwise.

Authentication methods used

The authentication method used in this API is JWT (Json Web Token). JWT is configured in the backend to contain the user information that is logged, including the user Id and role. This information is used later for different authorizations. The JWT is sent after login and should be used to make API calls to every protected route afterwards. The requests should set a header named Authorization with the value of Bearer followed by the JWT token received for that session.

For authorization, there is a middleware configured to fetch some user information from the token for internal processes and also the .NET’s identity framework for mongo AspNetCore.Identity.MongoDb. This enables the protection of some routes based on the role of a certain user. The following demonstrates an example header used to get access to protected routes.

{
  "headers": {
    "Authorization": "Bearer jwt_access_token"
  }
}

Endpoints

/api/auth/login

Methods: Post

Body:

{
  "email": "user@example.com",
  "password": "string"
}

Returned data:

{
  "token": "JWT_Token",
  "message": "Login successful",
  "user": {
    "id": "65bcc28f9e7d2e27a91cb82d",
    "profession": "string",
    "fullname": "Some one",
    "phonenumber": "0911926066",
    "city": "Dire Dawa",
    "age": 24,
    "imageUrl": "image_url",
    "role": "Admin",
    "email": "user@example.com",
    "gender": "Male"
  }
}

/api/auth/signup

Methods: Post

Body:

{
  "email": "user@example.com",
  "gender": "string",
  "phonenumber": "string",
  "profession": "string",
  "password": "string",
  "role": "Normal",
  "confirmPassword": "string"
}

Returned data:

{
  "id": "65bcc28f9e7d2e27a91cb82d",
  "profession": "user’s profession",
  "fullname": "",
  "phonenumber": "091231223",
  "city": "city of user",
  "age": "age of user",
  "imageUrl": "image_url",
  "role": "Normal",
  "email": "user1@example.com",
  "gender": "Male"
}

/api/user/{id}

This is accessible by Normal, Doctor and Admin as long as they are authenticated.

Methods: Put

Path: id of the user to be updated

Body: any one or more of the following can be sent

{
  "gender": "string",
  "email": "user@example.com",
  "profession": "string",
  "phonenumber": "string",
  "fullname": "string",
  "city": "string",
  "age": 150,
  "imageUrl": "string"
}

Returned data:

{
  "message": "User updated successfully",
  "user": {
    "id": "65aa80034e3f9f40cfe50e13",
    "profession": "string",
    "fullname": "John Doe",
    "phonenumber": "0911926067",
    "city": "Addis Ababa",
    "age": 22,
    "imageUrl": "img_url",
    "role": "Admin",
    "email": "user18@example.com",
    "gender": "M"
  }
}

/api/user/{id}/picture

This is accessible by Normal, Doctor and Admin as long as they are authenticated.

Methods: Post

Path: id of the user to upload the image for

Body: the body is a multipart form with ‘image’ key set to the image that is uploaded. The image types supported are ‘jpg’ and ‘jpeg’ only.

Returned data:

{
	"message": "Profile Image Uploaded Successfully",
	"user": {
		"id": "65be272eab0ad32f8d6bb7d1",
		"profession": "Programmer",
		"fullname": "John Doe",
		"phonenumber": "0911926067",
		"city": "Addis Ababa",
		"age": 21,
		"imageUrl": "ProfilePics/65be272eab0ad32f8d6bb7d1_e7bb5452-4c08-4d01-86b2-35f850d42ad2.jpg",
		"role": "Normal",
		"email": "user@example.com",
		"gender": "Male"
	}
}

Certainly! Here’s the formatted content for the remaining section:

### `/api/user/{id}/chat`

This is accessible by Normal, Doctor and Admin as long as they are authenticated.

#### Methods

- **Get:**

  - Returns the list of messages found in from recent to old based on their createdDate.
  - **Path:** id of the user whose chat we want to retrieve
  - **Returned data:** The ‘type’ key in the returned data is an Enumeration where ‘0’ corresponds to ‘Human’ and ‘1’ corresponds to ‘Ai’ indicating whether the message was sent by a human or by the AI.

  ```json
  {
    "successMessage": "Found messages",
    "messages": [
      {
        "createdDate": "date and time",
        "content": "What are you?",
        "type": 0,
        "userId": "65b9679db44315585bdb9302"
      },
      {
        "createdDate": "date and time",
        "content": "I am a health assistant for patients, especially on stroke.",
        "type": 1,
        "userId": "65b9679db44315585bdb9302"
      }
    ]
  }
  ```

/api/doctor

This is accessible by Normal, Doctor and Admin as long as they are authenticated.

Methods

/api/doctor/{id}

This is accessible by Normal, Doctor and Admin as long as they are authenticated.

Methods

Certainly! Here’s the formatted content for the remaining section:

### `/api/doctor/verify/{id}`

This is accessible by Admin.

#### Methods

- **Put:**

  - **Path:** id of the doctor should be included in the path
  - **Returned data:**

  ```json
  {
    "message": "Doctor Verified",
    "success": true
  }
  ```

/api/doctor/{id}/license

This is accessible by Doctor.

Methods

/api/user/schedule

This is accessible by Normal, Doctor and Admin as long as they are authenticated.

The returned data sets the scheduler to null and doctor to its corresponding value if the schedule is being queried by the person who requested the schedule. On the contrary, if the doctor who is receiving the schedule is querying the API it will be returning the scheduler information instead of the doctor’s.

Method

/api/user/schedule/{id}

This is accessible by Normal, Doctor and Admin as long as they are authenticated.

Methods

/api/user/schedule/{scheduleId}/status

This is accessible by Doctor.

Methods