Skip to content

Commit

Permalink
Updated microservice architecture
Browse files Browse the repository at this point in the history
  • Loading branch information
ishevche committed May 13, 2024
1 parent 523dc1b commit 36db0b2
Showing 1 changed file with 133 additions and 91 deletions.
224 changes: 133 additions & 91 deletions SERVICES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,104 +2,146 @@

## Auth Service

### Get Session ID

- **Endpoint:** `GET /session_id`
- **Description:** Retrieves a new user session ID.
- **Cookie:** Session ID

### Update Session ID

- **Endpoint:** `UPDATE /session_id`
- **Description:** Updates the session ID to connect it to a username if the user is in the database and the password is correct.

### Login

- **Endpoint:** `POST /sign-up`
- **Description:** Creates a new user and corresponding entry in the PostgreSQL database.

### Get Coffee Shop ID

- **Endpoint:** `GET /coffee_shop_id`
- **Description:** Returns the coffee shop ID for authenticating the user when editing coffee shop information.
- **Parameters:** Session ID

### Get User ID

- **Endpoint:** `GET /user_id`
- **Description:** Returns the user ID for authenticating the user when leaving a check-in.
- **Parameters:** Session ID

## Check-in Service

### Post Check-in

- **Endpoint:** `POST /check_in`
- **Description:** Posts a check-in, logs into a logging service, and adds a check-in to Cassandra.
- **Parameters (Body):** User ID, Coffee Pack ID (optional), Coffee Shop ID (optional), Rating, Text (Optional)

### Get Check-in

- **Endpoint:** `GET /check_in`
- **Description:** Retrieves all/filtered check-ins from Cassandra.
- **Parameters:** User ID (optional), Coffee Pack ID (optional), Coffee Shop ID (optional)
Responsible for storing account information and binding it to a session identified by `session_id` stored in the
cookies.
Account information is saved in PostgresSQL database.
Passwords are saved as a hashed value after adding the salt to an original password.
Sessions are stored in a distributed map of Hazelcast cluster.

### Endpoints

- `GET /session_id`
- **Description:** Setups a session if it was not set up before, otherwise renews it. Sets a cookie `session_id`.
- **Parameters:**
- `session_id` (cookie): session id to renew (optional)
- `POST /log_in`
- **Description:** Binds an account to a session_id. Session is automatically set up and renewed if necessary.
- **Parameters:**
- `session_id` (cookie): session id to bind with (optional)
- `login` (query): login of the account
- `password` (query): password of the account
- `POST /sign_up`
- **Description:** Creates a new account and binds it to a session_id.
Session is automatically set up and renewed if necessary.
- **Parameters:**
- `session_id` (cookie): session id to bind with (optional)
- `login` (query): login of the account
- `password` (query): password of the account
- `user_type` (query): type of the account (`user` or `shop`)
- `GET /id`
- **Description:** Retrieve the id from the account bound to the session id.
Session is automatically set up and renewed if necessary.
- **Parameters:**
- `session_id` (cookie): session id (optional)

## Coffee Pack Service

### Coffee Pack Model

- **Attributes:**
- Name
- ID
- Description
- Roastery
- Image path
- Weight
- Flavour

### Add Coffee Pack

- **Endpoint:** `POST /packs`
- **Description:** Adds to the "packs" table in PostgreSQL.

### Get Coffee Packs
Responsible for storing and returning the data about coffee packs.
Data is stored in a PostgresSQL database.

- **Endpoint:** `GET /packs`
- **Parameters:** Pack ID (path, optional)

### Get Coffee Pack by ID
### Coffee Pack Model

- **Endpoint:** `GET /packs/:pack_id`
- `name`: string
- `roastery`: string
- `description`: string (optional)
- `image_path`: string
- `country`: string
- `weight`: array of integers
- `flavour`: array of strings

### Endpoints

- `GET /packs`
- **Description:** Returns the list of the coffee packs.
- **Parameters:**
- `ids` (query): ids of the packs to return (optional)
- `GET /packs/{id}`
- **Description:** Returns the pack for specified `id`
- **Parameters:**
- `id` (path): id of the coffee pack
- `POST /packs`
- **Description:** Adds to the "packs" table in PostgreSQL.
- **Parameters:**
- `coffee_pack` (body/json): coffee pack object
- `session_id` (cookie): session id (optional)

## Coffee Shops Service

### Coffee Shop Model

- **Attributes:**
- Name
- ID
- Description
- Address
- Menu ID
Responsible for storing and returning the data about coffee shops alongside their menus.
Data is stored in a PostgresSQL database.

### Menu Model

- **Attributes:**
- Menu ID
- Coffee Pack ID
- Quantity
- Price

### Add Coffee Shop

- **Endpoint:** `POST /shops`
- **Description:** Adds to the "shops" table in PostgreSQL.

### Get Coffee Shops

- **Endpoint:** `GET /shops`
- **Parameters:** Shop ID (path, optional)

### Get Coffee Shop by ID
### Coffee Shop Model

- **Endpoint:** `GET /shops/:pack_id`
- `id` - integer
- `name` - string
- `description` - string
- `image_path` string
- `address_text` string
- `address_latitude` number
- `address_longitude` number

### Menu Item Model

- `coffee_pack_id` - integer
- `price` - number
- `quantity` - integer

### Endpoints

- `GET /coffee-shops`
- **Description:** Returns the list of all coffee-shops.
- `GET /coffee-shops/{id}`
- **Description:** Returns the coffee-shops for specified `id`
- **Parameters:**
- `id` (path): id of the shop
- `PUT /coffee-shops/{id}`
- **Description:** Updates the coffee-shops for specified `id`
- **Parameters:**
- `id` (path): id of the shop
- `coffee_shop` (body/json): coffee shop object
- `session_id` (cookie): session id (optional)
- `GET /coffee-shops/{id}/menu`
- **Description:** Returns the list of menu items for specified coffee shop `id`
- **Parameters:**
- `id` (path): id of the shop
- `POST /coffee-shops/{id}/menu`
- **Description:** Adds the menu item for specified coffee shop `id`
- **Parameters:**
- `id` (path): id of the shop
- `item` (body/json): menu item object
- `session_id` (cookie): session id (optional)
- `DELETE /coffee-shops/{id}/menu`
- **Description:** Deletes the menu item for specified coffee shop `id`
- **Parameters:**
- `id` (path): id of the shop
- `item_id` (query): menu item id to delete
- `session_id` (cookie): session id (optional)

## Check-in service

Responsible for storing and returning the data about check-ins.
Data is stored in a Cassandra keyspace.

### Check-in Model

- `coffee_shop_id`: integer (optional)
- `coffee_pack_id`: integer (optional)
- `check_in_time`: datetime
- `rating`: integer
- `check_in_text`: string (optional)

At least one of the `coffee_shop_id` and `coffee_pack_id` have to be specified.

### Endpoints

- `GET /check_ins`
- **Description:** Returns the list of all check-ins for specified parameters.
- **Parameters:**
- `coffee_shop_id` (query): id of the shop to get check_ins for (optional)
- `coffee_pack_id` (query): id of the pack to get check_ins for (optional)
- `user_id` (query): id of the user to get check_ins for (optional)
- `POST /check_ins`
- **Description:** Creates a check-in for logged-in user.
- **Parameters:**
- `check_in` (body/json): check-in to create
- `session_id` (cookie): session id (optional)

0 comments on commit 36db0b2

Please sign in to comment.