# Project export: flowzone

This document was generated by HackStack to give an AI agent context about a hackathon project. Sections are labeled with their provenance; content marked as truncated was cut to keep this document small.

## Project metadata

- Hackathon: TreeHacks 2024
- Tagline: What if I have a solution to halve the time you spend achieving your goals? Cutting down your 1-year goal into just 6 months. At flowzone, we simplify, integrate, and optimize your goals.
- Devpost: https://devpost.com/software/flowzone
- GitHub: https://github.com/TJun-Jie/flowzone
- Video: https://www.youtube.com/embed/BSHO9FA54ds?enablejsapi=1&hl=en_US&rel=0&start=&version=3&wmode=transparent
- Team: 4 GitHub contributor(s) — JamesLiuZX (22 commits), Jun Jie (20 commits), Asher Lim (15 commits), cyli (8 commits)

## Devpost submission (written by the team)

### Inspiration

Our team is composed of aspiring and existing entrepreneurs, where we share a common struggle of having multiple goals but insufficient time to achieve them all. Goal optimization then stood out as a problem we wanted to tackle. Likewise, research shows that 92% of people fail to achieve their goals. After doing extensive market research, we realized there are productivity tools that aid goal optimization like Todoist which breaks down goals into actionables, or Motion which schedules actionables into your calendar. While current solutions work in silos, we see value in having a comprehensive end-to-end solution from goal setting to Simplification to Integration and Analysis. This birthed flowzone. With flowzone, you can halve the time you spend achieving your goals. A one-year goal shortens to merely 6 months.

### What it does

From setting your goals to simplifying them into actionable tasks, to integrating them into your existing schedule, to analyzing your progress - flowzone is there every step of the way. flowzone is your end-to-end solution and best pal to help you achieve your goals. Simplify - Our AI breaks down your goal into a list of actionable tasks, with quantifiable time frames, segmented into phases. Integrate - Our AI analyzes your existing calendar (eg. synced Google calendar), and slots in your actionables on top of your existing routines. Optimize - Our AI analyzes both quantitative data (eg. stress levels and sleep patterns from TerraAPI), as well as qualitative data (from our daily reflections form where users reflect on their wins and losses), to recommend better ways to optimize your path to achieving your goals. flowzone knows you like the back of our palms - we anticipate your needs and wants before you realize them yourself. Knowing that having poor sleep quality drops your focus time to 2 hours at a time, we will suggest shortening your work intervals to suit your productivity trends. Knowing that your peak productivity is from 8am-10am, we will suggest scheduling High Priority action items during those hours. The list goes on.

### How we built it

Next.js for front-end Convex for back-end TerraAPI to get health data from wearables TogetherAI for AI agent and analysis

### Challenges we ran into

Training and finetuning our models in a short period of time - there is still much we would like to work on to achieve close to 100% accuracy. Improving inference speed was also a major challenge we faced. Integrating all the different APIs and linking the various databases into a cohesive system and flow for our users was also something we had to try and retry to find the most intuitive user flow, after rounds of user testing.

### Accomplishments we're proud of

Being able to dissect the issue of goal optimization into concrete features addressing the 3 key pain points in a short 2 days. Due to the complexity of the solution we wanted flowzone to be - with the multiple integrations of API, linkages in database, extensive model training, we all had to step out of our comfort zone to fulfill the needs of the team. For example, our front-end developers had to double up as back-end, our back-end developers had to double up as AI developers, etc.

### What we learned

We learnt the importance of adopting the iterative design thinking process. As we developed, we made sure to use an iterative feedback loop - doing regular user testing to ensure we are meeting their pain points and designing in an intuitive manner. This is also an idea we really believed in so trying to build a product that would make sense as a business, and taking into consideration our target market, business model, etc also held weight on our design of the product.

### What's next

Short-term milestones: Mar 2024 - MVP Jun 2024 - Beta Launch Sep 2024 - Live Mobile App Next phase milestones: Explore Enterprise plans for teams on top of current Freemium models for individuals. Further finetune AI models to provide scientifically / academia-proven recommendations and analysis.

