36 | );
37 | }
38 |
--------------------------------------------------------------------------------
/ayuvritt/README.md:
--------------------------------------------------------------------------------
1 | This is a [Next.js](https://nextjs.org) project bootstrapped with [`create-next-app`](https://nextjs.org/docs/app/api-reference/cli/create-next-app).
2 |
3 | ## Getting Started
4 |
5 | First, run the development server:
6 |
7 | ```bash
8 | npm run dev
9 | # or
10 | yarn dev
11 | # or
12 | pnpm dev
13 | # or
14 | bun dev
15 | ```
16 |
17 | Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
18 |
19 | You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file.
20 |
21 | This project uses [`next/font`](https://nextjs.org/docs/app/building-your-application/optimizing/fonts) to automatically optimize and load [Geist](https://vercel.com/font), a new font family for Vercel.
22 |
23 | ## Learn More
24 |
25 | To learn more about Next.js, take a look at the following resources:
26 |
27 | - [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
28 | - [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.
29 |
30 | You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js) - your feedback and contributions are welcome!
31 |
32 | ## Deploy on Vercel
33 |
34 | The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.
35 |
36 | Check out our [Next.js deployment documentation](https://nextjs.org/docs/app/building-your-application/deploying) for more details.
37 |
--------------------------------------------------------------------------------
/ayuvritt/src/components/leaves.tsx:
--------------------------------------------------------------------------------
1 | const Leaf1 = () => (
2 |
8 | );
9 |
10 | const Leaf2 = () => (
11 |
17 | );
18 |
19 | const Leaf3 = () => (
20 |
30 | );
31 |
32 | const SmallLeaf = () => (
33 |
39 | );
40 |
41 | export { Leaf1, Leaf2, Leaf3, SmallLeaf };
42 |
--------------------------------------------------------------------------------
/ayuvritt/src/components/footer.tsx:
--------------------------------------------------------------------------------
1 | import { SmallLeaf } from "./leaves";
2 |
3 | export function Footer() {
4 | return (
5 |
41 | );
42 | }
43 |
--------------------------------------------------------------------------------
/ayuvritt/src/app/naturopathy/page.tsx:
--------------------------------------------------------------------------------
1 | "use client";
2 |
3 | import { BackButton } from "@/components/back-button";
4 | import { Leaf1, Leaf2, SmallLeaf } from "@/components/leaves";
5 | import Image from "next/image";
6 | import Link from "next/link";
7 | import { RoutineIcon, ChecklistIcon } from "@/components/naturopathy-icons";
8 |
9 | export default function NaturopathyPage() {
10 | return (
11 |
183 | Meditation is a powerful practice that can help reduce stress,
184 | improve focus, and promote overall well-being. Enter your specific
185 | concern above to receive personalized meditation recommendations.
186 |
362 | Remaining monthly cost same as montly expenses.
363 |
364 |
365 |
366 | {/* Notes Section */}
367 |
368 |
Notes
369 |
370 |
371 | •
372 |
373 | Reusable Items: Items like the neti pot, yoga
374 | mat, juicer, and steam inhaler are one-time purchases and may
375 | not need to be replaced monthly.
376 |
377 |
378 |
379 | •
380 |
381 | Seasonal Variations: The cost of fresh fruits
382 | and vegetables may vary depending on the season and location.
383 |
384 |
385 |
386 | •
387 |
388 | Optional Items: Essential oils, meditation
389 | cushions, and herbal teas are optional and can be skipped if not
390 | needed.
391 |
392 |
21 |
22 | {/* Decorative Leaves - Right Side */}
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 | {/* Small Floating Leaves */}
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 | {/* Header Section */}
53 |
54 | (window.location.href = "/")}
60 | />
61 |
62 |
63 |
64 | Understanding AyuVritt
65 |
66 |
67 | Discover how we're revolutionizing healthcare by combining
68 | ancient Ayurvedic wisdom with modern scientific validation.
69 |
70 |
71 |
72 | {/* Information Grid */}
73 |
74 |
75 | {/* Subtle corner leaf decoration */}
76 |
77 |
78 |
79 |
80 |
81 | Our Mission
82 |
83 |
84 | We aim to bridge the gap between traditional Ayurvedic medicine
85 | and modern healthcare through advanced AI-driven analysis and
86 | scientific validation.
87 |
88 |
89 |
90 |
103 | Validate traditional formulations with modern science
104 |
105 |
106 |
119 | Enhance the credibility of Ayurvedic medicine
120 |
290 | Join us in revolutionizing healthcare by combining the best of
291 | both worlds.
292 |
293 |
301 |
302 |
303 |
304 |
305 | );
306 | }
307 |
--------------------------------------------------------------------------------
/api/datasets/meditation.csv:
--------------------------------------------------------------------------------
1 | Name,Description,Duration,Instructions,,,,,,,,,Issue
2 | Mindfulness Meditation,Focuses on being present in the moment and non-judgmentally observing your thoughts and surroundings.,10-30 minutes,"Sit in a comfortable position with your eyes closed and focus on your breath. When your mind wanders, gently bring your attention back to your breath.",,,,,,,,,Stress and Anxiety
3 | Transcendental Meditation,Uses a mantra to help quiet the mind and achieve a deep state of relaxation.,"20 minutes, twice a day",Sit in a comfortable position with your eyes closed and repeat a mantra silently to yourself. Allow your mind to become absorbed in the mantra.,,,,,,,,,Insomnia
4 | Loving-Kindness Meditation,Involves generating feelings of love and compassion towards oneself and others.,10-30 minutes,Sit in a comfortable position with your eyes closed and repeat phrases of loving-kindness to yourself and others.,,,,,,,,,Lack of Focus
5 | Body Scan Meditation,"Involves systematically bringing attention to different parts of the body, noticing sensations and relaxing tension.",10-30 minutes,Lie down or sit in a comfortable position with your eyes closed. Focus on each part of your body starting from your toes and working your way up to the top of your head.,,,,,,,,,Low Self-Esteem
6 | Vipassana Meditation,Involves observing the breath and bodily sensations to gain insight into the nature of reality.,30-60 minutes,Sit in a comfortable position with your eyes closed and observe your breath and bodily sensations without judgement.,,,,,,,,,Chronic Pain
7 | Zen Meditation,"Involves sitting in silence and focusing on the breath, often with the support of a teacher or group.",20-40 minutes,Sit in a comfortable position with your eyes half-closed and focus on your breath. Follow the instructions of your teacher.,,,,,,,,,Emotional Trauma
8 | Chakra Meditation,Involves focusing on each of the body's energy centers to balance and align them.,10-30 minutes,"Sit in a comfortable position with your eyes closed and focus on each chakra, starting from the base of your spine and working your way up to the crown of your head.",,,,,,,,,Anger and Frustration
9 | Mantra Meditation,Involves repeating a word or phrase to focus the mind and achieve a calm state.,10-30 minutes,Sit in a comfortable position with your eyes closed and repeat a mantra silently to yourself. Allow your mind to become absorbed in the mantra.,,,,,,,,,Depression
10 | Breath Counting Meditation,Involves counting each breath to maintain focus and concentration.,10-30 minutes,Sit in a comfortable position with your eyes closed and count each inhale and exhale up to 10. Start over at 1 if you get distracted.,,,,,,,,,Overthinking
11 | Walking Meditation,"Involves walking slowly and mindfully, focusing on each step and the sensations in the body.",10-30 minutes,"Find a quiet place to walk slowly. Focus on each step, the sensations in your feet and legs, and the environment around you.",,,,,,,,,Lack of Energy
12 | Visualization Meditation,Involves creating a mental image or scenario to promote relaxation and positive emotions.,10-30 minutes,Sit in a comfortable position with your eyes closed and visualize a peaceful scene or positive outcome. Engage all your senses in the visualization.,,,,,,,,,Spiritual Disconnection
13 | Yoga Nidra Meditation,Involves lying down and systematically relaxing different parts of the body to achieve a deep state of relaxation.,20-40 minutes,Lie down in a comfortable position and follow the instructions of the teacher as they guide you through relaxation of each part of the body.,,,,,,,,,Relationship Issues
14 | Sound Meditation,Involves focusing on a particular sound or a series of sounds to promote relaxation.,10-30 minutes,"Sit in a comfortable position with your eyes closed and focus on a particular sound, such as chanting, a gong, or a singing bowl.",,,,,,,,,Procrastination
15 | Qi Gong Meditation,"Involves combining movement, breath, and visualization to improve physical and mental health.",10-30 minutes,"Follow the movements and breathing exercises of a Qi Gong teacher or video, and visualize the flow of energy in your body.",,,,,,,,,Grief and Loss
16 | Kundalini Meditation,"Involves combining breathwork, movement, and mantra to awaken the energy at the base of the spine and raise it up through the chakras.",10-30 minutes,"Follow the instructions of a Kundalini teacher or video, combining breathwork, movement, and mantra.",,,,,,,,,Lack of Motivation
17 | Silent Meditation,Involves sitting in silence and observing the mind without judgment.,10-60 minutes,Sit in a comfortable position with your eyes closed and observe your thoughts and sensations without getting caught up in them.,,,,,,,,,Physical Tension
18 | Open Monitoring Meditation,Involves observing one's thoughts and feelings without judgment and allowing them to come and go.,10-30 minutes,Sit in a comfortable position with your eyes closed and observe your thoughts and feelings without trying to change or control them.,,,,,,,,,Overwhelm
19 | Focused Attention Meditation,Involves focusing on a specific object or sound to maintain concentration and develop awareness.,10-30 minutes,"Sit in a comfortable position with your eyes closed and focus on a specific object or sound, such as a candle flame or the sound of a bell.",,,,,,,,,Loneliness
20 | Metta Meditation,Involves cultivating feelings of loving-kindness and compassion towards oneself and others.,10-30 minutes,Sit in a comfortable position with your eyes closed and repeat phrases of loving-kindness to yourself and others.,,,,,,,,,Lack of Creativity
21 | Body Awareness Meditation,Involves focusing on the sensations in the body to develop awareness and relaxation.,10-30 minutes,"Sit in a comfortable position with your eyes closed and focus on the sensations in your body, such as warmth, tingling, or tension.",,,,,,,,,Fear and Uncertainty
22 | Compassion Meditation,Involves cultivating feelings of empathy and compassion towards oneself and others.,10-30 minutes,Sit in a comfortable position with your eyes closed and visualize yourself and others experiencing happiness and freedom from suffering.,,,,,,,,,Digestive Issues
23 | Breath Awareness and Body Scan Meditation,Involves combining breath awareness and body scan techniques to promote relaxation and awareness.,10-30 minutes,Lie down or sit in a comfortable position with your eyes closed and focus on your breath and the sensations in your body.,,,,,,,,,Lack of Patience
24 | Progressive Muscle Relaxation,Involves tensing and relaxing different muscle groups to promote relaxation and reduce tension.,10-30 minutes,Lie down in a comfortable position and systematically tense and then release each muscle group in your body.,,,,,,,,,Burnout
25 | Guided Meditation,Involves following the instructions of a teacher or audio recording to promote relaxation and awareness.,10-30 minutes,Sit in a comfortable position with your eyes closed and follow the instructions of the teacher or recording.,,,,,,,,,Negative Self-Talk
26 | Mindful Eating Meditation,"Involves eating slowly and mindfully, focusing on the taste, texture, and sensations of the food.",10-30 minutes,"Choose a food to eat, sit in a quiet place, and focus on the taste, texture, and sensations of each bite.",,,,,,,,,Lack of Connection with Nature
27 | Mindful Breathing Meditation,Involves focusing on the breath to promote relaxation and develop awareness.,10-30 minutes,"Sit in a comfortable position with your eyes closed and focus on your breath, observing each inhale and exhale.",,,,,,,,,Difficulty Letting Go
28 | Compassionate Mind Meditation,Involves cultivating feelings of compassion and empathy towards oneself and others.,10-30 minutes,Sit in a comfortable position with your eyes closed and visualize yourself and others experiencing happiness and freedom from suffering.,,,,,,,,,Lack of Gratitude
29 | Spiritual Meditation,Involves connecting with a higher power or spiritual practice to promote relaxation and inner peace.,10-30 minutes,Sit in a comfortable position with your eyes closed and connect with your higher power or spiritual practice through prayer or visualization.,,,,,,,,,Difficulty Sleeping
30 | Chanting Meditation,Involves repeating a sound or phrase to promote relaxation and focus.,10-30 minutes,"Sit in a comfortable position with your eyes closed and repeat a sound or phrase, such as 'Om' or 'peace'.",,,,,,,,,Lack of Self-Compassion
31 | Third Eye Meditation,Involves focusing on the area between the eyebrows to promote relaxation and develop intuition.,10-30 minutes,"Sit in a comfortable position with your eyes closed and focus on the area between your eyebrows, imagining a light or energy there.",,,,,,,,,Difficulty Managing Emotions
32 | Mudra Meditation,Involves using hand gestures to promote relaxation and focus.,10-30 minutes,"Sit in a comfortable position with your eyes closed and use a specific hand gesture, or mudra, to promote relaxation and focus.",,,,,,,,,Lack of Balance in Life
33 | Self-Inquiry Meditation,Involves asking oneself open-ended questions to promote self-awareness and understanding.,10-30 minutes,"Sit in a comfortable position with your eyes closed and ask yourself open-ended questions, such as 'Who am I?' or 'What do I really want?'.",,,,,,,,,Difficulty with Decision-Making
34 | Inner Light Meditation,Involves focusing on a bright light within oneself to promote relaxation and inner peace.,10-30 minutes,"Sit in a comfortable position with your eyes closed and imagine a bright light within yourself, focusing on its warmth and energy.",,,,,,,,,Lack of Inner Peace
35 | Mindful Movement Meditation,Involves combining movement and mindfulness to promote relaxation and awareness.,10-30 minutes,"Engage in a gentle movement practice, such as yoga or tai chi, while maintaining awareness of your body and breath.",,,,,,,,,Difficulty with Forgiveness
36 | Gratitude Meditation,Involves focusing on feelings of gratitude and appreciation to promote positivity and well-being.,10-30 minutes,"Sit in a comfortable position with your eyes closed and focus on things you are grateful for, allowing yourself to feel the emotions associated with gratitude.",,,,,,,,,Lack of Positivity
37 | Affirmation Meditation,Involves repeating positive affirmations to promote self-confidence and positivity.,10-30 minutes,"Sit in a comfortable position with your eyes closed and repeat positive affirmations to yourself, such as 'I am worthy' or 'I am capable'.",,,,,,,,,Difficulty with Self-Acceptance
38 | Compassionate Body Scan Meditation,Involves combining body scan and compassionate meditation techniques to promote relaxation and self-compassion.,10-30 minutes,"Lie down or sit in a comfortable position with your eyes closed and focus on each part of your body, sending feelings of love and compassion towards yourself.",,,,,,,,,Lack of Connection with Others
39 | Breath and Sound Meditation,Involves combining breath and sound awareness to promote relaxation and focus.,10-30 minutes,"Sit in a comfortable position with your eyes closed and focus on your breath and a specific sound, such as white noise or a mantra.",,,,,,,,,Difficulty with Relaxation
40 | Morning Meditation,Involves starting the day with a meditation practice to promote focus and positivity.,10-30 minutes,Sit in a comfortable position with your eyes closed and start the day with a meditation practice of your choice.,,,,,,,,,Lack of Clarity
41 | Evening Meditation,Involves ending the day with a meditation practice to promote relaxation and restful sleep.,10-30 minutes,Sit in a comfortable position with your eyes closed and end the day with a meditation practice of your choice.,,,,,,,,,Difficulty with Self-Reflection
42 | Breath and Body Awareness Meditation,Involves focusing on the breath and sensations in the body to promote relaxation and awareness.,10-30 minutes,Sit in a comfortable position with your eyes closed and focus on your breath and the sensations in your body.,,,,,,,,,Lack of Energy Flow
43 | Mindful Communication Meditation,Involves practicing mindful communication with oneself and others to promote understanding and connection.,10-30 minutes,Sit in a comfortable position with your eyes closed and visualize communicating mindfully with yourself and others.,,,,,,,,,Difficulty with Mindful Eating
44 | Labyrinth Meditation,Involves walking a labyrinth to promote relaxation and focus.,10-30 minutes,"Find a labyrinth and walk it slowly and mindfully, focusing on each step and the path ahead.",,,,,,,,,Lack of Emotional Balance
45 | Color Visualization Meditation,Involves visualizing different colors and their associated emotions to promote relaxation and positivity.,10-30 minutes,"Sit in a comfortable position with your eyes closed and visualize different colors, focusing on the emotions associated with each color.",,,,,,,,,Difficulty with Self-Worth
46 | Breath and Loving-Kindness Meditation,Involves combining breath awareness and loving-kindness meditation to promote relaxation and compassion.,10-30 minutes,"Sit in a comfortable position with your eyes closed and focus on your breath, while also sending feelings of love and compassion towards yourself and others.",,,,,,,,,Lack of Connection with Higher Self
47 | Gratitude Journaling Meditation,Involves journaling about things you are grateful for to promote positivity and well-being.,10-30 minutes,"Write in a journal about things you are grateful for, focusing on the emotions associated with gratitude.",,,,,,,,,Difficulty with Letting Go of Control
48 | Sitting with Difficult Emotions Meditation,Involves sitting with uncomfortable emotions to promote self-awareness and acceptance.,10-30 minutes,Sit in a comfortable position with your eyes closed and allow yourself to feel difficult emotions without judgement or resistance.,,,,,,,,,Lack of Joy
49 | Mindful Walking Meditation,"Involves walking slowly and mindfully, focusing on each step and the environment around you.",10-30 minutes,"Find a quiet place to walk slowly, focusing on each step and the environment around you.",,,,,,,,,Difficulty with Self-Discipline
50 | Gratitude Body Scan Meditation,Involves combining body scan and gratitude techniques to promote relaxation and positivity.,10-30 minutes,"Lie down or sit in a comfortable position with your eyes closed and focus on each part of your body, while also feeling gratitude for each part.",,,,,,,,,Lack of Inner Strength
51 | Breath and Body Awareness in Nature Meditation,Involves combining breath and body awareness with being in nature to promote relaxation and connection.,10-30 minutes,"Find a quiet place in nature to sit or walk, focusing on your breath and the sensations in your body.",,,,,,,,,Difficulty with Acceptance
52 | Breath and Loving-Kindness in Nature Meditation,Involves combining breath awareness and loving-kindness meditation with being in nature to promote relaxation and connection.,10-30 minutes,"Find a quiet place in nature to sit or walk, focusing on your breath and sending feelings of love and compassion towards yourself and others.",,,,,,,,,Lack of Connection with the Present Moment
53 | Compassionate Forgiveness Meditation,Involves cultivating feelings of compassion and forgiveness towards oneself and others.,10-30 minutes,Sit in a comfortable position with your eyes closed and visualize yourself and others experiencing forgiveness and freedom from past hurt.,,,,,,,,,Difficulty with Emotional Release
54 | Breath and Body Awareness with Affirmations Meditation,Involves combining breath and body awareness with positive affirmations to promoterelaxation and positivity.,10-30 minutes,"Sit in a comfortable position with your eyes closed and focus on your breath and the sensations in your body, while also repeating positive affirmations to yourself.",,,,,,,,,Lack of Inner Calm
55 | Body Awareness and Gratitude Meditation,Involves combining body awareness and gratitude techniques to promote relaxation and positivity.,10-30 minutes,"Lie down or sit in a comfortable position with your eyes closed and focus on each part of your body, while also feeling gratitude for each part.",,,,,,,,,Difficulty with Self-Expression
56 | Breath and Open Awareness Meditation,Involves focusing on the breath and open awareness of thoughts and sensations to promote relaxation and mindfulness.,10-30 minutes,"Sit in a comfortable position with your eyes closed and focus on your breath, while also allowing thoughts and sensations to come and go without judgement.",,,,,,,,,Lack of Connection with the Body
57 | Singing Bowl Meditation,Involves listening to the sound of a singing bowl to promote relaxation and focus.,10-30 minutes,"Sit in a comfortable position with your eyes closed and listen to the sound of a singing bowl, focusing on the vibrations and sensations in your body.",,,,,,,,,Difficulty with Self-Love
58 | Body Scan and Loving-Kindness Meditation,Involves combining body scan and loving-kindness techniques to promote relaxation and compassion.,10-30 minutes,"Lie down or sit in a comfortable position with your eyes closed and focus on each part of your body, while also sending feelings of love and compassion towards yourself and others.",,,,,,,,,Lack of Connection with the Universe
59 | Breath and Movement Meditation,Involves combining breath awareness and gentle movement to promote relaxation and mindfulness.,10-30 minutes,"Sit or stand in a comfortable position and focus on your breath, while also gently moving your body in a way that feels good.",,,,,,,,,Difficulty with Emotional Healing
60 | Gratitude Visualization Meditation,Involves visualizing things you are grateful for to promote positivity and well-being.,10-30 minutes,"Sit in a comfortable position with your eyes closed and visualize things you are grateful for, focusing on the emotions associated with gratitude.",,,,,,,,,Lack of Connection with the Breath
61 | Loving-Kindness Meditation,Involves sending feelings of love and compassion towards oneself and others to promote well-being.,10-30 minutes,Sit in a comfortable position with your eyes closed and focus on sending feelings of love and compassion towards yourself and others.,,,,,,,,,Difficulty with Self-Awareness
62 | Breath and Body Awareness with Mantra Meditation,Involves combining breath and body awareness with a mantra to promote relaxation and focus.,10-30 minutes,"Sit in a comfortable position with your eyes closed and focus on your breath and the sensations in your body, while also repeating a mantra to yourself.",,,,,,,,,Lack of Connection with the Heart
63 | Relaxation Meditation,Involves promoting relaxation in the body and mind through various techniques such as progressive muscle relaxation and visualization.,10-30 minutes,Lie down or sit in a comfortable position with your eyes closed and practice various relaxation techniques such as progressive muscle relaxation and visualization.,,,,,,,,,Difficulty with Emotional Balance
64 | Self-Compassion Meditation,Involves cultivating feelings of self-compassion and acceptance to promote well-being.,10-30 minutes,"Sit in a comfortable position with your eyes closed and focus on sending feelings of love, compassion, and acceptance towards yourself.",,,,,,,,,Lack of Connection with the Mind
65 | Breath and Loving-Kindness in Community Meditation,Involves combining breath awareness and loving-kindness meditation with the idea of community to promote connection and positivity.,10-30 minutes,"Sit in a comfortable position with your eyes closed and focus on your breath, while also sending feelings of love and compassion towards yourself and the community.",,,,,,,,,Difficulty with Self-Reflection
66 | Gratitude and Loving-Kindness Meditation,Involves combining gratitude and loving-kindness techniques to promote positivity and well-being.,10-30 minutes,Sit in a comfortable position with your eyes closed and focus on sending feelings of love and gratitude towards yourself and others.,,,,,,,,,Lack of Connection with the Soul
67 | Breath and Body Awareness with Chakra Meditation,Involves combining breath and body awareness with the concept of chakras to promote relaxation and balance.,10-30 minutes,"Sit in a comfortable position with your eyes closed and focus on your breath and the sensations in your body, while also visualizing the energy centers in your body known as chakras.",,,,,,,,,Difficulty with Emotional Clarity
68 | Mindful Eating Meditation,Involves practicing mindfulness while eating to promote awareness and enjoyment of food.,10-30 minutes,"Choose a food to eat mindfully, focusing on the taste, texture, and sensations in your body while eating.",,,,,,,,,Lack of Connection with the Earth
69 | Compassionate Self-Talk Meditation,Involves cultivating positive self-talk and self-compassion to promote well-being.,10-30 minutes,Sit in a comfortable position with your eyes closed and focus on cultivating positive self-talk and sending feelings of self-compassion towards yourself.,,,,,,,,,Difficulty with Self-Acceptance
--------------------------------------------------------------------------------
/ayuvritt/src/app/medicine-recommendations/page.tsx:
--------------------------------------------------------------------------------
1 | "use client";
2 |
3 | import { useState, useEffect } from "react";
4 | import Image from "next/image";
5 | import { Leaf1, Leaf2 } from "@/components/leaves";
6 | import { BackButton } from "@/components/back-button";
7 |
8 | interface LocationResult {
9 | display_name: string;
10 | place_id: number;
11 | }
12 |
13 | interface Doctor {
14 | name: string;
15 | distance: number;
16 | address: string;
17 | type: string;
18 | }
19 |
20 | interface NominatimPlace {
21 | display_name: string;
22 | importance: number;
23 | type: string;
24 | lat: string;
25 | lon: string;
26 | }
27 |
28 | interface Coordinates {
29 | lat: number;
30 | lon: number;
31 | }
32 |
33 | export default function Start() {
34 | const [showResult, setShowResult] = useState(false);
35 | const [medicineInfo, setMedicineInfo] = useState("");
36 | const [diseaseInfo, setDiseaseInfo] = useState("");
37 | const [loading, setLoading] = useState(false);
38 | const [formData, setFormData] = useState({
39 | name: "",
40 | age: "",
41 | location: "",
42 | issues: "",
43 | });
44 | const [loadingLocation, setLoadingLocation] = useState(false);
45 | const [locationError, setLocationError] = useState("");
46 | const [searchResults, setSearchResults] = useState([]);
47 | const [showSuggestions, setShowSuggestions] = useState(false);
48 | const [doctors, setDoctors] = useState([]);
49 | const [loadingDoctors, setLoadingDoctors] = useState(false);
50 | const [showDoctors, setShowDoctors] = useState(false);
51 |
52 | useEffect(() => {
53 | const handleClickOutside = (event: MouseEvent) => {
54 | if (!(event.target as HTMLElement).closest("#location")) {
55 | setShowSuggestions(false);
56 | }
57 | };
58 |
59 | document.addEventListener("mousedown", handleClickOutside);
60 | return () => document.removeEventListener("mousedown", handleClickOutside);
61 | }, []);
62 |
63 | const getMedicineInfo = async (
64 | symptoms: string
65 | ): Promise<[string | null, string | null, string | null]> => {
66 | try {
67 | const response = await fetch(
68 | `${
69 | process.env.NEXT_PUBLIC_API_URL
70 | }/getMedicine?symptoms=${encodeURIComponent(symptoms)}`
71 | );
72 | const data = await response.json();
73 | if (data.error) {
74 | return [null, null, data.error];
75 | }
76 | return [data.medicine, data.disease, null];
77 | // eslint-disable-next-line @typescript-eslint/no-explicit-any
78 | } catch (error: any) {
79 | return [null, null, error.toString()];
80 | }
81 | };
82 | let disease, medicine;
83 | const handleSubmit = async (e: React.FormEvent) => {
84 | e.preventDefault();
85 | setLoading(true);
86 | try {
87 | const res = await getMedicineInfo(formData.issues.trim());
88 | medicine = res[0];
89 | disease = res[1];
90 | const error = res[2];
91 | if (error) {
92 | alert(error);
93 | setLoading(false);
94 | return;
95 | }
96 | setMedicineInfo(medicine || "");
97 | setDiseaseInfo(disease || "");
98 | } catch (error) {
99 | console.error("Error in submission:", error);
100 | setMedicineInfo("paracetamol"); // Default fallback
101 | setDiseaseInfo("cold"); // Default fallback
102 | }
103 | setLoading(false);
104 | setShowResult(true);
105 | };
106 |
107 | const getCurrentLocation = () => {
108 | setLoadingLocation(true);
109 | setLocationError("");
110 |
111 | if (!navigator.geolocation) {
112 | setLocationError("Geolocation is not supported by your browser");
113 | setLoadingLocation(false);
114 | return;
115 | }
116 |
117 | navigator.geolocation.getCurrentPosition(
118 | async (position) => {
119 | try {
120 | const response = await fetch(
121 | `https://nominatim.openstreetmap.org/reverse?format=json&lat=${position.coords.latitude}&lon=${position.coords.longitude}`
122 | );
123 | const data = await response.json();
124 |
125 | const address = data.display_name;
126 | setFormData((prev) => ({
127 | ...prev,
128 | location: address,
129 | }));
130 | } catch (error) {
131 | setLocationError("Failed to get location details" + error);
132 | }
133 | setLoadingLocation(false);
134 | },
135 | (error) => {
136 | setLocationError(
137 | error.code === 1
138 | ? "Please allow location access"
139 | : "Unable to get your location"
140 | );
141 | setLoadingLocation(false);
142 | }
143 | );
144 | };
145 |
146 | const searchLocation = async (query: string) => {
147 | if (query.length < 3) {
148 | setSearchResults([]);
149 | return;
150 | }
151 |
152 | try {
153 | const response = await fetch(
154 | `https://nominatim.openstreetmap.org/search?format=json&q=${encodeURIComponent(
155 | query
156 | )}&limit=5`
157 | );
158 | const data = await response.json();
159 | setSearchResults(data);
160 | setShowSuggestions(true);
161 | } catch (error) {
162 | console.error("Search error:", error);
163 | }
164 | };
165 |
166 | const calculateDistance = (
167 | point1: Coordinates,
168 | point2: Coordinates
169 | ): number => {
170 | const R = 6371; // Earth's radius in km
171 | const dLat = ((point2.lat - point1.lat) * Math.PI) / 180;
172 | const dLon = ((point2.lon - point1.lon) * Math.PI) / 180;
173 | const a =
174 | Math.sin(dLat / 2) * Math.sin(dLat / 2) +
175 | Math.cos((point1.lat * Math.PI) / 180) *
176 | Math.cos((point2.lat * Math.PI) / 180) *
177 | Math.sin(dLon / 2) *
178 | Math.sin(dLon / 2);
179 | const c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
180 | return R * c; // Distance in km
181 | };
182 |
183 | const findNearbyDoctors = async () => {
184 | setLoadingDoctors(true);
185 | try {
186 | const locationQuery = encodeURIComponent(formData.location);
187 | const geoResponse = await fetch(
188 | `https://nominatim.openstreetmap.org/search?format=json&q=${locationQuery}`
189 | );
190 | const geoData = await geoResponse.json();
191 |
192 | if (geoData.length > 0) {
193 | const userLocation = {
194 | lat: parseFloat(geoData[0].lat),
195 | lon: parseFloat(geoData[0].lon),
196 | };
197 |
198 | // Try with small radius first
199 | let viewboxSize = 0.1;
200 | let data = [];
201 |
202 | // Keep expanding search radius until we find results or hit max radius
203 | while (data.length === 0 && viewboxSize <= 2) {
204 | const response = await fetch(
205 | `https://nominatim.openstreetmap.org/search?` +
206 | `format=json&` +
207 | // Modified search query to be more specific
208 | `q=ayurvedic&` +
209 | `viewbox=${userLocation.lon - viewboxSize},${
210 | userLocation.lat - viewboxSize
211 | },${userLocation.lon + viewboxSize},${
212 | userLocation.lat + viewboxSize
213 | }&` +
214 | `bounded=1&limit=50&` + // Increased limit
215 | `dedupe=1&` + // Remove duplicates
216 | `category=healthcare,medical` // Added category filter
217 | );
218 | const responseData = await response.json();
219 | data = Array.isArray(responseData) ? responseData : [];
220 |
221 | if (data.length === 0) {
222 | // Try alternative search if first attempt returns no results
223 | const altResponse = await fetch(
224 | `https://nominatim.openstreetmap.org/search?` +
225 | `format=json&` +
226 | `amenity=hospital,clinic,doctors,healthcare&` +
227 | `lat=${userLocation.lat}&` +
228 | `lon=${userLocation.lon}&` +
229 | `radius=${viewboxSize * 111000}&` + // Convert degrees to meters (roughly)
230 | `limit=50`
231 | );
232 | const altData = await altResponse.json();
233 | data = Array.isArray(altData) ? altData : [];
234 | }
235 |
236 | viewboxSize *= 2;
237 | }
238 |
239 | const nearbyDoctors = data
240 | .filter(
241 | (place: NominatimPlace) =>
242 | place.display_name.toLowerCase().includes("hospital") ||
243 | place.display_name.toLowerCase().includes("clinic") ||
244 | place.display_name.toLowerCase().includes("medical") ||
245 | place.display_name.toLowerCase().includes("health") ||
246 | place.type === "hospital" ||
247 | place.type === "clinic"
248 | )
249 | .map((place: NominatimPlace) => {
250 | const distance = calculateDistance(userLocation, {
251 | lat: parseFloat(place.lat),
252 | lon: parseFloat(place.lon),
253 | });
254 | return {
255 | name: place.display_name.split(",")[0],
256 | distance: Math.round(distance * 10) / 10,
257 | address: place.display_name,
258 | type: place.type || "Healthcare Facility",
259 | };
260 | })
261 | .sort((a: Doctor, b: Doctor) => a.distance - b.distance)
262 | .slice(0, 5);
263 |
264 | setDoctors(nearbyDoctors);
265 | setShowDoctors(true);
266 | }
267 | } catch (error) {
268 | console.error("Error finding doctors:", error);
269 | }
270 | setLoadingDoctors(false);
271 | };
272 |
273 | const openInGoogleMaps = (address: string) => {
274 | // Encode the destination address for the URL
275 | const destination = encodeURIComponent(address);
276 | // Open Google Maps in a new tab with directions
277 | window.open(
278 | `https://www.google.com/maps/dir/?api=1&destination=${destination}`,
279 | "_blank"
280 | );
281 | };
282 |
283 | const randomMessages = [
284 |
285 | After carefully analyzing your symptoms, our assessment indicates that you
286 | may be experiencing{" "}
287 | {diseaseInfo}. We
288 | recommend{" "}
289 | {medicineInfo}, a
290 | time-tested Ayurvedic remedy rooted in ancient formulations known for its
291 | natural healing properties.
292 | ,
293 |
294 | Based on a detailed evaluation of your symptoms, it appears that you may
295 | have {diseaseInfo}.{" "}
296 | {medicineInfo} is a
297 | traditional Ayurvedic remedy, derived from ancient formulations, known for
298 | its effectiveness in promoting recovery.
299 | ,
300 |
301 | Our thorough analysis of your symptoms suggests a likelihood of{" "}
302 | {diseaseInfo}. We
303 | recommend{" "}
304 | {medicineInfo}, an
305 | ancient Ayurvedic formulation trusted for centuries to support natural
306 | healing and balance.
307 | ,
308 |
309 | Following a detailed analysis of your symptoms, the findings suggest{" "}
310 | {diseaseInfo}.{" "}
311 | {medicineInfo} is a
312 | classical Ayurvedic remedy, carefully preserved from ancient traditions to
313 | restore health and well-being.
314 | ,
315 |
316 | Our evaluation points to{" "}
317 | {diseaseInfo} based on
318 | your symptoms. We suggest trying{" "}
319 | {medicineInfo}, a
320 | well-established Ayurvedic remedy from ancient texts, known for its
321 | targeted healing properties.
322 | ,
323 |
324 | Based on a comprehensive analysis of your symptoms, you may be
325 | experiencing{" "}
326 | {diseaseInfo}.{" "}
327 | {medicineInfo} is a
328 | traditional Ayurvedic solution, derived from ancient wisdom, and valued
329 | for its natural effectiveness in restoring balance and health.
330 | ,
331 | ];
332 |
333 | return (
334 |
335 | {/* Decorative Leaves - Left Side */}
336 |
337 |
338 |
339 |
340 |
341 |
342 |
343 |
344 |
345 | {/* Decorative Leaves - Right Side */}
346 |