Skip to content

Commit

Permalink
renaming of tools files
Browse files Browse the repository at this point in the history
  • Loading branch information
yunusj committed Nov 25, 2024
1 parent d587a61 commit 20eda0b
Show file tree
Hide file tree
Showing 11 changed files with 41 additions and 37 deletions.
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,15 @@ Marvel AI is an open-source project by Reality AI, designed to provide smart too
## Architecture
The "Marvel" platform is structured into two main components: Firebase and AI. The Firebase side, detailed in this repository, encompasses both the frontend, developed with NextJS and hosted on Firebase Hosting, and the backend, which includes user management and session handling via Firebase Functions like `signUpUser` and `createChatSession`. The `communicator` function acts as a proxy for chat interactions between the Firebase infrastructure and the AI services. Tool requests (like "Quizify" and "YouTube Flashcard Generator") are sent directly from the frontend to the AI endpoints. Firestore DB is utilized for data storage. The AI endpoints are housed in a separate repository, including a chatbot and tools like "Quizify" and "Flashcard Generator."

![Architecture Diagram](https://github.com/marvelai-org/marvel-platform/blob/2400bf1b10af77b57976778a108f3f2296aa5215/Marvel%20Architecture.png)

### Folder Structure
## Folder Structure Overview

- **`/`**:
Standard firebase project structure, having frontend in the root and functions in the functions folder.
Standard firebase project structure, having frontend, NEXTJS files in the root and backend in the functions folder.

- **`/functions`**:
Houses the Firebase Functions, which are serverless functions responsible for backend processes such as AI chatbot and tools communicators
Houses the Firebase Functions, which are serverless functions responsible for backend processes such as AI chatbot and user signup. Any operation which is sensitive or compute intensive or background tasks should be placed in functions.

## Key Files
- **`firebase.json`**:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ import { TOOLS_ID } from '@/constants/tools';
import styles from './styles';

import FlashCardsOutput from './toolRenderers/FlashCardsOutput';
import MultipleChoiceQuizOutput from './toolRenderers/MultipleChoiceQuizOutput';
import QuizQuizOutput from './toolRenderers/QuizQuizOutput';

import { convertToUnixTimestamp } from '@/utils/FirebaseUtils';
import { copyToClipboard, exportToCSV } from '@/utils/ToolHistoryUtils';

const DRAWER_RENDERERS = {
[TOOLS_ID.GEMINI_QUIZIFY]: MultipleChoiceQuizOutput,
[TOOLS_ID.GEMINI_DYNAMO]: FlashCardsOutput,
[TOOLS_ID.QUIZ_GENERATOR]: QuizQuizOutput,
[TOOLS_ID.FLASHCARDS_GENERATOR]: FlashCardsOutput,
};

const DEFAULT_DATA = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Grid, List, ListItem, Typography } from '@mui/material';

import styles from '../styles';

