This repository contains a Flask application for handling CSV upload, querying data from ClickHouse, and authentication using JWT.
Note: Temporarily Stopped EC2 instance and ClickHouse Cloud service to avoid any extra charges! Hope, you'll find this project interesting ;)
You can pull the Docker image and run the application locally:
docker pull narendramaurya/segwise-flask-app:latestdocker run -p 5000:5000 narendramaurya/segwise-flask-app:latestYou can test the endpoints using Postman or any HTTP client:
Endpoint:
http://13.50.90.158:5000/auth/signup- Method: POST
- Body:
{ "username": "harshitsingh", "password": "pass#101" } - Response:
{
"message": "User registered successfully."
} Endpoint:
http://13.50.90.158:5000/auth/login- Method: POST
- Body:
{ "username": "shobhit", "password": "shobhit@segwise" } - Response:
{
"token": "<generated_jwt_token>"
}Endpoint:
http://13.50.90.158:5000/main/upload_csv-
Method: POST
-
Header
{ "Content-Type": "application/json", "Authorization": "Bearer <generated_jwt_token>" } -
Body:
{ "csv_url": "https://drive.google.com/uc?export=download&id=18450NWcYxXZoEVrwwjwfIfDgLUUZPJPQ" } -
Response:
{
"message": "CSV upload and processing completed."
}Endpoint:
http://13.50.90.158:5000/query/query?Required_age=17- Method: GET
- Headers:
{ "Content-Type": "application/json", "Authorization": "Bearer <generated_jwt_token>" } - Response:

Endpoint:
http://13.50.90.158:5000/query/query?Name=Tele- Method: GET
- Headers:
{ "Content-Type": "application/json", "Authorization": "Bearer <generated_jwt_token>" } - Response:

Endpoint:
http://13.50.90.158:5000/query/query?Release_date=2020-02-03 - Method: GET
- Headers:
{ "Content-Type": "application/json", "Authorization": "Bearer <generated_jwt_token>" } - Response:

aggregate_field : column name
aggregate_type : aggregate function name for e.g. count , sum , avg , min , max , etcEndpoint:
http://13.50.90.158:5000/query/query?aggregate_field=Price&aggregate_type=sum
- Method: GET
- Headers:
{ "Content-Type": "application/json", "Authorization": "Bearer <generated_jwt_token>" } - Response:

Endpoint:
http://13.50.90.158:5000/query/query?start_date=2020-02-03&end_date=2020-10-03- Method: GET
- Headers:
{ "Content-Type": "application/json", "Authorization": "Bearer <generated_jwt_token>" } - Response:

If you receive a response with the following message:
{
"message": "Token has expired!"
}Action Re-login: Obtain a new JWT token by logging in again using your credentials.
- Instance Type: t3.micro instance is in the general purpose family with 2 vCPUs, 1.0 GiB of memory and up to 5 Gibps of bandwidth starting at $0.0108 per hour.
- Region: Europe (Stockholm) (eu-north-1)
- On-Demand Linux Pricing: $0.0108 USD per Hour
- Instance Running Time: 24 hours/day
- Number of Days: 30 days
- File Uploads: 1 per day
- Queries: 100 per day
-
Calculate Monthly Hours:
- Hours in a day: 24 hours
- Days in a month: 30 days
- Total hours per month: 720 hours
-
Calculate Instance Cost:
- Hourly rate: $0.0108 USD
- Monthly cost: 720 hours * $0.0108 USD/hour = $7.78 USD/month
- Base EC2 Cost: $7.78 USD/month
- The t3.micro instance type is eligible for the AWS Free Tier for new AWS accounts.
- Under the Free Tier, you can use 750 hours of t3.micro instance per month for the first 12 months after sign-up


