diff --git a/.eslintrc.cjs b/.eslintrc.cjs index 36f7e57..6e8698b 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -2,17 +2,17 @@ module.exports = { root: true, env: { browser: true, es2020: true }, extends: [ - 'eslint:recommended', - 'plugin:@typescript-eslint/recommended', - 'plugin:react-hooks/recommended', + "eslint:recommended", + "plugin:@typescript-eslint/recommended", + "plugin:react-hooks/recommended", ], - ignorePatterns: ['dist', '.eslintrc.cjs'], - parser: '@typescript-eslint/parser', - plugins: ['react-refresh'], + ignorePatterns: ["dist", ".eslintrc.cjs"], + parser: "@typescript-eslint/parser", + plugins: ["react-refresh"], rules: { - 'react-refresh/only-export-components': [ - 'warn', + "react-refresh/only-export-components": [ + "warn", { allowConstantExport: true }, ], }, -} \ No newline at end of file +}; diff --git a/README.md b/README.md index 1064dbe..5cae9f2 100644 --- a/README.md +++ b/README.md @@ -1,38 +1,46 @@ -# Analysr - Business Analytics Platform 📊 +# Analysr - Review Analytics Platform 📊 +
- Transform your business with powerful analytics and data-driven insights + Transform your business with Analysr
Airbyte-Motherduck Hackathon - December 2024 - January 2025
+
+For all you speedy folks out there, here’s the scoop:
+
+- **1.0.0**
+ With your customer reviews in motherduck, along with your chosen business stack and areas of interest, Analysr is ready to dish out some insightful analytics. And just to sweeten the deal, Groq has stepped in to help you navigate all your growth phases—because who doesn’t want a sidekick in business?
+
+Your analytics lineup features Aspect Analysis, a Word Sentiment Heatmap (for those feelings), Advanced Text Analysis, Groq Business Analytics, Keyphrase Analysis, and a handy Competitor Comparison.
+
+## Walkthrough
+
+1) To obtain customer review insights, sync your data to Motherduck with the schema: { "review_text": "string", "stars": "number" } (More schemas will be supported soon). We recommend using Airbyte due to its extensive list of sources and seamless data movement.
+2) Visit the Analysr website at (growwithanalysr.web.app) and click on the "Get Started Now" button.
+3) Select your business stack and substack; Groq and queries will use this information to fetch insights.
+4) Input your Motherduck token and wait for the connection to be established (the time required will depend on your network bandwidth).
+5) Select the database and table where your customer reviews or any related reviews exist, and set the data limit.
+6) Input your Groq token (recommended) to obtain AI-based insights.
+7) Optionally provide your Airbyte bearer token (from the cloud.airbyte.com settings page) and connection ID (from the connections tab URL) to trigger a sync for updating your Motherduck table.
+8) Finally, input your area of interest for insights, such as customer satisfaction, and click "Continue to Dashboard."
+9) Wait a few seconds until all queries are executed and visualized.
+10) Voilà! Your dashboard will be ready, featuring all the capabilities of Analysr to support your next big step!
+
+
## ✨ Features
-### 🎯 Smart Business Insights
-- AI-powered analysis of customer feedback and market trends
-- Sentiment analysis and emotion tracking
-- Key phrase extraction and topic modeling
-- Competitive benchmarking and industry comparisons
-
-### 📈 Advanced Analytics
-- Real-time data processing and visualization
-- Customizable dashboards and reports
-- Trend analysis and forecasting
-- Performance metrics and KPIs
-
-### 🔍 Deep Customer Understanding
-- Customer sentiment tracking
-- Demographic analysis
-- Behavior pattern recognition
-- Satisfaction metrics and NPS tracking
-
-### 🚀 Growth Opportunities
-- Market opportunity identification
-- Customer pain point analysis
-- Competitive advantage analysis
-- Strategic recommendations
+- **Aspect Analysis:** Gain insights into different aspects of customer feedback.
+- **Word Sentiment Heatmap:** Visualize sentiment trends in your reviews.
+- **Advanced Text Analysis:** Delve deeper into the nuances of customer language.
+- **Groq Business Analytics:** Access data-driven insights to inform your growth strategy.
+- **Keyphrase Analysis:** Identify and analyze key phrases that matter to your customers.
+- **Competitor Comparison:** Benchmark your performance against competitors.
## 🛠️ Technology Stack
@@ -42,39 +50,38 @@
- **Visualization**: Recharts
- **State Management**: Zustand
- **Animations**: Framer Motion
+- **Hosting**: Firebase (Production), Vercel (Experiment)
+- **CI/CD**: GitHub Actions for automated deployment
+
+
+## Future roadmap
+
+- **Microservice for generating queries**: Currently all queries for analytics are highly coupled with code, seperation of concerns to microservice
+ - [*] Create mock express server and deployed as supabase functions
+ - [] Separate DuckDB queries for as an api call
+ - [] Enhance microservice with GPT Wrapper
+ - [] Enhance business insights from groq: Currently it hallucinates as the mixtral model is not powerful (Requires funding)
## 🚀 Getting Started
1. Clone the repository:
+
```bash
-git clone https://github.com/yourusername/analysr.git
+git clone https://github.com/btkcodedev/airbyte-motherduck-hackathon.git
```
2. Install dependencies:
+
```bash
npm install
```
-3. Set up environment variables:
-```env
-MOTHERDUCK_TOKEN=your_token
-GROQ_API_KEY=your_key
-```
+3. Start the development server:
-4. Start the development server:
```bash
npm run dev
```
-## 📊 Dashboard Features
-
-- **Real-time Analytics**: Monitor business performance in real-time
-- **Sentiment Analysis**: Track customer sentiment and emotions
-- **Competitive Analysis**: Compare performance against industry benchmarks
-- **Text Analysis**: Extract insights from customer feedback
-- **Trend Visualization**: Track metrics over time with interactive charts
-- **AI Insights**: Get AI-powered recommendations for business growth
-
## 🔒 Security
- Secure token management
@@ -92,10 +99,10 @@ Contributions are welcome! Please feel free to submit a Pull Request.
## 📬 Contact
-For questions and support, please open an issue or contact us at support@analysr.app
+For questions and support, please open an issue or contact at btk.codedev@gmail.com
---
{data.name}
++ Frequency: {data.size} +
Sentiment: {(data.sentiment * 100).toFixed(0)}%
@@ -106,4 +112,4 @@ export default function SentimentHeatmap() {Optional Airbyte Configuration
{welcomeScreenData.welcomeSectionVersionBottom}
diff --git a/src/data/businessCategories.ts b/src/config/data/businessCategories.ts
similarity index 100%
rename from src/data/businessCategories.ts
rename to src/config/data/businessCategories.ts
diff --git a/src/config/services/index.ts b/src/config/services/index.ts
new file mode 100644
index 0000000..050d5da
--- /dev/null
+++ b/src/config/services/index.ts
@@ -0,0 +1,20 @@
+export const AIRBYTE_SUPABASE_PROXY_URL = "https://lejxudxaxuqfkhtgddoe.supabase.co/functions/v1/apiProxy/airbyte";
+export const AIRBYTE_LOCAL_PROXY_URL = "/api/airbyte";
+export const AIRBYTE_API_BASE_URL = "https://api.airbyte.com/v1";
+export const GROQ_SUPABASE_PROXY_URL = "https://lejxudxaxuqfkhtgddoe.supabase.co/functions/v1/apiProxy/groq";
+export const GROQ_LOCAL_PROXY_URL = "/api/groq";
+export const GROQ_API_BASE_URL = "https://api.groq.com/v1";
+
+export const getAirbyteApiUrl = () => {
+ if (import.meta.env.DEV) {
+ return AIRBYTE_LOCAL_PROXY_URL;
+ }
+ return AIRBYTE_SUPABASE_PROXY_URL;
+ };
+
+ export const getGroqApiUrl = () => {
+ if (import.meta.env.DEV) {
+ return GROQ_LOCAL_PROXY_URL;
+ }
+ return GROQ_SUPABASE_PROXY_URL;
+ };
diff --git a/src/lib/airbyte/useSyncStatus.ts b/src/hooks/useAirbyteSyncStatus.ts
similarity index 91%
rename from src/lib/airbyte/useSyncStatus.ts
rename to src/hooks/useAirbyteSyncStatus.ts
index b2c0ae7..ec86fc0 100644
--- a/src/lib/airbyte/useSyncStatus.ts
+++ b/src/hooks/useAirbyteSyncStatus.ts
@@ -1,8 +1,8 @@
import { useState, useEffect } from "react";
-import { checkConnectionStatus, triggerJob } from "./service";
-import type { StatusState } from "../../types/status";
+import { checkConnectionStatus, triggerJob } from "../lib/airbyte/service";
+import type { StatusState } from "../types/status";
-export function useSyncStatus(
+export function useAirbyteSyncStatus(
token?: string,
connectionId?: string,
jobType: "sync" | "reset" = "sync",
diff --git a/src/lib/motherduck/useConnectionStatus.ts b/src/hooks/useConnectionStatus.ts
similarity index 90%
rename from src/lib/motherduck/useConnectionStatus.ts
rename to src/hooks/useConnectionStatus.ts
index d992a7c..05f2db0 100644
--- a/src/lib/motherduck/useConnectionStatus.ts
+++ b/src/hooks/useConnectionStatus.ts
@@ -1,7 +1,7 @@
import { useState, useEffect } from "react";
-import { getConnection } from "./connection";
-import { useTokenStore } from "./tokenStore";
-import type { StatusState } from "../../types/status";
+import { getConnection } from "../lib/motherduck/connection";
+import { useTokenStore } from "../lib/motherduck/tokenStore";
+import type { StatusState } from "../types/status";
export function useConnectionStatus(
inputToken: string | undefined
diff --git a/src/lib/groq/useGroqConnection.ts b/src/hooks/useGroqConnection.ts
similarity index 96%
rename from src/lib/groq/useGroqConnection.ts
rename to src/hooks/useGroqConnection.ts
index 795fb71..ee3a9dd 100644
--- a/src/lib/groq/useGroqConnection.ts
+++ b/src/hooks/useGroqConnection.ts
@@ -1,6 +1,6 @@
import { useState, useEffect } from "react";
import { Groq } from "groq-sdk";
-import type { StatusState } from "../../types/status";
+import type { StatusState } from "../types/status";
export function useGroqConnection(token?: string): StatusState {
const [status, setStatus] = useState