Slides
Prompts
01. Write step-by-step guide based on the preferred tech stack
I want to learn how to build a AI Chat web app using React and Firebase.
Here's the tech stack I want to used:
Frontend:
- React 18 (typescript) with Vite: For building the user interface.
- React Router v6: For client-side routing.
- React useContext: For context and global state management.
- Shadcn UI: For building the UI components.
- Tailwind CSS: For styling components.
- Framer Motion: For animations and transitions.
- Lucide React: For icons.
- Sonner: For displaying toast notifications.
Backend:
- Firebase: For database and backend logic.
- Firebase Firestore: For database.
AI Integration:
- Firebase AI Logic: For calling the Gemini AI API via Firebase JS SDK.
Authentication:
- Firebase Auth: For authentication for both frontend and backend. The frontend will use the Firebase JS SDK (modular) and the backend will use the Firebase Admin SDK.
Note that this AI Chat web app is frontend only app. No backend server. We will be using Firebase Auth for authentication.
Firestore is used for storing the user's messages and the AI's responses. Since there is no backend server, we will need to setup a strong security rules for the Firestore database so that only the authenticated users can access their own data and not other users' data. We need to make this as secure as possible.
As for the AI part, we will be using Firebase AI Logic so that we don't need to have a backend to call the Gemini API. We will be using the Firebase JS SDK to call the Gemini API.
Help me compile a detailed and comprehensive step-by-step guide on how to do this.
Make sure to use the latest information only.
The guide needs to start from the beginning and end with the advanced stuff.
02. Use the guide to generate project rules
{{_GUIDE_HERE_}}
===============================================
Based on the guide above, help me do a research and create a project rules document for a project to create a Frontend only web application using React and supported Firebase services for authentication, database, and AI services.
You need to keep the project rules document generic so that it can be used for any type of web application.
03. My React + Firebase Project Rules
04. Brainstorm for requirements
I have a frontend-focused web app idea I'd like to develop using React with Vite for the frontend and Firebase services for the backend infrastructure.
Here's my initial concept:
-----
{{_IDEA_}}
-----
I'm looking to collaborate with you to turn this into a detailed project request. As we develop this project, I want you to:
1. Use web_search tools if you need more information to clarify the request
2. If the project involves rich text editing with TipTap, use the docs-mcp server to gather information:
- Call list_doc_sources tool to get the available llms.txt file
- Call fetch_docs tool to read it
- Reflect on the URLs in llms.txt
- Reflect on the input question
- Call fetch_docs on any URLs relevant to the question
- Use this information to provide comprehensive TipTap implementation guidance
3. Document which sources were used for each finding
4. Help me craft optimal solutions following the project rules.
Let's iterate together until we have a complete request that I find to be comprehensive and well-architected.
After each of our exchanges, please return the current state of the request in this format:
```request
# Project Name
## Project Description
[Description]
## Target Audience
[Target users]
## Research Findings
### Documentation References
- [ ] [Key documentation reference]
- [ ] [Relevant details from documentation]
### Best Practices
- [ ] [Researched best practice]
- [ ] [Implementation consideration]
## Desired Features
### [Feature Category]
- [ ] [Requirement]
- [ ] [Sub-requirement]
## UI/UX Design Concept
### Visual Design
[Describe the overall visual aesthetic, color schemes, typography choices, and design philosophy. Include references to modern design trends like glassmorphism, dark mode preferences, micro-animations, etc.]
### Layout Structure
[Detail the main layout components including navigation patterns, responsive breakpoints, sidebar/header arrangements, and how content areas are organized]
### User Flow
[Explain the primary user journeys through the application, from entry points to key actions, including authentication flows, onboarding sequences, and task completion paths]
### Interactive Elements
[Describe hover states, transitions, loading states, error states, and micro-interactions that enhance the user experience]
### Accessibility Considerations
[Outline ARIA labels, keyboard navigation support, color contrast requirements, and other accessibility features]
## Design Requests
- [ ] [Specific design requirement]
- [ ] [Design detail]
## Type Definitions
### User Types
- User
- uid: unique identifier
- email: user email address
- displayName: optional display name
- photoURL: optional profile photo URL
- role: user role (user, admin, etc.)
- createdAt: timestamp of account creation
- [additional user fields]
### [Feature Entity Types]
- [EntityName]
- id: unique identifier
- [field]: [description and constraints]
- [field]: [description and constraints]
- createdAt: timestamp
- updatedAt: timestamp
### [Additional Entity Types]
- [EntityName]
- [field]: [description and constraints]
- [relationships to other entities]
### Enums and Constants
- [EnumName]
- [VALUE]: [description]
- [VALUE]: [description]
## Technical Requirements
### Frontend (React/Vite)
- [ ] [Implementation requirement]
- [ ] [Specific feature to utilize]
### Firebase Services Architecture
- [ ] [Firestore Database Design]
- [ ] [Collection structure]
- [ ] [Document schema]
- [ ] [Firebase Authentication]
- [ ] [Auth providers to implement]
- [ ] [User profile management]
- [ ] [Firebase Storage]
- [ ] [File types and organization]
- [ ] [Firebase AI Logic/Gemini API]
- [ ] [AI features to implement]
- [ ] [Security Rules]
- [ ] [Firestore rules]
- [ ] [Storage rules]
### State Management
- [ ] [React Context providers needed]
- [ ] [Custom hooks to create]
### Cloud Functions (Background Only)
- [ ] [Authentication triggers]
- [ ] [Firestore triggers]
- [ ] [Scheduled functions]
## Project Structure
- [ ] [Folder organization following the recommended structure]
- [ ] [Key files and their purposes]
## Performance & Security Considerations
- [ ] [Performance optimizations]
- [ ] [Security measures]
- [ ] [Cost optimization strategies]
## Other Notes
- [Additional considerations]
```
Please:
1. Use web_search tool if you need more information to clarify the request
2. For TipTap or other rich text editing needs, use the docs-mcp server as described above
3. Ask me questions about any areas that need more detail
4. Suggest features or considerations I might have missed, based on your research
5. Show me the current state of the spec after each exchange
6. Flag any potential technical challenges or important decisions regarding:
- React 19+ implementation with concurrent features
- Firestore database design and denormalization strategies
- Real-time data synchronization patterns
- Authentication flow with multiple providers
- AI integration with Firebase AI Logic/Gemini API
7. Recommend appropriate UI/UX features using Shadcn UI and Tailwind CSS, ensuring the design creates an engaging, modern experience
8. Advise on best practices for Firebase implementation including:
- Optimal Firestore data structure for minimizing reads
- Security rules that enforce data integrity
- Cloud Functions usage (remember: background triggers only, no REST APIs)
- File storage organization and optimization
- Cost-effective query patterns
9. Suggest project structure that follows the frontend-first architecture principles
10. Define comprehensive type structures that support TypeScript's strict mode and enable excellent developer experience
We'll continue iterating and refining the request until I indicate it's complete and ready. I want to ensure the project leverages Firebase's strengths like:
- Real-time data synchronization with Firestore
- Comprehensive authentication with multiple providers
- Serverless backend with Cloud Functions (for background tasks only)
- Integrated AI capabilities with Gemini API
- Robust security with Firebase Security Rules
- File storage with automatic CDN distribution
- Frontend-first architecture with minimal backend complexity
Let's start by discussing my concept and identifying the key components that would benefit from Firebase's services while maintaining a simple, frontend-focused architecture.
05. Generate FireStore Schema and Complete User Journey
Based on the requirements and the project rules, give me the whole Firestore Schema and its security rules (put this in one artifact). Then, give me the complete user journey flow for this web app (put this in another artifact).
06. Add Complete Project Structure in the Requirements
Help me update the Project requirements by adding in the complete recommended project structure
07. Generate UI Design
First, read the following files:
- @notes/rules.md
- @notes/requirements.md
- @notes/user_journey.md
- @notes/firestore_schema.md
Then, think hard about the project, and craft a plan to create a complete, production-ready HTML UI design based on the provided project specification. The HTML will eventually be converted to a React application, so include appropriate annotations.
## Instructions:
### 1. Project Analysis
**Carefully analyze the project specification** including:
- Project description and target audience
- Desired features and functionality
- UI/UX design concepts and requirements
- Technical requirements and architecture
- User journey and workflows
- Data types and structures
### 2. File Organization
**Create multiple HTML files** organized as follows:
#### File Structure:
```
│ ├── pages/ # Page components
│ │ ├── landing-page.tsx
│ │ ├── login-page.tsx
│ │ ├── signup-page.tsx
│ │ ├── dashboard-page.tsx
│ │ ├── new-session-page.tsx
│ │ ├── review-session-page.tsx
│ │ ├── session-history-page.tsx
│ │ ├── session-detail-page.tsx
│ │ ├── categories-page.tsx
│ │ └── not-found-page.tsx
```
#### Naming Conventions:
- Use lowercase with hyphens for file names (e.g., `user-profile.html`, `category-management.html`)
- Name files based on their primary function or feature
- Keep names concise but descriptive
#### When to Split Files:
- Create separate files for distinct user flows
- Split when a page has fundamentally different layout/navigation
- Separate authenticated vs. non-authenticated views
- Isolate complex features that would make a single file unwieldy
- Consider creating 3-8 HTML files for a typical application
### 3. Cross-File Considerations
- Include navigation links between pages using standard `<a href="...">` tags
- Maintain consistent header/navigation across files
- Use the same CDN links and base styles in each file
- Include comments indicating which page links to which
- Add `<!-- @ROUTE: /path/to/page -->` annotations for React Router planning
### 4. Technology Stack
**Use the following technologies in each file**:
- Tailwind CSS (via CDN) for styling
- Font Awesome icons (via CDN) for iconography
- Modern semantic HTML5
- Vanilla JavaScript for interactions (can be shared via `<script>` tags)
- Custom CSS animations where appropriate
### 5. React Conversion Annotations
**Include these annotations throughout all files**:
- Mark components with `<!-- @COMPONENT: ComponentName [description] -->`
- Mark state with `<!-- @STATE: stateName:type = defaultValue -->`
- Mark events with `data-event="eventType:handlerName"`
- Mark data bindings with `data-bind="dataPath"`
- Mark mock data with `data-mock="true"`
- Mark lists with `<!-- @MAP: array.map(item => ( -->` and `<!-- @END_MAP )) -->`
- Add implementation notes with `data-implementation="description"`
- Add functionality notes with `<!-- @FUNCTIONALITY: description -->`
- Add route annotations with `<!-- @ROUTE: /path -->` at the top of each page
### 6. Component Sharing Strategy
For components that appear across multiple pages:
- Implement fully in the first occurrence
- In subsequent files, use simplified versions with a comment: `<!-- @COMPONENT_REF: ComponentName (see index.html) -->`
- This shows placement without duplicating complex code
### 7. Design Guidelines
**For each file, maintain**:
- Clean, modern interface that matches the project's tone
- Consistent spacing, typography, and color schemes
- Proper visual hierarchy
- Loading states, empty states, and error states where appropriate
- Smooth transitions and micro-interactions
- Accessibility with proper ARIA labels and semantic HTML
### 8. Required UI Elements
**Include across files as appropriate**:
- Navigation (consistent header/nav, contextual sidebars)
- Forms with validation states
- Buttons with hover/active states
- Cards, lists, and data displays
- Modals, dropdowns, and overlays (define once, reference elsewhere)
- Status indicators and progress bars
- Empty states and loading skeletons
### 9. JavaScript Functionality
**Organize JavaScript as follows**:
- Include page-specific JavaScript in each file
- For shared functionality, include a comment: `<!-- @SHARED_SCRIPT: functionality-name -->`
- Demonstrate interactions relevant to each page
- Show/hide modals and dropdowns
- Toggle states and UI elements
- Simulate data updates
- Handle responsive behavior
### 10. File-Specific Requirements
#### For index.html:
- Include global styles and configurations
- Define color schemes and CSS variables
- Show the main entry point or dashboard
- Include primary navigation structure
#### For auth.html:
- Login and signup forms
- Password reset flow
- Social authentication options
- Form validation examples
#### For feature pages:
- Focus on specific functionality
- Include relevant modals/overlays
- Show different states of the feature
- Include feature-specific navigation
### 11. Data Representation
**In each file**:
- Use realistic mock data relevant to that page
- Show different states (loading, success, error, empty)
- Demonstrate data relationships
- Include variety to show edge cases
### 12. Responsive Design
**Ensure each file has**:
- Mobile-first approach
- Proper breakpoints
- Touch-friendly interfaces
- Collapsible menus and adaptive layouts
### 13. Output Format
Here are the locations of the files that you will create:
- @notes/ui/landing-page.html
- @notes/ui/login-page.html
- @notes/ui/signup-page.html
- @notes/ui/dashboard-page.html
- @notes/ui/new-session-page.html
- @notes/ui/review-session-page.html
- @notes/ui/session-history-page.html
- @notes/ui/session-detail-page.html
- @notes/ui/categories-page.html
- @notes/ui/not-found-page.html
### 14. Quality Standards
Each HTML file should:
- Be a complete, valid HTML document
- Include all necessary meta tags and viewport settings
- Have organized, commented code
- Work independently while maintaining visual consistency
- Accurately represent the application's functionality
- Be detailed enough for straightforward React conversion
Remember: These HTML files collectively form a high-fidelity prototype that accurately represents the final application's look, feel, and functionality. They should be comprehensive enough that a React developer can understand the component structure, routing needs, and state management requirements for the entire application.
08. Generate Implementation Plan
Based on the requirements, Firestore schema, user journey, proposed UI for this web app and the project rules, please create a detailed implementation plan for the project.
The implementation plan should focus on the following phrases:
0/ Project setup and configuration:
- In this phrase, we will setup the project, install the dependencies, and configure the project.
1/ App structure setup:
- In this phrase, we will create the:
- Folder structure and file organization
- Setup the types and interfaces
- Setup the utils and helpers in the lib folder
2/ Project hooks and context:
- In this phrase, we will create the:
- Project hooks in the hooks folder
- Project context and providers in the context folder
3/ Project main layout and authentication components:
- In this phrase, we will create the:
- Project main layout in the components/layout folder
- Project authentication components in the components/auth folder
4/ Project features and its components:
- In this phrase, we will create the
- project features and its components in the components/{feature_name} folder
5/ Project pages:
- In this phrase, we will create the:
- Project pages in the pages folder
6/ Setup App.tsx:
- In this phrase, we will create the:
- App.tsx for the main app component. This is the entry point of the app. It should have all the providers, routes, and any other global setup needed.
7/ Cloud functions:
- In this phrase, we will create the
- Cloud functions for the app in the functions folder. This will include all the background triggers, and the scheduled functions needed for the app.
The implementation plan should be in checklist format. No need to include any codes yet. However, you can include the file names, the folder names, what libraries to use or install, some code snippets (ONLY if you deem it absolutely necessary).
Put it in an artifact
09. Implement One Section at a time
Based on the @notes/plan.md , help me implement the below:
{{_STEP_}}
Now, think harder, plan properly, create a todo list, and then execute the tasks. Once you've done , please update the @notes/plan.md
if you are working on any UI component or page, make sure to read the UI design in @notes/ui/ first. For example:
- if you are working on the {{_PAGE_1_}} or its components, read the {{_PAGE_1_}}.html file.
- if you are working on the {{_PAGE_2_}} or its components, read the {{_PAGE_2_}}.html file.
- if you are working on the {{_PAGE_3_}} or its components, read the {{_PAGE_3_}}.html file.
- If you are working on the {{_PAGE_4_}} or its components, read the {{_PAGE_4_}}.html file.
...{{_CONTINUE_FOR_MORE_PAGES_}}
This is just reference, you don't need to follow it exactly. You should always prioritize using the shadcn ui components and the shadcn ui design system. Only if you are sure that the shadcn ui component is not available, you can create a custom component. If you need to create custom styling, please use tailwind css. Only use custom css if the styling you need cannot be achieved with tailwind css.
If you need any info about any libraries, sdk, or documentation, you can use web search to look for more information.
Lastly, please update the @CLAUDE.md file with the current context of the project.
10. Claude Code Command: Prime.md
# Context Prime
> Follow the instructions to understand the context of the project.
## Run the following command
eza . --tree -git-ignore --ignore-glob="node_modules|.git|tmp"
## Read the following files
> Read the files below and nothing else.
CLAUDE.md
notes/rules.md
notes/requirements.md
notes/user_journey.md
notes/firestore_schema.md
notes/plan.md
11. Claude Code Command: Lint fixes
- Run `npm run lint` to check for linting errors
- If errors are found:
a. Analyze each error type and location
b. Read the affected files and understand the context
c. Apply appropriate fixes based on ESLint rules
d. Save the fixed files
e. Re-run `npm run lint` to verify fixes
f. Repeat this process until no errors remain
- Document any manual fixes that were needed
12. Claude Code Command: Type check and fix
- Run `npx tsc --noEmit --project tsconfig.app.json` to check for TypeScript errors
- If errors are found:
a. Analyze each TypeScript error carefully
b. Read the affected files and understand the type issues
c. Apply appropriate type fixes (add type annotations, fix type mismatches, etc.)
d. Save the fixed files
e. Re-run `npx tsc --noEmit --project tsconfig.app.json` to verify fixes
f. Repeat this process until no errors remain
- You can ignore errors are primarily missing implementations rather than fundamental type conflicts.
- Document any complex type fixes applied
13. Use extended thinking mode for bug fixes
Analyze and think about what could be the potential problem, list down all the potential causes, single out the most likely cause of this issue, craft a plan on how to solve this, and then execute it.
14. Ask AI to log all the steps
in @{{_FILE_}}, I having issue of {{_ISSUE_}}.
I want to {{_DESIRED_RESULT_}}. Please put console log across the file so that I can know exactly where went wrong.
Useful Links and Resources
Leave a Reply