## README (from the GitHub repository)

## Technologies Used
### Convex
#### Features Used
- Queries
- Mutations
- Actions
- Internal Functions
- HTTP Actions
- Indexes
- File Storage
- Authentication
- Scheduling (Cron Jobs)
- Full-Text Search
### Together AI
#### Model used: asherlimyi@gmail.com/Mistral-7B-Instruct-v0.1-flowzone-finetune-2024-02-18-16-40-42 (fine-tuned via knowledge distillation)
#### Features used:
- Fine-tuning
- Model deployment
- JSON mode


## Detected evidence (automated analysis)

Indexed codebase: 105 recognized source files, 276 KB.
- CSS (language) — detected in the code
- Express (technology) — detected in the code
- JavaScript (language) — detected in the code
- MongoDB (technology) — detected in the code
- Next.js (technology) — detected in the code
- OpenAI (technology) — detected in the code
- React (technology) — detected in the code
- Tailwind CSS (technology) — detected in the code
- TypeScript (language) — detected in the code

## Codebase structure (from repository index)

### Files (120 of 130)

```
.DS_Store
.eslintrc.json
.gitignore
backend/.gitignore
backend/app.js
backend/calendarai-406701-5a018cb153c5.json
backend/chatGPTClient.js
backend/eventScraper.js
backend/googleCalendarClient.js
backend/googleOAuth.js
backend/models/event.js
backend/models/plan.js
backend/models/task.js
backend/models/users.js
backend/mongodbClient.js
backend/package.json
backend/prompts/generate_goal_outline.txt
backend/prompts/generate_plan.txt
backend/readPrompt.js
backend/server.js
backend/uility/insertSampleData.js
frontend/.gitignore
frontend/convex/_generated/api.d.ts
frontend/convex/_generated/api.js
frontend/convex/_generated/dataModel.d.ts
frontend/convex/_generated/server.d.ts
frontend/convex/_generated/server.js
frontend/convex/actionItems.ts
frontend/convex/analytics.ts
frontend/convex/auth.config.js
frontend/convex/crons.ts
frontend/convex/dailyMetrics.ts
frontend/convex/files.ts
frontend/convex/generateActionItems.ts
frontend/convex/getUpdatedCalendar.ts
frontend/convex/http.ts
frontend/convex/README.md
frontend/convex/schema.ts
frontend/convex/sleepScores.ts
frontend/convex/stresses.ts
frontend/convex/stressScores.ts
frontend/convex/tsconfig.json
frontend/convex/zodSchema.js
frontend/mockActionItems.jsonl
frontend/mockDailyMetrics.jsonl
frontend/mockRecommendations.jsonl
frontend/mockStress.jsonl
frontend/next.config.mjs
frontend/package.json
frontend/postcss.config.js
frontend/README.md
frontend/sampleActionItems.json
frontend/sampleActionItems.jsonl
frontend/sampleDailyMetrics.jsonl
frontend/sampleDistractions.jsonl
frontend/sampleGoals.jsonl
frontend/sampleSleepScores.jsonl
frontend/sampleStress.jsonl
frontend/src/app/actionitem/components/actionItemComponent.tsx
frontend/src/app/actionitem/components/mainComponent.tsx
frontend/src/app/actionitem/components/SearchTable.tsx
frontend/src/app/actionitem/page.tsx
frontend/src/app/ConvexClientProvider.tsx
frontend/src/app/daily/components/Form.tsx
frontend/src/app/daily/components/HealthChart.tsx
frontend/src/app/daily/components/InputField.tsx
frontend/src/app/daily/components/Insights.tsx
frontend/src/app/daily/components/InsightsPage.tsx
frontend/src/app/daily/components/sampleTerraData.json
frontend/src/app/daily/components/StarRating.tsx
frontend/src/app/daily/oldPage.tsx
frontend/src/app/daily/page.tsx
frontend/src/app/dashboard/page.tsx
frontend/src/app/dayView/ActionItemsCalendarView.tsx
frontend/src/app/dayView/Combined.tsx
frontend/src/app/dayView/oldPage.tsx
frontend/src/app/dayView/page.tsx
frontend/src/app/globals.css
frontend/src/app/goals/page.tsx
frontend/src/app/home/page.tsx
frontend/src/app/layout.tsx
frontend/src/app/mainCalendar/components/AddDatePickerEventModal.tsx
frontend/src/app/mainCalendar/components/AddEventModal.tsx
frontend/src/app/mainCalendar/components/Chat.tsx
frontend/src/app/mainCalendar/components/EventCalendar.tsx
frontend/src/app/mainCalendar/components/EventInfo.tsx
frontend/src/app/mainCalendar/components/EventInfoModal.tsx
frontend/src/app/mainCalendar/components/util/CalendarToolbar.tsx
frontend/src/app/mainCalendar/components/util/Toolbar.js
frontend/src/app/mainCalendar/context/OperationsContext.tsx
frontend/src/app/mainCalendar/index.css
frontend/src/app/mainCalendar/page.tsx
frontend/src/app/page.tsx
frontend/src/app/planner/components/ActivityList.tsx
frontend/src/app/planner/components/AddDatePickerEventModal.tsx
frontend/src/app/planner/components/AddEventModal.tsx
frontend/src/app/planner/components/Chat.tsx
frontend/src/app/planner/components/EventCalendar.tsx
frontend/src/app/planner/components/EventCard.tsx
frontend/src/app/planner/components/EventInfo.tsx
frontend/src/app/planner/components/EventInfoModal.tsx
frontend/src/app/planner/components/Tabs.tsx
frontend/src/app/planner/components/util/CalendarToolbar.tsx
frontend/src/app/planner/components/util/Toolbar.js
frontend/src/app/planner/context/OperationsContext.tsx
frontend/src/app/planner/index.css
frontend/src/app/planner/page.tsx
frontend/src/app/profile/page.tsx
frontend/src/app/profile/profile.css
frontend/src/app/profile/profile.tsx
frontend/src/app/protected/page.tsx
frontend/src/app/search/page.tsx
frontend/src/app/test/page.tsx
frontend/src/app/typings/schemas.ts
frontend/src/app/UploadButton.tsx
frontend/src/app/weekly/page.tsx
frontend/src/components/Checkbox.tsx
frontend/src/components/SleepGraph.tsx
frontend/src/components/Table/ColumnConfig.ts
frontend/src/components/Table/DefaultTableHeaderCell.tsx
[10 more files omitted for size]
```

