Skip to content

Submission #72

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 25 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 1 addition & 0 deletions xaea12/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
API_KEY=""
43 changes: 43 additions & 0 deletions xaea12/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.venv
/api/venv
/api/__pycache__
/.pnp
.pnp.js
/api/venv

# testing
/coverage

# next.js
/.next/
/out/

# production
/build

# misc
.DS_Store
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# local env files
.env*.local

# vercel
.vercel

# typescript
*.tsbuildinfo
next-env.d.ts
__pycache__

#API Key
API_KEY
63 changes: 63 additions & 0 deletions xaea12/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
## Team Name

XAEA12

## Problem Statement

Currently, Google offers Direction Requests insights (Count of unique customers seeking directions to your business, adjusted for multi-tapping, cancellations, and spam) as a part of Google Business Profile performance metrics.
However, for a new business who wishes to set up a store in a particular locality, there is little to no data available on the customer density.

## Team leader email

[email protected]

## A brief of the prototype

# Idea
Develop an application utilizing the Google Maps Places API to extract business details and create heatmaps, addressing the problem of understanding market demand in specific geographic areas.

# Solution
Our application collects data on business activity, including visit trends, and visualizes it using heatmaps. This helps businesses and local authorities make data-driven decisions, optimize operations, and identify growth opportunities.

## Tech stack

Next.js (with TypeScript) for the frontend, with Flask for the backend. We use Google maps APIs such as Places API to get place data, autofill as well as visualization information for creating heatmaps.

## Step by Step code execution instructions

First, edit the code to insert your API key with Places API enabled in
app/.env
api/.env
.env
app/page.tsx

Install the dependencies:

```bash
npm install
# or
yarn
# or
pnpm install
```

Run

```npm run build
```

to build the packages.

Then, run the development server:

```bash
npm run dev
# or
yarn dev
# or
pnpm dev
```

Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.

The Flask server will be running on [http://127.0.0.1:5328](http://127.0.0.1:5328) – feel free to change the port in `package.json` (you'll also need to update it in `next.config.js`).
1 change: 1 addition & 0 deletions xaea12/api/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
API_KEY=""
2 changes: 2 additions & 0 deletions xaea12/api/config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from dotenv import load_dotenv
load_dotenv()
119 changes: 119 additions & 0 deletions xaea12/api/index.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
import datetime
import time

import requests
from flask import Flask, jsonify
import json

import populartimes
import googlemaps

import os
API_KEY = os.getenv("API_KEY")

#app instance
app = Flask(__name__)

@app.route("/api/python")
def hello_world():
return "<p>Hello, World!</p>"

@app.route("/api/popular_times_demo", methods=['GET'])
def delayed_api_req():
time.sleep(20)
response = [
{
"coordinates": {
"lat": 12.9682704,
"lng": 74.8065197
},
"weekly_sum": 5307
},
{
"coordinates": {
"lat": 12.9883174,
"lng": 74.8005921
},
"weekly_sum": 3800
},
{
"coordinates": {
"lat": 13.0223759,
"lng": 74.8079575
},
"weekly_sum": 5655
},
{
"coordinates": {
"lat": 12.9894559,
"lng": 74.8015439
},
"weekly_sum": 3798
},
{
"coordinates": {
"lat": 12.9743232,
"lng": 74.8036651
},
"weekly_sum": 4279
},
{
"coordinates": {
"lat": 12.9815466,
"lng": 74.8227607
},
"weekly_sum": 4314
},
{
"coordinates": {
"lat": 13.0010366,
"lng": 74.8260901
},
"weekly_sum": 5191
}
]
return response


@app.route("/api/popular_times_test", methods=['GET'])
def weight_gen():
weights = []
pop_time = popular_times()

for index in range(len(pop_time)):
pop_time_temp = pop_time[index]
weight = {
"coordinates": pop_time_temp["coordinates"],
"weekly_sum": 0
}

for day_data in pop_time_temp["populartimes"]:
data_values = day_data["data"]
day_sum = sum(data_values)
weight["weekly_sum"] += day_sum

weights.append(weight)

return jsonify(weights)


def popular_times():
[p1, p2] = geocode()
response = populartimes.get(API_KEY, ["bar"], p1, p2)
return response

def geocode():
gmaps = googlemaps.Client(key=API_KEY)
geocode_response = gmaps.geocode(address="Surathkal")
geocode_response_dict = geocode_response[0]

northeast = geocode_response_dict["geometry"]["bounds"]["northeast"]
southwest = geocode_response_dict["geometry"]["bounds"]["southwest"]

p1 = (southwest["lat"], southwest["lng"])
p2 = (northeast["lat"], northeast["lng"])

return [p1, p2]

if __name__ == "__main__":
app.run(debug=True)
Loading