<!-- TABLE OF CONTENTS -->
<details>
<summary>Table of Contents</summary>
<ol>
<li>
<a href="#about-the-project">About The Project</a>
<ul>
<li><a href="#built-with">Built With</a></li>
</ul>
</li>
<li>
<a href="#getting-started">Getting Started</a>
<ul>
<li><a href="#prerequisites">Prerequisites</a></li>
<li><a href="#installation">Installation</a></li>
</ul>
</li>
<li><a href="#usage">Usage</a></li>
</ol>
</details>
<!-- ABOUT THE PROJECT -->
### About the project
Flock service is a project that is built with FastAPI. The main role of this service is that you read from the parquet file that is stored in the S3, load it into the in-memory database which id duckDB, execute the query(queries).
API List:
| Endpoint | Description |
| -------- | -------- |
| /health | |
| /query | Run the provided query against a dataset/Parquet file|
| /batchquery | This allows multiple queries to be sent at once |
#### Built with
This project is built with the following technologies:
* [FastAPI](https://fastapi.tiangolo.com/) - FastAPI is a modern, fast (high-performance), web framework for building APIs with Python 3.7+ based on standard Python type hints.
* [DuckDB](https://www.duckdb.org/) - A SQL database that can be used as an alternative to traditional relational databases.
* [Pydantic](https://pydantic-docs.helpmanual.io/) - Data validation and settings management using Python type annotations.
* [pytest](https://docs.pytest.org/en/stable/) - A mature full-featured Python testing tool that helps you write better programs.
* [uvicorn](https://www.uvicorn.org/) - A fast ASGI server, to run a FastAPI application in a remote server machine is an ASGI server program like Uvicorn.
* [MinIO](https://min.io/) - An open-source object storage server that is API-compatible with Amazon S3, to mimic the use of S3bucket (for developing and testing).
* [boto3](https://boto3.amazonaws.com/v1/documentation/api/latest/index.html) - The AWS SDK for Python, which provides an easy-to-use interface to interact with AWS services including S3 or MinIO.
<!-- GETTING STARTED -->
### Getting started
#### Prerequisites
Before you can use this project, you'll need to have Docker installed. Once you have Docker installed, you can run the following command to start the MinIO container:
```sh
docker pull minio/minio
```
```sh
docker run -p 9000:9000 -p 9090:9090 --name minio2 -e "MINIO_ROOT_USER=ADD_YOUR_ROOT_USER" -e "MINIO_ROOT_PASSWORD=ADD_YOUR_ROOT_PASSWORD" -v ${HOME}/minio/data:/data quay.io/minio/minio server /data --console-address ":9090"
```
Open http://localhost:9000/ to verify that MinIO is running correctly.
#### Installation
1. Clone the repo
```sh
git clone ssh://git@oxfordssh.awsdev.infor.com:7999/flock_dev/flock_dev.git
```
2. Install the dependencies of the project by running `pip install -r requirements.txt`
3. Enter your root user and password in the S3_funcs.py file
```
aws_access_key_id='ADD_YOUR_ROOT_USER'
aws_secret_access_key='ADD_YOUR_ROOT_PASSWORD'
```
<!-- USAGE EXAMPLES -->
### Usage
Run the following command to run the project:
```
uvicorn main:app --reload
```