### Dependencies

- backend/package.json: @clerk/clerk-sdk-node@^4.13.4, @googleapis/calendar@^9.3.2, axios@^1.6.2, chrono-node@^2.7.5, cors@^2.8.5, date-fns@^3.3.1, dotenv@^16.3.1, express@^4.18.2, googleapis@^128.0.0, mongodb@^6.3.0, mongoose@^8.1.1, mongosh@^2.1.3, nodemon@^3.0.2, openai@^4.20.1, terra-api@^1.4.5
- frontend/package.json: @chatscope/chat-ui-kit-react@^1.10.1, @clerk/clerk-react@^4.30.5, @clerk/nextjs@^4.29.7, @emotion/react@^11.11.3, @emotion/styled@^11.11.0, @mui/icons-material@^5.15.10, @mui/joy@^5.0.0-beta.28, @mui/lab@^5.0.0-alpha.165, @mui/material@^5.15.10, @mui/x-date-pickers@^5.0.12, @types/lodash.debounce@^4.0.9, @types/luxon@^3.4.2, @types/node@^20, @types/react@^18, @types/react-big-calendar@^1.8.8, @types/react-dom@^18, @types/react-grid-layout@^1.3.5, @xixixao/uploadstuff@^0.0.5, autoprefixer@^10.0.1, axios@^1.6.3, convex@^1.9.0, date-fns@2.30.0, dayjs@^1.11.10, eslint@^8, eslint-config-next@14.1.0, formik@^2.4.5, framer-motion@^11.0.5, lodash.debounce@^4.0.8, luxon@^3.4.4, moment-timezone@^0.5.45, next@14.1.0, openai@^4.21.0, overlayscrollbars-react@^0.5.4, postcss@^8, react@^18, react-big-calendar@1.8.2, react-chartjs-2@^5.2.0, react-colorful@5.6.1, react-dom@^18, react-grid-layout@^1.4.4, react-icons@^4.12.0, sass@^1.70.0, tailwindcss@^3.3.0, typescript@^5, zod@^3.22.4, zod-to-json-schema@^3.22.4, zod-to-ts@^1.2.0

