Open sammybigbux opened 2 hours ago
Hi @sammybigbux
Shreyansh this side, Can you please provide access to the Figma. Would love to have a quick meeting with you over the Ui revamp plan.
I have mostly worked with NextJs(React) & TailwindCSS. This is an ideal project for me as per my expertise. Let's collaborate.
@sammybigbux saw your google drive's video, If the Ui shown in the video is the expected output I will convert the UI into pixel perfect frontend, ensuring responsiveness in layout across all devices. With expected frontend functionality with clean code.
Let me know if we can connect!
Best Regards Shreyansh www.shreyanshkr.com www.tellcrow.com
DeckHub Frontend Development Guide
Welcome to the DeckHub project! This project is an interactive platform designed to help students prepare for certification exams using modern cognitive research techniques. DeckHub offers multiple-choice and open-ended question formats, with real-time feedback to guide learners through exam content.
Issue Overview
DeckHub is undergoing a UI redesign to improve user experience. Your task as the frontend developer is to implement the new UI based on the wireframe provided in Figma and apply it to the existing platform.
Key Resources:
You can test your changes by either running the project locally (setup instructions are provided later in this document) or by pushing to the
staging
branch to deploy the updates to our cloud environment.The following sections will guide you through the project structure and the steps required to set up and deploy the project.
Local Setup
Secure files from Google Drive are required to host this locally but if you push to
staging
branch the Github Actions will deploy to Google Cloud.Install dependencies:
Set up a
.env
file in the main directory:Set up a
.env
file in the backend directory:Navigate to the backend directory and install Python requirements:
Place the
firebase_key.json
file into the backend directory:Create an OpenAI assistant and update the assistant ID:
assistant_id
at the top of theapp.py
file to the assistant you created. You will need to replace the current assistant ID with the one generated from the assistant you're using:Run the backend:
/src/backend
directory, start the backend server:Run the frontend:
Project Structure
You can find a guide to each section in the README.md files in their respective directories. The project consists of the following main components:
Frontend: Located in the
/routes
directory, the frontend is built using Vite and Svelte. It handles the user interface, interactions, and communication with the backend services.Backend: Found in the
/src/backend
directory, the backend is built using Flask. It handles API endpoints, user sessions, and database interactions via Firebase. The backend also includes routes for managing userFront end overview
The frontend of the platform is built using Svelte with TypeScript and utilizes Svelte stores for state management, Firebase for authentication (
userId
,isLoggedIn
), and Skeleton UI for components like Avatars and ProgressBars. It interacts with a backend hosted on either localhost or a cloud server (base_url
).Key Pages and Functionality
1. My-Cards Page (
my-cards.svelte
)allDecks
anduserOwnedDeckNames
store the available decks and the decks owned by the user.searchQuery
stores the search input, and the derived storefilteredDecks
filters decks based on the search query and ownership.handleInput
updates the search input field./get_decks
endpoint and then fetches the user-specific decks using the/get_user_decks
endpoint, passing the Firebase token for authentication (idToken
).2. Search Page (
search.svelte
)searchQuery
is used to store user input from the search bar.decks
holds all decks fetched from the backend.filteredDecks
is derived fromsearchQuery
anddecks
to filter the decks based on the user’s input.handleInput
updatessearchQuery
as the user types./get_decks
to populatedecks
. Additionally, it fetches the user’s decks via/get_user_decks
using the Firebase token (idToken
).3. User-Info Page (
user-info.svelte
)tabSet
tracks which tab (Payment Information, Past Orders, Funding, Log out) is currently active.onMount
: Checks the URL hash to set the active tab.4. Chat Pages (Learn, Understand, Apply)
The chat pages (e.g.,
learn-multiple
,learn-open
,understand-multiple
,apply-multiple
) are built on similar structures with differences based on the mode (multiple choice or open-ended).Learn-Multiple Page (
learn-multiple.svelte
)messageFeed
holds the conversation history.related_terms
holds terms related to the current question.currentTerm
andcurrentQuestionData
store the current question’s data.retrieveTermsData
: Fetches the user's progress (total and solved terms).retrieveQuestion
: Fetches the next question from the backend and updates the chat.displayAnswerResponse
: Displays feedback (correct/incorrect) when the user answers a question.toggle_multi
: Switches between multiple-choice and open-ended modes.updateStatus
: Updates the user’s progress after answering correctly.sendMessage
: Sends a user query to the backend and streams back a response.Learn-Open Page (
learn-open.svelte
)learn-multiple
but for open-ended questions.change_difficulty
adjusts the AI's response difficulty.General Components
Across all pages, common components include:
Firebase Integration
userId
store from Firebase handles user authentication.onAuthStateChanged
) is used to get the user’s token (idToken
), which is required for accessing protected routes like/get_user_decks
and/get_terms_data
.Svelte Lifecycle Hooks
cleanupEnv
ensures the user’s environment is reset when they leave the chat pages.Conclusion
The frontend of the platform is a combination of Svelte’s reactivity, store management, Firebase authentication, and backend interactions. Each page is structured around a core set of stores (
decks
,userDecks
,messageFeed
) and functions (retrieveQuestion
,sendMessage
,updateStatus
) that ensure a dynamic and interactive learning experience for users. The UI is cleanly structured with Skeleton UI components to enhance visual consistency across the platform.Backend Structure Overview
The backend primarily consists of:
app.py
): This contains the core logic for handling requests from the frontend, interacting with Firebase Firestore and Cloud Storage, and managing users and terms through helper classes.UserManager
: Manages users, their sessions, and their data files.TermManager
: Manages the terms and their statuses for each user.firebase_admin_init_cloud.py
: Initializes Firebase Admin SDK for cloud deployments using credentials stored in Secret Manager.firebase_admin_init_local.py
: Initializes Firebase Admin SDK for local deployments using a service account file stored locally.Application Workflow
app.py
The
app.py
file defines the main Flask application that handles various endpoints. It handles:/initialize_env
,/cleanup_env
)/start_thread
,/send_message
)/get_terms_data
,/get_question
,/update_status
, etc.)/create_user_if_not_exists
,/api/create-checkout-session
,/webhook
)Key components include:
Firebase Setup:
terms.json
files for each user.Data Loading:
learn_data.json
,understand_data.json
, andapply_data.json
from thestatic_data
directory. These are used in various term-based operations.User and Term Management:
UserManager
andTermManager
for managing user sessions and interacting withterms.json
.UserManager
handles downloading/uploading the user’sterms.json
from/to Cloud Storage and initializing sessions.TermManager
handles loading the user's terms data, providing questions, and updating the status of terms.Helper Classes
UserManager
TermManager
instance is created to handle the user's interaction with the current module (learn, understand, apply).terms.json
file is downloaded from Cloud Storage (or initialized with default terms) when a session is started and uploaded when the session ends.initialize_user_session
: Initializes a user’s session, creates aTermManager
for them, and retrieves theirterms.json
file.manage_user_json
: Downloads the user'sterms.json
from Cloud Storage if it exists, or creates one from a default template if it doesn't.cleanup_user_session
: Uploads theterms.json
file back to Cloud Storage and deletes the local file when the session is cleaned up.TermManager
terms.json
._read_json
: Reads the user'sterms.json
.write_terms_to_file
: Writes the updated terms toterms.json
at the end of the session.retrieve_question
: Retrieves a question for the user based on their unsolved terms.update_status
: Updates the status of a term to mark it as solved.get_correct_response
andget_incorrect_response
: Fetch correct or incorrect responses for terms.Firebase Initialization Files
firebase_admin_init_cloud.py
firebase_admin_init_local.py
firebase_key.json
file for local development.GitHub Actions CI/CD System Summary
The project uses GitHub Actions to automate the deployment of both the backend and frontend. Separate workflows handle deployments to the production and staging environments for both the backend and frontend.
1. Backend Deployment to Production (
deployment-production-backend.yml
)main
branch and those changes are within thesrc/backend/
directory.actions/checkout@v4
.OPENAI_API_KEY
,STRIPE_SECRET_KEY
, etc.unittest
.2. Frontend Deployment to Production (
deployment-production-frontend.yml
)main
branch.actions/checkout@v4
.npm ci
andnpm run build
.https://deckhub.web.app/
).3. Backend Deployment to Staging (
deploy-staging-backend.yml
)staging
branch and only runs if there are changes in thesrc/backend/
directory.actions/checkout@v4
.unittest
, but this time against the staging URL (https://deckhub-backend-staging-1086653848406.us-central1.run.app
).4. Frontend Deployment to Staging (
deploy-staging-frontend.yml
)staging
branch.actions/checkout@v4
.npm ci
andnpm run build
.https://deckhubapp--staging-8dva1oxn.web.app/
).