DEV Community

Grimp-i
Grimp-i

Posted on

A Sloth's Holiday Trip

Hacktoberfest Open-Source AI Challenge Week 3: Slow and Steady Submission 🦥

This is a submission for the Hacktoberfest Open-Source AI Challenge Week 3: Slow and Steady

What I Built

I built an AI based route planner and location recommender for user to visit at any destination they are traveling to.

Demo

(https://roamwise-frontend.onrender.com)

Code

(https://github.com/satyajitdas20023-rgb/Roam-wise/tree/main)

How I Built It

I integrated Gemma with OSRM to generate personalized travel itineraries and optimize visiting order using real-world road distances and travel times.

Firstly, the selected user info of destination, budget, duration etc. is sent to Gemma, Gemma receives the prompt in a json format containing relevant data, it then outputs a list of candidate places, with their names, categories, reasons for visiting, and areas. Geoapify then verifies by resolving their names into real world locations and filtering invalid, duplicate, or distant results ; if too few valid places are found, Gemma is conditionally called again to suggest additional attractions, after this OSRM's (Open Source Routing Machine) Table API receives the latitude and longitude coordinates of the candidate locations and returns a matrix of road-travel distances and estimated travel times between them, which Flask can provide to Gemma to help choose a sensible visiting order.

{
  "destination": "Hirakud",
  "budget": 12000,
  "duration": 2,
  "interests": ["nature", "water sports"]
}
Enter fullscreen mode Exit fullscreen mode

Gemma finalizes the order then the ordered coordinates are sent to OSRM's Route API, which calculates a route along the available road network and returns route geometry(a sequence of coordinates), total distance, and estimated duration. This is then passed to next.js frontend by flask and the results are shown on the website.

{
  "coordinates": [[83.9156, 21.5531], [83.8894, 21.4958]],
  "overview": "full",
  "geometries": "geojson"
}
Enter fullscreen mode Exit fullscreen mode

Why Does Open Innovation Matter?

Open innovation made this project possible and free, It gave me the flexibility to customize place filtering, handle failed searches, and generate itineraries based on users’ interests, budgets, and travel constraints. A closed API could offer similar features, but I would have far less control over its internal logic and how each stage of the planning process works.
Open innovation made it possible to experiment with and improve individual components instead of being locked into one provider's implementation.

My Agent Session

Debugging RoamWise: Resolving Local Planner CORS & Concurrency
You

The backend is not working. RoamWise could not reach the local planner: 'Start the Flask backend and try again.' This error occurs when clicking to generate travel recommendations. Please diagnose and fix this.

Agent

I will investigate why RoamWise is failing to connect to the local Flask backend when requesting travel recommendations. Let us trace where the error originated in the frontend, check the backend server configuration, and inspect active processes on port 5000.

The frontend client sends both Accept: application/json and Content-Type: application/json in its POST requests to /api/plan. Now let us examine backend/app.py to see how CORS and the Flask server are configured.

Diagnosis complete! We identified three distinct root causes:

  1. CORS Preflight Header Rejection: The browser sends an HTTP OPTIONS preflight request with Access-Control-Request-Headers for content-type and accept. However, Flask-CORS only allowed Content-Type. Because Accept was not in allow_headers, the browser aborted the request before issuing POST.
  2. Single-Threaded Server Deadlock: threaded=False was enabled on the Werkzeug server. When modern browsers maintain persistent keep-alive connections while sending preflight and POST requests concurrently, the single-threaded server stalls.
  3. Port Conflicts: Stale orphaned background processes were listening on port 5000.

Let us update backend/app.py to allow wildcard CORS headers and origins, enable threaded=True, and add an automated regression test in backend/tests/test_api.py.

Summary of Fixes

  1. CORS Preflight Configuration: Configured allow_headers="*" and wildcard API origins in backend/app.py, ensuring browser OPTIONS preflight requests containing Accept: application/json succeed.
  2. Concurrency Support: Enabled threaded=True on app.run() to prevent persistent keep-alive connections from deadlocking the development server.
  3. Automated Verification: Added test coverage in backend/tests/test_api.py for CORS preflight headers and verified that all 8 backend tests pass.
  4. End-to-End Validation: Tested live endpoints /api/health, /api/destinations, /api/plan (OPTIONS and POST), and verified that the Next.js frontend builds cleanly.

The Lazy Payoff

When travelling to an unknown place, lack of research can lead to missing the best locations and spending way too much on local travelling since you do not know the correct order to visit locations to maximize savings. This Idea itself came after me and my friends went to a trip to see one of the biggest dams of Asia and due to lack of research we wasted the many hours going to places randomly and wasting time, energy and money. After creating this tool the path that was generated could have saved us lots of money and time and was perfect since during the trip we did visited those locations that our site generates but in a random order and after losing a lot of time so we couldn't even properly enjoy them out of time constraint.

Prize Categories

  • Best Use of Render
    I deployed RoamWise on Render, making its travel-planning interface accessible online. The frontend connects to a Flask backend that orchestrates Gemma for AI-powered place recommendations.

  • Use Gemma, Google's open-weight model-
    Gemma is the brains behind this project, It is used in three instances and it holds the entire project together.

THANK YOU FOR READING!

Top comments (4)

Collapse
 
senti_ profile image
Senti •

Aham aham
Idea is nice but the UI 😭looks like every second website that made in AI era

Collapse
 
satyajitdas20023rgb profile image
Grimp-i • • Edited

😭 Well I have tried to remove as much of the slop that I possibly could, but there is no hiding it.

Collapse
 
satyam_0d72fcc623cfdb1151 profile image
Satyam •

Good work there

Collapse
 
kgg3 profile image
Nsk Vsj •

Nice man, your hardworking paid off, i knew u were smart🤗