const MultipleChoiceQuizOutput = ({ data }) => {
const QuizQuizOutput = ({ data }) => {
const panelData = data?.response || [];

const renderExplanation = (explanation) => {
Expand Down Expand Up @@ -51,4 +51,4 @@ const MultipleChoiceQuizOutput = ({ data }) => {
);
};

export default MultipleChoiceQuizOutput;
export default QuizQuizOutput;
4 changes: 2 additions & 2 deletions constants/tools.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const TOOLS_ID = {
GEMINI_QUIZIFY: '0',
GEMINI_DYNAMO: '1',
QUIZ_GENERATOR: '0',
FLASHCARDS_GENERATOR: '1',
WORKSHEET_GENERATOR: '2',
SYLLABUS_GENERATOR: '6',
};
Expand Down
35 changes: 20 additions & 15 deletions firestore.rules
Original file line number Diff line number Diff line change
@@ -1,24 +1,29 @@
rules_version = '2';

service cloud.firestore {
match /databases/{database}/documents {
match /users/{userId} {
allow read: if true; // Allow all read operations
allow write: if request.auth.uid != null
&& request.auth.uid == userId // Ensure the user is the owner
match /users/{uid} {
// Allow read access to all users
allow read: if true;

// Allow write access only if the user is authenticated and is writing to their own document
allow write: if request.auth != null && request.auth.uid == uid;
}

match /chatSessions/{sessionId} {
allow read, write: if request.auth != null && resource.data.user.id == request.auth.uid;
allow write: if request.auth.uid != null; // Allow write if user is authenticated

match /chatSessions/{id} {
allow read: if true;
// Allow write access if the user is authenticated and the document's userId matches the authenticated user's ID
allow write: if request.auth != null && request.resource.data.userId == request.auth.uid;
}

match /tools/{toolId} {
allow read, write: if true; // Example rule allowing all read and write operations for tools
// Adjust read and write rules as per your application's needs
match /toolSessions/{id} {
allow read: if true;
// Allow write access if the user is authenticated and the document's userId matches the authenticated user's ID
allow write: if request.auth != null && request.resource.data.userId == request.auth.uid;
}
match /toolSessions/{sessionId} {
allow read: if request.auth != null; // Allow read if user is authenticated
allow write: if request.auth != null; // Allow write if user is authenticated

match /tools/{id} {
allow read: if true;
}
}
}
}
1 change: 0 additions & 1 deletion templates/ToolPage/MultipleChoiceResponse/index.js

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { useSelector } from 'react-redux';

import styles from './styles';

const MultipleChoiceResponse = () => {
const QuizResponse = () => {
const { response } = useSelector((state) => state.tools);

const hasTitle = false;
Expand Down Expand Up @@ -60,4 +60,4 @@ const MultipleChoiceResponse = () => {
</Fade>
);
};
export default MultipleChoiceResponse;
export default QuizResponse;
1 change: 1 addition & 0 deletions templates/ToolPage/QuizResponse/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from './QuizResponse';
File renamed without changes.
6 changes: 3 additions & 3 deletions templates/ToolPage/ToolPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import ROUTES from '@/constants/routes';
import { TOOLS_ID } from '@/constants/tools';

import FlashCardList from './FlashCardList';
import MultipleChoiceResponse from './MultipleChoiceResponse';
import QuizResponse from './QuizResponse';
import styles from './styles';
import SyllabusGeneratorResponse from './SyllabusGeneratorResponse';
import ToolForm from './ToolForm';
Expand All @@ -26,8 +26,8 @@ import { resetCommunicator, setFormOpen } from '@/redux/slices/toolsSlice';
import theme from '@/theme/theme';

const RESPONSE_OUTPUTS = {
[TOOLS_ID.GEMINI_DYNAMO]: FlashCardList,
[TOOLS_ID.GEMINI_QUIZIFY]: MultipleChoiceResponse,
[TOOLS_ID.FLASHCARDS_GENERATOR]: FlashCardList,
[TOOLS_ID.QUIZ_GENERATOR]: QuizResponse,
[TOOLS_ID.WORKSHEET_GENERATOR]: WorksheetGeneratorResponse,
[TOOLS_ID.SYLLABUS_GENERATOR]: SyllabusGeneratorResponse,
};
Expand Down
12 changes: 6 additions & 6 deletions utils/ToolUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const getToolData = (props) => {
const { toolId, item } = props;

switch (toolId) {
case TOOLS_ID.GEMINI_QUIZIFY: {
case TOOLS_ID.QUIZ_GENERATOR: {
const title = `Multiple Choice Assessment - ${item.topic}`;
const description =
item.description ||
Expand All @@ -31,7 +31,7 @@ const getToolData = (props) => {
...item,
};
}
case TOOLS_ID.GEMINI_DYNAMO: {
case TOOLS_ID.FLASHCARDS_GENERATOR: {
const concepts = item.response?.map((card) => card.concept) || [];
const primaryConcept = concepts[0] || 'Various Concepts';

Expand All @@ -48,16 +48,16 @@ const getToolData = (props) => {
const title = `Flashcards on ${primaryConcept} and More`;
const description = `Includes concepts like ${notableConcepts}`;
const flashCards = item.response;
const dynamoBackgroundImgURL =
const flashcardBackgroundImgURL =
'https://firebasestorage.googleapis.com/v0/b/kai-ai-f63c8.appspot.com/o/Dynamo.png?alt=media&token=db14183f-a294-49b2-a9de-0818b007c080';
const dynamoLogo =
const flashcardLogo =
'https://firebasestorage.googleapis.com/v0/b/kai-ai-f63c8.appspot.com/o/YoutubeLogo.png?alt=media&token=2809083f-f816-41b6-8f86-80582b3da188';

return {
title,
description,
backgroundImgURL: dynamoBackgroundImgURL,
logo: dynamoLogo,
backgroundImgURL: flashcardBackgroundImgURL,
logo: flashcardLogo,
output: flashCards,
...item,
};
Expand Down

0 comments on commit 20eda0b

Please sign in to comment.