### Recent commits (newest first)

- add final commit
- Update README.md
- Create README.md
- add search feature
- Merge branch 'main' of https://github.com/TJun-Jie/flowzone
- add search index
- fixes
- final comimt
- Fix insights adding
- add cron jobs
- yes
- Fix mock data
- mock stress
- Merge branch 'main' of https://github.com/TJun-Jie/flowzone
- mock stress data
- sample data for stress
- Merge branch 'main' of https://github.com/TJun-Jie/flowzone
- Edit fiel.
- Edit api.d.ts
- Merge branch 'main' of https://github.com/TJun-Jie/flowzone

## Key source files (fetched from GitHub, selected and truncated for size)

### backend/package.json

```
{
  "dependencies": {
    "@clerk/clerk-sdk-node": "^4.13.4",
    "@googleapis/calendar": "^9.3.2",
    "axios": "^1.6.2",
    "chrono-node": "^2.7.5",
    "cors": "^2.8.5",
    "date-fns": "^3.3.1",
    "dotenv": "^16.3.1",
    "express": "^4.18.2",
    "googleapis": "^128.0.0",
    "mongodb": "^6.3.0",
    "mongoose": "^8.1.1",
    "mongosh": "^2.1.3",
    "openai": "^4.20.1",
    "terra-api": "^1.4.5"
  },
  "scripts": {
    "dev": "nodemon server.js"
  },
  "devDependencies": {
    "nodemon": "^3.0.2"
  }
}

```

### frontend/package.json

```
{
  "name": "flowzone",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "dev": "next dev",
    "build": "next build",
    "start": "next start",
    "lint": "next lint"
  },
  "dependencies": {
    "@chatscope/chat-ui-kit-react": "^1.10.1",
    "@clerk/clerk-react": "^4.30.5",
    "@clerk/nextjs": "^4.29.7",
    "@emotion/react": "^11.11.3",
    "@emotion/styled": "^11.11.0",
    "@mui/icons-material": "^5.15.10",
    "@mui/joy": "^5.0.0-beta.28",
    "@mui/lab": "^5.0.0-alpha.165",
    "@mui/material": "^5.15.10",
    "@mui/x-date-pickers": "^5.0.12",
    "@types/react-big-calendar": "^1.8.8",
    "@xixixao/uploadstuff": "^0.0.5",
    "axios": "^1.6.3",
    "convex": "^1.9.0",
    "date-fns": "2.30.0",
    "dayjs": "^1.11.10",
    "formik": "^2.4.5",
    "framer-motion": "^11.0.5",
    "lodash.debounce": "^4.0.8",
    "luxon": "^3.4.4",
    "moment-timezone": "^0.5.45",
    "next": "14.1.0",
    "openai": "^4.21.0",
    "overlayscrollbars-react": "^0.5.4",
    "react": "^18",
    "react-big-calendar": "1.8.2",
    "react-chartjs-2": "^5.2.0",
    "react-colorful": "5.6.1",
    "react-dom": "^18",
    "react-grid-layout": "^1.4.4",
    "react-icons": "^4.12.0",
    "sass": "^1.70.0",
    "zod": "^3.22.4",
    "zod-to-json-schema": "^3.22.4",
    "zod-to-ts": "^1.2.0"
  },
  "devDependencies": {
    "@types/lodash.debounce": "^4.0.9",
    "@types/luxon": "^3.4.2",
    "@types/node": "^20",
    "@types/react": "^18",
    "@types/react-dom": "^18",
    "@types/react-grid-layout": "^1.3.5",
    "autoprefixer": "^10.0.1",
    "eslint": "^8",
    "eslint-config-next": "14.1.0",
    "postcss": "^8",
    "tailwindcss": "^3.3.0",
    "typescript": "^5"
  }
}

```

