Skip to content

sanik0300/meetings-scheduling-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Meetings Scheduling API a backend system for scheduling meetings for multiple users Requirements

  • .NET SDK 8+
  • Visual Studio (optional, recommended 2022)

How to start

  1. Clone the repository git clone https://github.com/sanik0300/meetings-scheduling-api.git
  2. Install dependencies (they include EntityFrameworkCore.InMemory - for data storage according to the task) dotnet restore

There is no need to configure any database, because an in-memory database is used. So therefore data is wiped when the program stops.

  1. Run the API: dotnet run
  2. API starts at the port 5071 (HTTP) or 7262 (HTTPS):
http://localhost:5071
https://localhost:7262
  1. Test the API with Swagger, other client (I recommend Postman) or directly in browser
  2. Ctrl+C to shutdown

API endpoints Warning: datetime format in JSONs must be UTC: for example, 2025-06-20T09:00:00Z_

  1. User Controller POST /users
  • creates a user Request body example:
{ "name": "Alice" }

Returns: 204 No content In case of errors returns: if name value is not provided - 400 Bad Request

GET /users/{userId}/meetings

  • returns all meetings for a user by the specified ID Response body example in succesful case:
[
    {
        "id": 1,
        "participantIds": [
            1,
            2
        ],
        "startTime": "2025-06-20T09:00:00Z",
        "endTime": "2025-06-20T10:00:00Z"
    },
    {
        "id": 3,
        "participantIds": [
            1,
            2,
            3
        ],
        "startTime": "2025-06-20T11:30:00Z",
        "endTime": "2025-06-20T12:20:00Z"
    },
    {
        "id": 4,
        "participantIds": [
            2,
            5,
            4
        ],
        "startTime": "2025-06-22T16:00:00Z",
        "endTime": "2025-06-22T16:45:00Z"
    }
]

In case of errors returns:

  • Impossible user ID (0 or negative): 400 Bad Request
  • Not found user with such ID in DB: 404 Not Found

GET /users/list

  • returns a list of all users. Although not required by the task, implemented for convenience. Response body example:
[
    {
        "id": 1,
        "name": "Alice"
    },
    {
        "id": 2,
        "name": "Karter"
    },
    {
        "id": 3,
        "name": "Jenna"
    },
    {
        "id": 4,
        "name": "Timmy"
    },
    {
        "id": 5,
        "name": "Giles"
    }
]
  1. Meetings Controller POST /meetings
  • returns the earliest time slot (start time and end time) that fits calendars of all users whose IDs are specified in the request Request body example:
{
  "participantIds": [3, 4],
  "durationMinutes": 60,
  "earliestStart": "2025-06-20T09:00:00Z",
  "latestEnd": "2025-06-20T17:00:00Z"
}

Response body example in succesful case:

{
    "start": "2025-06-20T10:15:00Z",
    "end": "2025-06-20T11:15:00Z"
}

In case of errors returns:

  • JSON malformed or not provided, missing properties etc: 400 Bad Request
  • Impossible user ID (0 or negative) among participant IDs: 400 Bad Request
  • Time range end time earlier than or equal to start time: 400 Bad Request
  • Time range boundaries beyond business hours (9:00-17:00): 400 Bad Request
  • Not found in DB at least 1 user by ID among participants: 404 Not Found
  • Not found time slot free for everyone in given time range: 404 Not Found

POST /meetings/add

  • tries to add the meeting in a set time slot in the calendars of all users whose IDs are specified in the request. Not required by the task, but implemented for convenience. Uses essentially the same logic as the previous action. Request body example:
{
  "ParticipantIds": [1, 2, 3],
  "StartTime": "2025-06-20T11:30:00Z",
  "EndTime": "2025-06-20T12:20:00Z"
}

Returns: 204 No content In case of errors returns: same as the previous action

Unit tests The agorithm of detecting the earliest time slot is covered by 12 unit tests in total, which are situated in the test project. Tests focus on such situations as:

  • there are no other meetings at all
  • there are other meetings, but they are beyond the requested time range
  • enough free time is at the start/end of the requested time range
  • consecutive meetings with and without enough free time between them
  • overlapping and back-to-back meetings within the requested time range (but enough free time between them)
  • enough free time is at the start of the next day
  • enough free time is during the next day
  • overlapping and back-to-back meetings, no free time between them You can run the tests with: dotnet test

Solution structure MeetingsScheduleAPI #main project |-Properties/ #launchSettings.json here |-Controllers/ #API controllers described above |-Infrastructure/ #Here there are implementations of repositories + custom validation attribute to limit DateTime properties within business hours |-Models/ |-Repositories/ #Interfaces of repositories |-ViewModels/ #Model classes that don't count as data: a request to find time slot for participants in a time range (=request body for POST /meetings); and time slot (start + end time) #Here there are data classes (User and Meeting), DbContext for the in-memory database and a static class with the main algorithm of finding earliest time slots #Here is Program.cs, that includes configuration of DbContext, repositories ScheduleApiUnitTest #there is a single file with unit tests of time slot detection algorithm

About

test task for HYS academy's backend course

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages