Skip to content

Commit

Permalink
Allotax (#15)
Browse files Browse the repository at this point in the history
* query refactor for now

* update yml files

* made backend a submodule

* sync for backend

* seperate frontend and backend

* query functionality v1

* fix query form

* add request schema

* cleanup schema & add command to readme

* add go to next page from query & use user id, refactor ngram page

* add save query button & post request to backend

* query page styling

* remove footed & add logic for loading saved queries

* ngram page cleanup & save & load

* upload saved query

* added user login & dynamic loading of specific users saved queries. Also scrapped nav and put all content on landing page

* display and save query

* added back removed query params

* update query to be posts or comments or both

* refator query + ngram page for styling purposes

* ngram save and display buttons

* ngram viz force graph

* successful v1 of ngram ts viz!!

* ngram visualizations are at a good stopping point for now, will now focus on group ngram divergence visualizations

* remove saving and loading logic

* added group allotax selection & group search functionality, TODO : ALLOTAX BEE SWARM PLOTS

* allotax viz & plots v1

* update lock file

* update actions

* delete unused pages

* fix linting bugs

* refactor to have sessionID instead of sessionStorage data, deployment still not working

* fuggetaboutit i got it to work

* test for updated backend ip

* update port
  • Loading branch information
Jayman391 authored Dec 16, 2024
1 parent ca0eba5 commit 7d3aa36
Show file tree
Hide file tree
Showing 27 changed files with 23,651 additions and 1,435 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ name: Vercel Preview Deployment
env:
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
VERCEL_FORCE_NO_BUILD_CACHE: 1
on:
push:
branches-ignore:
Expand All @@ -13,6 +14,12 @@ jobs:
- uses: actions/checkout@v2
- name: Install Vercel CLI
run: npm install --global vercel@latest
- name: Setup pnpm
uses: pnpm/action-setup@v2.2.4
with:
version: 8.6.0
-name: Run pnpm install
run: pnpm install
- name: Pull Vercel Environment Information
run: vercel pull --yes --environment=preview --token=${{ secrets.VERCEL_TOKEN }}
- name: Build Project Artifacts
Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ name: Vercel Production Deployment
env:
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
VERCEL_FORCE_NO_BUILD_CACHE: 1
on:
push:
branches:
Expand All @@ -13,6 +14,12 @@ jobs:
- uses: actions/checkout@v2
- name: Install Vercel CLI
run: npm install --global vercel@latest
- name: Setup pnpm
uses: pnpm/action-setup@v2.2.4
with:
version: 8.6.0
-name: Run pnpm install
run: pnpm install
- name: Pull Vercel Environment Information
run: vercel pull --yes --environment=production --token=${{ secrets.VERCEL_TOKEN }}
- name: Build Project Artifacts
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "babycenter-backend"]
path = babycenter-backend
url = https://github.com/Jayman391/babycenter-backend.git
79 changes: 1 addition & 78 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,78 +1 @@
<p align="center">
<a href="https://nextjs-flask-starter.vercel.app/">
<img src="https://assets.vercel.com/image/upload/v1588805858/repositories/vercel/logo.png" height="96">
<h3 align="center">Next.js Flask Starter</h3>
</a>
</p>

<p align="center">Simple Next.js boilerplate that uses <a href="https://flask.palletsprojects.com/">Flask</a> as the API backend.</p>

<br/>

## Introduction

This is a hybrid Next.js + Python app that uses Next.js as the frontend and Flask as the API backend. One great use case of this is to write Next.js apps that use Python AI libraries on the backend.

## How It Works

The Python/Flask server is mapped into to Next.js app under `/api/`.

This is implemented using [`next.config.js` rewrites](https://github.com/vercel/examples/blob/main/python/nextjs-flask/next.config.js) to map any request to `/api/:path*` to the Flask API, which is hosted in the `/api` folder.

On localhost, the rewrite will be made to the `127.0.0.1:5328` port, which is where the Flask server is running.

In production, the Flask server is hosted as [Python serverless functions](https://vercel.com/docs/concepts/functions/serverless-functions/runtimes/python) on Vercel.

## Demo

https://nextjs-flask-starter.vercel.app/

## Deploy Your Own

You can clone & deploy it to Vercel with one click:

[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/clone?demo-title=Next.js%20Flask%20Starter&demo-description=Simple%20Next.js%20boilerplate%20that%20uses%20Flask%20as%20the%20API%20backend.&demo-url=https%3A%2F%2Fnextjs-flask-starter.vercel.app%2F&demo-image=%2F%2Fimages.ctfassets.net%2Fe5382hct74si%2F795TzKM3irWu6KBCUPpPz%2F44e0c6622097b1eea9b48f732bf75d08%2FCleanShot_2023-05-23_at_12.02.15.png&project-name=Next.js%20Flask%20Starter&repository-name=nextjs-flask-starter&repository-url=https%3A%2F%2Fgithub.com%2Fvercel%2Fexamples%2Ftree%2Fmain%2Fpython%2Fnextjs-flask&from=vercel-examples-repo)

## Developing Locally

You can clone & create this repo with the following command

```bash
npx create-next-app nextjs-flask --example "https://github.com/vercel/examples/tree/main/python/nextjs-flask"
```

## Getting Started

First, install the dependencies:

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

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`).

## Learn More

To learn more about Next.js, take a look at the following resources:

- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.
- [Flask Documentation](https://flask.palletsprojects.com/en/1.1.x/) - learn about Flask features and API.

You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js/) - your feedback and contributions are welcome!
npx @openapitools/openapi-generator-cli generate -i requestSchema.yaml -g ruby -o babycenter-frontend
2 changes: 0 additions & 2 deletions api/.env

This file was deleted.

66 changes: 0 additions & 66 deletions api/index.py

This file was deleted.

101 changes: 101 additions & 0 deletions app/CustomSelect.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
import React, { useState, useRef, useEffect } from 'react';

interface CustomSelectProps {
options: { value: string; label: string }[];
selectedValue: string;
onChange: (value: string) => void;
placeholder?: string;
}

export const CustomSelect: React.FC<CustomSelectProps> = ({
options,
selectedValue,
onChange,
placeholder = '-- Select an Option --',
}) => {
const [isOpen, setIsOpen] = useState(false);
const ref = useRef<HTMLDivElement>(null);

const handleOptionClick = (value: string) => {
onChange(value);
setIsOpen(false);
};

// Close the dropdown when clicking outside
useEffect(() => {
const handleClickOutside = (event: MouseEvent) => {
if (ref.current && !ref.current.contains(event.target as Node)) {
setIsOpen(false);
}
};
document.addEventListener('mousedown', handleClickOutside);
return () => {
document.removeEventListener('mousedown', handleClickOutside);
};
}, []);

const selectedLabel =
options.find((option) => option.value === selectedValue)?.label || placeholder;

return (
<div className="custom-select" ref={ref}>
<div className="custom-select__selected" onClick={() => setIsOpen(!isOpen)}>
{selectedLabel}
<span className="custom-select__arrow">&#9662;</span>
</div>
{isOpen && (
<ul className="custom-select__options">
{options.map((option) => (
<li
key={option.value}
className="custom-select__option"
onClick={() => handleOptionClick(option.value)}
>
{option.label}
</li>
))}
</ul>
)}

<style jsx>{`
.custom-select {
position: relative;
width: 100%;
}
.custom-select__selected {
padding: 8px;
border: 1px solid #ccc;
border-radius: 3px;
background-color: #fff;
cursor: pointer;
display: flex;
justify-content: space-between;
align-items: center;
color: black;
}
.custom-select__arrow {
margin-left: 10px;
}
.custom-select__options {
position: absolute;
width: 100%;
max-height: 200px;
overflow-y: auto;
border: 1px solid #ccc;
border-radius: 3px;
background-color: #fff;
z-index: 1000;
margin-top: 5px;
}
.custom-select__option {
padding: 8px;
cursor: pointer;
color: black;
}
.custom-select__option:hover {
background-color: #f1f1f1;
}
`}</style>
</div>
);
};
47 changes: 0 additions & 47 deletions app/auth.tsx

This file was deleted.

2 changes: 1 addition & 1 deletion app/config.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
// app/config.ts

export const BACKEND_IP = "http://127.0.0.1:5328";
export const BACKEND_IP = "http://0.0.0.0:8000";
16 changes: 0 additions & 16 deletions app/footer.tsx

This file was deleted.

Loading

0 comments on commit 7d3aa36

Please sign in to comment.