### backend/app.js

```javascript
// app.js
const {getUserContext} = require('./mongodbClient');
const {getEventRecommendations}= require('./chatGPTClient');
const { insertEventsToCalendar, parseEvent } = require('./googleCalendarClient');
const { oauth2Client } = require('./googleOAuth');

async function main() {
    try {
        if (!oauth2Client.credentials) {
            console.log('User is not authenticated. Please authenticate through the OAuth flow.');
            return;
        }
    
        const userId = '65bae4feb44e32c3e377153a'; 
        const userContext = await getUserContext(userId);
        console.log(`the usercontext is ${userContext}`);
        let recommendations = await getEventRecommendations(userContext);
        let parsedEvents = recommendations.split('\n').map(parseEvent).filter(event => event !== null);
        console.log(`the events are ${parsedEvents}`);
        if (parsedEvents.length > 0) {
            await insertEventsToCalendar(parsedEvents);
            console.log('Events inserted into Google Calendar');
        } else {
            console.log('No events to insert.');
        }
    } catch(error) {
        console.log(`Error inserting events into Google Calendar: ${error}`);
    }
    
}

// Call main only after OAuth authentication is complete
// You might want to trigger this based on a specific route or user action
module.exports = main; // Export the main function

```

### backend/server.js

```javascript
const express = require("express");
const { MongoClient, ObjectId } = require("mongodb");
const cors = require("cors"); // Import cors
const Terra = require("terra-api").default;
const { oauth2Client, getAuthUrl, getAccessToken } = require("./googleOAuth");
const main = require("./app"); // Import the main function
const {
  getStepsToAchieveGoal,
  classifyInputs,
  generatePlanOutline,
  getParsedThirdPartyEvents,
  getActualFormattedGPTResponse,
  getUserCurrentCalendar,
} = require("./chatGPTClient");
const { getThirdPartyEventRecommendations } = require("./eventScraper");
const {
  getUserContext,
  getUserProfile,
  updateUserContext,
} = require("./mongodbClient");
const {
  insertEventsToCalendar,
  convertToJsonForGoogleCalendar,
  replaceOverlappingEvents,
} = require("./googleCalendarClient");
const { readPromptFile } = require("./readPrompt");
const app = express();
const User = require("./models/users.js");

const terra = new Terra(
  "jIiBleJPEDKyh0bSTPTIkJ-h4fdKMWm6",
  "flowzone-testing-bIazeQuLhm",
  "629b9ca6c5744571caaeb07fc98688f67d3483bf86af9fc8"
);

// Enable All CORS Requests
app.use(cors());
app.use(express.json());

const mongoose = require("mongoose");

mongoose
  .connect("mongodb://localhost:27017/calendar_db", {
    useNewUrlParser: true,
    useUnifiedTopology: true,
  })
  .then(() => console.log("MongoDB Connected"))
  .catch((err) => console.log(err));

app.get("/auth", (req, res) => {
  res.redirect(getAuthUrl());
});

app.get("/authenticated", async (req, res) => {
  try {
    console.log(req);
    const clerkUserId = req.query.clerk_user_id;
    await getAccessToken(clerkUserId);
    //res.redirect('/getThirdpartyEvents'); // Redirect to execute main after successful authentication
  } catch (error) {
    console.error(error);
    res.send("Error during authentication.");
  }
});
/*
app.get('/oauth2callback', async (req, res) => {
    try {
        console.log(req);
        const { code } = req.query;
        await getAccessToken(code);
        res.redirect('/getThirdpartyEvents'); // Redirect to execute main after successful authentication
    } catch (error) {
        console.error(error);
        res.send('Error during authentication.');
    }
});
*/
/*
app.get('/oauth2callback', async (req, res) => {
    const { code } = req.query;
    if (code) {
        try {
            const { tokens } = await oauth2Client.getToken(code);
            oauth2Client.setCredentials(tokens);

            res.send('Authorization successful. You can close this tab.');
        } catch (error) {
            console.error('Error getting tokens:', error);
            res.send('Error during the login process. Please try again.');
        }
    } else {
        res.send('No authorization code found. Please try again.');
    }
});

app.get('/executeMain', async (req, res) => {
    try {
        await main(); // Call the main function from app.js
        res.send('Calendar operations completed successfully.');
    } catch (error) {
        console.error(error);
        res.send('Error executing calendar operations.');
    }
});
*/

app.get("/getChatResponse", async (req, res) => {
  try {
    const response = await getActualFormattedGPTResponse(req.chat);
    console.log(response);
    res.send(response);
  } catch (error) {
    console.error(error);
    res.send("Error executing calendar operations.");
  }
});

app.get("/getThirdpartyEvents", async (req, res) => {
  //TODO: to get additoinal context later from the FE req.body.events;
  const events = await getParsedThirdPartyEvents();
  res.send(JSON.stringify(events));
});

app.get("/createEvent", async (req, res) => {
  //TODO: to get additoinal context later from the FE req.body.events;
  try {
    const clerkUserId = req.query.clerk_user_id;
    await getAccessToken(clerkUserId);
    const recommendationObjs = req.recommendationObj;
    for (const recommendationObj of recommendationObjs) {
      const googleEvent = await replaceOverlappingEvents(recommendationObj);
      await replaceOverlappingEvents(googleEvent);
    }
  } catch (error) {
    console.error(error);
    res.send(error);
  }
});

app.get("/getUserCurrentCalendar", async (req, res) => {
  try {
    if (!req.query.clerk_user_id) {
      return res
        .status(400)
        .send({ error: "clerk_user_id is required as a query parameter." });
    }
    const clerkId = req.query.clerk_user_id;
    const result = await getUserCurrentCalendar(clerkId);
    res.send(JSON.stringify(result));
  } catch (error) {
    console.error("Error fetching user calendar:", error);
    res.status(500).send({ error: "Internal server error." });
  }
});

app.get("/getUserProfile", async (req, res) => {
  //TODO: to get additoinal context later from the FE req.body.events;
  try {
    const userId = "user_2bsEMuFTxBZqdsWnHiUANOnsKHF";
    const userContext = await getUserContext(userId);
    console.log(`the usercontext is ${JSON.stringify(userContext)}`);
    res.send(userContext);
  } catch (error) {
    console.error(error);
    res.send(error);
  }
});

app.get("/getUserData", async (req, res) => {
  //TODO: to get additoinal context later from the FE req.body.events;
  try {
    const userId = "user_2bsEMuFTxBZqdsWnHiUANOnsKHF";
    const userContext = await getUserProfile(userId);
    console.log(`the usercontext is ${JSON.stringify(userContext)}`);
    res.send(userContext);
  } catch (error) {
    console.error(error);
    res.send(error);
  }
});

// Endpoint to add a user, returns the user id
app.post("/addUser", async (req, res) => {
  try {
    const newUser = new User(req.body); // Create a new user with the request body
    const savedUser = await newUser.save(); // Save the new user to the database
    res.status(201).send({ userId: savedUser._id }); // Respond with the userId of the new user
  } catch (error) {
    console.error(error);
    res
      .status(500)
      .send({ message: "Error adding user", error: error.message });
  }
});

app.post("/classifyIn
[truncated — 11914 more characters]
```

