Skip to content

Commit af6202b

Browse files
committed
adding docs
1 parent 4e4aca3 commit af6202b

2 files changed

Lines changed: 174 additions & 0 deletions

File tree

README.md

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# Reservation API
2+
3+
## Overview
4+
The **Reservation API** is a RESTful service for managing room reservations. It allows users to create, retrieve, and delete reservations, register rooms, and check availability. Authentication is required for certain endpoints.
5+
6+
## API Information
7+
- **Title:** Reservation API
8+
- **Version:** 0.0.1
9+
- **Description:** Room booking API.
10+
- **Author:** [Marcel Fox](https://marcelfox.com/)
11+
- **License:** [MIT](https://mit-license.org/)
12+
13+
## Local Development
14+
**For information regarding how to run the application locally, visit the [development section](./docs/DEVELOPMENT.md)**
15+
16+
## Authentication
17+
The API uses **OAuth2 Password Bearer Token** authentication for protected endpoints. Users must obtain a token via the `/token/` endpoint.
18+
19+
## Endpoints
20+
21+
### Health Check
22+
- **GET /**
23+
- **Description:** Check API health status.
24+
- **Response:** `{ "message": "ok" }`
25+
26+
### Authentication
27+
- **POST /token/**
28+
- **Description:** Authenticate user and obtain an access token.
29+
- **Request:** `application/x-www-form-urlencoded` (username & password required)
30+
- **Response:** Access token
31+
32+
### Reservations
33+
- **POST /reservations/**
34+
- **Description:** Create a new reservation.
35+
- **Authentication:** Required
36+
- **Request Body:** `{ "user_name": "John Doe", "start_time": "2025-01-22T14:00:00", "end_time": "2025-01-22T16:00:00", "room_id": 1 }`
37+
- **Response:** Reservation details
38+
39+
- **GET /reservations/**
40+
- **Description:** Retrieve a list of reservations.
41+
- **Query Parameters:** `skip` (default: 0), `limit` (default: 10)
42+
- **Response:** List of reservations
43+
44+
- **DELETE /reservations/{id}**
45+
- **Description:** Remove a reservation by ID.
46+
- **Authentication:** Required
47+
48+
### Rooms
49+
- **GET /rooms/**
50+
- **Description:** Retrieve a list of registered rooms.
51+
- **Query Parameters:** `skip` (default: 0), `limit` (default: 10)
52+
- **Response:** List of rooms
53+
54+
- **POST /rooms/**
55+
- **Description:** Register a new room.
56+
- **Authentication:** Required
57+
- **Request Body:** `{ "name": "Conference Room", "capacity": 10, "location": "Floor 1" }`
58+
- **Response:** Room details
59+
60+
- **GET /rooms/{id}/availability**
61+
- **Description:** Check room availability for a specific time range.
62+
- **Query Parameters:** `start_time`, `end_time`
63+
- **Response:** Availability status
64+
65+
- **GET /rooms/{id}/reservation**
66+
- **Description:** List reservations for a specific room.
67+
- **Query Parameters:** `date` (optional), `skip` (default: 0), `limit` (default: 10)
68+
- **Response:** List of reservations for the room
69+
70+
## Error Handling
71+
The API returns **422 Validation Error** for invalid requests. Errors include:
72+
- Missing required fields
73+
- Invalid data formats
74+
- Unauthorized access
75+
76+
## License
77+
This project is licensed under the [MIT License](https://mit-license.org/).
78+

docs/DEVELOPMENT.md

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
# Development Guide
2+
3+
## Heads-up!
4+
Before starting development, ensure you:
5+
- Create a virtual environment and activate it.
6+
- A good tool to manage virtualenvs is [virtualenvwrapper](https://virtualenvwrapper.readthedocs.io/en/latest/)
7+
- Have a PostgreSQL instance running.
8+
- For Docker users, it is possible to create a postgres instance running `make run:deb` in an individual terminal.
9+
- Install dependencies using:
10+
```sh
11+
pip install -r requirements.txt
12+
```
13+
Alternatively, if you have [Poetry](https://python-poetry.org/) installed globally, you can use:
14+
```sh
15+
poetry install
16+
```
17+
- Execute database migrations using:
18+
```sh
19+
alembic upgrade head
20+
```
21+
22+
## Prerequisites
23+
Ensure you have the following installed:
24+
- Python (>=3.8)
25+
- [pip](https://pip.pypa.io/en/stable/)
26+
- [FastAPI](https://fastapi.tiangolo.com/)
27+
- [Uvicorn](https://www.uvicorn.org/)
28+
- [Docker](https://www.docker.com/)
29+
- [Alembic](https://alembic.sqlalchemy.org/en/latest/)
30+
- [pytest](https://docs.pytest.org/en/stable/)
31+
- [Ruff](https://github.com/charliermarsh/ruff)
32+
- [isort](https://pycqa.github.io/isort/)
33+
34+
## Setup
35+
1. Install dependencies:
36+
```sh
37+
make install
38+
```
39+
40+
## Running the Application
41+
You can run the application in different environments using the following commands:
42+
43+
### Standard Run
44+
```sh
45+
make run
46+
```
47+
This starts the application using `fastapi run`.
48+
49+
### Development Mode
50+
```sh
51+
make run:dev
52+
```
53+
Runs the application in development mode using `fastapi dev`.
54+
55+
### Using Uvicorn
56+
#### Production Mode
57+
```sh
58+
make run:uvi
59+
```
60+
Runs the application using `uvicorn` with `0.0.0.0` as the host.
61+
62+
#### Development Mode
63+
```sh
64+
make run:uvi:dev
65+
```
66+
Runs the application using `uvicorn` with auto-reloading enabled.
67+
68+
### Running with Docker
69+
```sh
70+
make run:docker
71+
```
72+
Runs the application inside a Docker container using `docker compose`.
73+
74+
## Database Setup
75+
To start the PostgreSQL database:
76+
```sh
77+
make run:db
78+
```
79+
80+
To apply migrations:
81+
```sh
82+
make migrate
83+
```
84+
85+
## Linting & Formatting
86+
To format and lint the code:
87+
```sh
88+
make lint
89+
```
90+
This runs `ruff format` and `isort` on the `src/` directory.
91+
92+
## Running Tests
93+
To run tests with `pytest`:
94+
```sh
95+
make test
96+
```

0 commit comments

Comments
 (0)