### frontend/src/app/page.tsx

```typescript
"use client";
import { ClerkLoaded, SignInButton, useUser } from "@clerk/nextjs";

import Home from "./home/page";

export default function HomePage() {
  const { user } = useUser();

  return (
    <div className="h-max flex flex-col items-center justify-center -mt-4 from-pink-300 via-purple-300 to-indigo-400 ">
      {user ? (
        <div className="h-full w-full flex flex-col ">
          <h1 className="text-2xl font-semibold text-white flex  w-full justify-center items-center mt-[50px] ">
            Welcome back, {user.firstName}!
          </h1>

          <Home />
        </div>
      ) : (
        <div className="p-6 rounded-lg shadow-lg bg-white -mt-4">
          <h2 className="text-xl font-semibold text-gray-800 mb-4">
            Welcome to Calendare
          </h2>
          <p className="text-gray-600 mb-8">Please sign in to continue</p>
          <ClerkLoaded>
            <div className="flex justify-center text-white bg-blue-600 hover:bg-blue-700 font-bold py-2 px-4 rounded ">
              <SignInButton />
            </div>
          </ClerkLoaded>
        </div>
      )}
    </div>
  );
}

```

### frontend/convex/_generated/server.js

```javascript
/* eslint-disable */
/**
 * Generated utilities for implementing server-side Convex query and mutation functions.
 *
 * THIS CODE IS AUTOMATICALLY GENERATED.
 *
 * Generated by convex@1.9.0.
 * To regenerate, run `npx convex dev`.
 * @module
 */

import {
  actionGeneric,
  httpActionGeneric,
  queryGeneric,
  mutationGeneric,
  internalActionGeneric,
  internalMutationGeneric,
  internalQueryGeneric,
} from "convex/server";

/**
 * Define a query in this Convex app's public API.
 *
 * This function will be allowed to read your Convex database and will be accessible from the client.
 *
 * @param func - The query function. It receives a {@link QueryCtx} as its first argument.
 * @returns The wrapped query. Include this as an `export` to name it and make it accessible.
 */
export const query = queryGeneric;

/**
 * Define a query that is only accessible from other Convex functions (but not from the client).
 *
 * This function will be allowed to read from your Convex database. It will not be accessible from the client.
 *
 * @param func - The query function. It receives a {@link QueryCtx} as its first argument.
 * @returns The wrapped query. Include this as an `export` to name it and make it accessible.
 */
export const internalQuery = internalQueryGeneric;

/**
 * Define a mutation in this Convex app's public API.
 *
 * This function will be allowed to modify your Convex database and will be accessible from the client.
 *
 * @param func - The mutation function. It receives a {@link MutationCtx} as its first argument.
 * @returns The wrapped mutation. Include this as an `export` to name it and make it accessible.
 */
export const mutation = mutationGeneric;

/**
 * Define a mutation that is only accessible from other Convex functions (but not from the client).
 *
 * This function will be allowed to modify your Convex database. It will not be accessible from the client.
 *
 * @param func - The mutation function. It receives a {@link MutationCtx} as its first argument.
 * @returns The wrapped mutation. Include this as an `export` to name it and make it accessible.
 */
export const internalMutation = internalMutationGeneric;

/**
 * Define an action in this Convex app's public API.
 *
 * An action is a function which can execute any JavaScript code, including non-deterministic
 * code and code with side-effects, like calling third-party services.
 * They can be run in Convex's JavaScript environment or in Node.js using the "use node" directive.
 * They can interact with the database indirectly by calling queries and mutations using the {@link ActionCtx}.
 *
 * @param func - The action. It receives an {@link ActionCtx} as its first argument.
 * @returns The wrapped action. Include this as an `export` to name it and make it accessible.
 */
export const action = actionGeneric;

/**
 * Define an action that is only accessible from other Convex functions (but not from the client).
 *
 * @param func - The function. It receives an {@link ActionCtx} as its first argument.
 * @returns The wrapped function. Include this as an `export` to name it and make it accessible.
 */
export const internalAction = internalActionGeneric;

/**
 * Define a Convex HTTP action.
 *
 * @param func - The function. It receives an {@link ActionCtx} as its first argument, and a `Request` object
 * as its second.
 * @returns The wrapped endpoint function. Route a URL path to this function in `convex/http.js`.
 */
export const httpAction = httpActionGeneric;

```

### frontend/src/app/layout.tsx

```typescript
import "./globals.css";
import type { Metadata } from "next";
import { Inter } from "next/font/google";
import {
  ClerkLoaded,
  ClerkLoading,
  ClerkProvider,
  SignInButton,
  UserButton,
  auth,
} from "@clerk/nextjs";
import ConvexClientProvider from "./ConvexClientProvider";
import "./globals.css";
import { LocalizationProvider } from "@mui/x-date-pickers";
import { AdapterDayjs } from "@mui/x-date-pickers/AdapterDayjs";

const inter = Inter({ subsets: ["latin"] });

export const metadata: Metadata = {
  title: "Create Next App",
  description: "Generated by create next app",
};

export default function RootLayout({
  children,
}: {
  children: React.ReactNode;
}) {
  const { userId } = auth();
  return (
    <html lang="en">
      <body
        className={`w-screen h-screen ${inter.className} bg-gradient-to-r from-pink-300 via-purple-300 to-indigo-400`}
      >
        <ConvexClientProvider>
          <ClerkLoading>
            <div className="w-full h-full flex justify-center items-center bg-[#fff]">
              <div
                className="inline-block h-8 w-8 animate-spin rounded-full border-4 border-solid border-current border-r-transparent align-[-0.125em] motion-reduce:animate-[spin_1.5s_linear_infinite]"
                role="status"
              >
                <span className="!absolute !-m-px !h-px !w-px !overflow-hidden !whitespace-nowrap !border-0 !p-0 ![clip:rect(0,0,0,0)]">
                  Loading...
                </span>
              </div>
            </div>
          </ClerkLoading>
          <ClerkLoaded>
            <div className="w-screen h-screen flex flex-col">
              <nav className="bg-gradient-to-r from-pink-300 via-purple-300 to-indigo-400 text-white px-4 py-3">
                <div className="container mx-auto flex justify-between items-center">
                  <a href="/" className="text-lg font-semibold justify-start">
                    flowzone
                  </a>
                  <div className="flex items-center space-x-4">
                    <a href="/" className="hover:text-gray-300">
                      Home
                    </a>
                    <a href="/goals" className="hover:text-gray-300">
                      Goals
                    </a>
                    <a href="/mainCalendar" className="hover:text-gray-300">
                      Calendar
                    </a>
                    <a href="/daily" className="hover:text-gray-300">
                      Daily
                    </a>
                    <a href="/search" className="hover:text-gray-300">
                      Search
                    </a>
                    <a href="/profile" className="hover:text-gray-300">
                      Profile
                    </a>
                    {userId ? (
                      <div className="flex items-center space-x-4">
                        <div className="hover:text-gray-300">
                          <UserButton />
                        </div>
                      </div>
                    ) : (
                      <div className="flex items-center space-x-4">
                        <a href="#" className="hover:text-gray-300">
                          <SignInButton />
                        </a>
                      </div>
                    )}
                  </div>
                </div>
              </nav>
              {children}
            </div>
          </ClerkLoaded>
        </ConvexClientProvider>
      </body>
    </html>
  );
}

```

### frontend/src/app/dayView/page.tsx

```typescript
import DayViewCalendar from "../dayView/Combined";

export default DayViewCalendar;
```

### frontend/src/app/protected/page.tsx

```typescript
export type ProtectedPageProps = {};

const ProtectedPage: React.FC<ProtectedPageProps> = () => {
  return <div className="w-screen h-screen"> i am protected</div>;
};

export default ProtectedPage;

```

### frontend/src/app/profile/page.tsx

```typescript
import Profile from "./profile";

export type ProfilePage = {};

const ProfilePage: React.FC = () => {
  return (
    <div className="flex flex-col w-full items-center mt-5">
      <h1>User Profile</h1>
      <Profile />
    </div>
  );
};

export default ProfilePage;
```

[92 more indexed source files omitted to keep this export small. The full file list is in the Codebase structure section above.]