A shared tag with AI prompts and code snippets
From workspace: Replit
Team: AI Prompts
Total snippets: 79
79 snippets
Package and host full finance tracker with Flask and React on Replit.
Replit deployment steps: – Use Flask + React project setup – Move backend to `/backend`, frontend to `/frontend` – Add OpenAI key in `.env` – Run Flask + React servers – Validate app shows dashboard, accepts entries, and calls OpenAI
Let users view expenses and summaries for custom date ranges.
Add date pickers in dashboard: – Filter shown expenses by start & end date – Update chart + AI summary accordingly Send selected range to `/expenses?from=...&to=...`
Show OpenAI-generated weekly spending summary in UI.
Add a new React section: – On load, call `/summary` endpoint – Show AI feedback (1–2 paragraphs) – Update automatically every Sunday
Send expenses to OpenAI to get financial behavior feedback.
Create a new Flask endpoint `/summary`: – Reads `expenses.json` – Sends data to OpenAI Chat API with prompt: "Analyze this week's expenses. Highlight overspending, trends, and improvement tips." Return short paragraph summary.
Display all expenses grouped by category with totals.
Create a dashboard in React: – Show total spending this week – Show per-category totals – Use a chart or card layout Use `/expenses` endpoint to get data.
Persist expenses on backend using a simple JSON file.
Update Flask logic to save submitted expenses to `expenses.json`. – On each POST: append to file – Add GET `/expenses` to return all Ensure file is created if not found.
Send submitted expenses from frontend to backend API.
Use Axios or Fetch to send expense data to `/expense`. Show: – Loading state while sending – Success confirmation – Reset form after submission
Build a backend endpoint that receives and stores submitted expenses.
Create a Flask endpoint `/expense` that: – Accepts POST requests – Accepts JSON with amount, category, description – Stores in a local list or temporary variable – Returns confirmation response Enable CORS for localhost:3000.
Create a form for users to add expense amount, category, and description.
Build a React component to add an expense. Fields: – Amount (number) – Category (dropdown: Food, Rent, Travel, Other) – Optional description – Submit button No backend integration yet.
Create frontend and backend folders for an AI-powered finance tracker app.
Create a project structure: /finance-tracker /frontend – React app /backend – Flask API Add a README: "Smart finance tracker that lets users input expenses, categorize them, and receive weekly AI-powered summaries."
Prepare and deploy the fullstack journaling app using Replit.
Guide for deploying to Replit: – Use Python + Node template – Set up `.env` with OpenAI key – Ensure Flask and React start properly – Use fetch with full paths or proxy – Test: Can user submit entry and see AI analysis?
Store past entries and feedback in localStorage for reflection.
Save each journal entry + mood + affirmations to localStorage. Show a sidebar list of past dates. When clicked, show full analysis again.
Display AI mood analysis and affirmations in the frontend.
After successful submission: – Show mood analysis – List emotional themes – Show AI-generated affirmations Use clean card layout and allow user to close feedback.
Use AI to generate daily affirmations based on journal themes.
Add OpenAI logic to return 2–3 affirmations based on journal tone/themes. Prompt format: "Generate 3 personalized affirmations for someone who feels {mood} about {themes}." Return as array of strings in JSON.
Use OpenAI API to analyze mood, tone, and themes of journal entry.
Extend the Flask endpoint to: – Use OpenAI's Chat API – Prompt: “Analyze this journal entry. Return mood, tone, and emotional themes.” – Return JSON like: { "mood": "Anxious but hopeful", "themes": ["uncertainty", "self-reflection", "growth"] }
Connect React form to Flask backend and send entry text.
Send journal entry to Flask `/entry` endpoint. Requirements: – Use Axios or Fetch with JSON body – Show 'sending' state – Confirm with success message after submission
Build a Flask API to receive and store journal text for AI processing.
Create a Flask endpoint `/entry` that: – Accepts POST requests – Receives `entry_text` from JSON body – Logs it or saves to a temporary variable for now – Returns success JSON response Enable CORS for localhost:3000.
Create a React form for users to input daily journal entries.
Create a journal entry component in React. Features: – Textarea input with 500+ character limit – Submit button – Shows word count as user types Do not connect backend yet.
Create folder layout for React + Flask app for journaling and AI feedback.
Create a project directory with: /mental-journal /frontend – React app /backend – Flask API Add README with: "Mental Health Journal app that lets users write journal entries and receive AI-powered reflections and affirmations."
Package and deploy full-stack app on Replit with environment variables.
Guide for deploying the Resume Analyzer on Replit: – Use Replit's Node + Python template – Move frontend into `/frontend` and backend in `/backend` – Add `.env` with OpenAI key – Use `flask run` + React dev server with proxy or manual fetch to...
Add basic branding and light/dark mode toggle to the app.
Improve visual style of the Resume Analyzer app. – Add a logo – Add dark/light mode toggle – Use system preference by default – Apply consistent typography + spacing
Store past resume feedback in local storage for quick access.
After each analysis, save the resume file name + feedback to localStorage. Display: – Recent resumes analyzed – Click to view past AI feedback without uploading again
Render structured resume feedback in the frontend.
Add a feedback view in React that shows: – Strengths (bullet list) – Weaknesses (bullet list) – Suggested job roles Style the layout simply and show loading while waiting for AI response.
Send extracted resume text to OpenAI API and return summary.
Add AI analysis logic to Flask: – Use OpenAI's Chat API – Prompt: "Analyze this resume and give strengths, weaknesses, and job fit" – Use extracted text as input – Return feedback to frontend Keep API key secure in .env.
Extract text from uploaded .pdf or .txt file in Flask.
Extend the `/upload` Flask endpoint to: – If file is .txt → read with open() – If file is .pdf → extract text using `PyMuPDF` or `pdfminer.six` – Return extracted text in JSON: `{ text: "..." }`
Connect the React frontend to Flask backend for file uploads.
Using Axios or Fetch, send the uploaded file from React to Flask `/upload`. Requirements: – Use FormData – Show success or error message on response – Display loading state during upload
Build a Flask endpoint to receive uploaded resume files.
Create a Flask endpoint `/upload` that: – Accepts POST requests – Accepts file via `request.files['resume']` – Saves file temporarily to disk – Returns success response with file name Enable CORS for localhost:3000 (React client).
Create a file input component in React for PDF or TXT resumes.
Build a React component for uploading a resume file. Requirements: – Accept only .pdf or .txt – Allow drag-and-drop and click-to-upload – Show filename preview once selected Do not yet send the file — just capture it.
Create frontend and backend folders for a resume review app.
Create a new project directory with this structure: /resume-analyzer /frontend – React app /backend – Flask API Add a README.md with the project goal: "Analyze uploaded resumes using an AI backend and return job-fit suggestions."
Check a Bash script for dangerous patterns or unsafe commands.
Review this Bash script. Find insecure command usage or practices. Script: #!/bin/bash FOLDER=$1 rm -rf $FOLDER
Review use of JWTs for access control and storage strategy.
Review the security of this JWT usage. What’s good, what’s missing, what’s risky? Code: const token = jwt.sign({ id: user.id }, 'secret', { expiresIn: '1h' }); res.cookie('token', token);
Review how passwords are stored and suggest secure practices.
Is this password storage safe? Suggest a secure alternative. Code: const users = []; function register(username, password) { users.push({ username, password }); }
Check frontend code for potential XSS vectors and output sanitization.
Find potential XSS vulnerabilities in this code. Suggest fixes or best practices. Code: <input type="text" id="nameInput" /> <div id="greeting"></div> <script> const name = document.getElementById('nameInput').value; ...
Detect and fix potential SQL injection in backend code.
Review this Python code for SQL injection risks. Suggest secure fixes using parameterized queries. Code: def get_user(email): query = f"SELECT * FROM users WHERE email = '{email}'" return db.execute(query)
Write a Python script to batch rename files with a prefix.
Write a script to: – Rename all `.txt` files in a folder – Add prefix 'renamed_' to each filename – Show before/after filenames Use pathlib or os.
Build a Node.js CLI tool using Commander.js.
Build a CLI in Node.js with Commander.js that: – Has a command `hello` that takes a `--name` flag – Prints `Hello, [name]!` Show install and run instructions too.
Generate a shell script that sends a warning if disk usage exceeds 90%.
Create a shell script that: – Checks disk usage – Prints warning if > 90% – Can be run via cron Add comments for each part.
Generate a Python CLI tool that accepts arguments using argparse.
Write a Python CLI that: – Accepts two numbers – Has a flag for addition or subtraction – Prints the result Use argparse for argument parsing.
Write a Bash script to back up a folder into a timestamped archive.
Write a Bash script to: – Accept a folder path as an argument – Create a .tar.gz backup with a timestamp – Save it in a 'backups' directory Make the script safe and reusable.
Insert a new row using Supabase JavaScript client.
Use Supabase JavaScript client to insert a row. Table: profiles Fields: – id (auto) – username: 'alina' – website: 'https://snippets.ai' Include: – Setup client – Insert call – Handle result
Extract all hyperlinks from HTML using BeautifulSoup.
Use BeautifulSoup to extract all `<a href="">` links. HTML: <html> <body> <a href="https://example.com">Example</a> <a href="https://test.com">Test</a> </body> </html>
Draw a pie chart in D3.js with labels and colors.
Use D3.js to draw a simple pie chart. Data: [ {label: 'A', value: 30}, {label: 'B', value: 50}, {label: 'C', value: 20} ] Include: – Color legend – Percentage labels – SVG setup
Define a User and Post model using SQLAlchemy ORM.
Define SQLAlchemy models with relationships. Models: – User: id, name, email – Post: id, title, user_id (FK) Include: – Base class – One-to-many relationship – `__repr__` methods
Create a styled button using Tailwind utility classes.
Use Tailwind CSS to style a button. Style: – Blue background – White text – Rounded corners – Hover effect (darker blue) HTML: <button>Click Me</button>
Show how to fetch and log JSON data from an API with Axios.
Use Axios to: – Fetch data from https://jsonplaceholder.typicode.com/posts – Log first 3 post titles to the console – Handle fetch errors Explain each step.
Plot a labeled bar chart using Matplotlib.
Use Matplotlib to create a bar chart. Data: products = ['A', 'B', 'C'] sales = [120, 300, 90] Chart should: – Show labels – Add title 'Product Sales' – Color bars Also show the final rendered chart.
Demonstrate array filtering and transformation using Lodash.
Use Lodash to: – Remove falsy values – Sort array descending – Return only even numbers Input: [0, 1, false, 2, '', 3, 4]
Show how to clean and transform a CSV using Pandas.
Show how to clean this CSV using Pandas. Tasks: – Remove rows with missing 'email' – Convert 'signup_date' to datetime – Filter users with 'active' == True Data: users.csv | id | email | signup_date | active...
Describe what this TypeScript interface means and how it's used.
Explain this interface and how it might be used. Code: interface User { id: number; name: string; email?: string; } Include: – Optional fields – Common usage in function arguments
Explain how this list comprehension works and what it returns.
Explain what this list comprehension does. Code: nums = [1, 2, 3, 4, 5] squares = [x*x for x in nums if x % 2 == 0] Include: – How filtering works – Final result list
Break down what this regex pattern matches and how.
Explain what this regex pattern does. Pattern: ^([a-z0-9_\.-]+)@([\da-z\.-]+)\.([a-z\.]{2,6})$ Include: – Each group – Anchors – Common use case
Explain how this SQL query joins and filters the data.
Explain this SQL query step by step. Include: – What the JOIN is doing – How WHERE affects the result – Final output rows Query: SELECT u.name, o.total FROM users u JOIN orders o ON u.id = o.user_id WHERE o.total > 100;
Break down how an async JavaScript function executes.
Explain how this async function runs. Include: – What promises are doing – What is awaited and when – Final output order Code: async function fetchData() { const user = await getUser(); const posts = await getPosts(user.id); return {...
Explain a recursive Python function line by line in plain English.
Explain this recursive function line by line. Goal: – Help beginners understand how recursion works – Include base and recursive case flow Code: def factorial(n): if n == 0: return 1 return n * factorial(n - 1)
Convert deeply nested callbacks into async/await syntax.
This code uses nested callbacks. Refactor using async/await. Code: getUser(id, function(user) { getSettings(user, function(settings) { saveData(user, settings, function(response) { console.log('Done'); }); ...
Encapsulate global variables and functions into a class.
This code uses global state. Refactor by moving everything into a class. Code: settings = {'theme': 'dark'} def get_theme(): return settings['theme'] def set_theme(t): settings['theme'] = t
Simplify a loop using functional programming methods.
Convert the loop to a functional style using `map` or `filter`. Code: names = ['Alice', 'Bob', 'Charlie'] upper = [] for name in names: if len(name) > 3: upper.append(name.upper())
Identify repeated logic and move it to a separate method.
Refactor by extracting common logic into a new helper method. Code: public class Report { public void printDaily() { System.out.println("==== Report Start ===="); System.out.println("Date: " + today()); ...
Refactor nested if conditions into cleaner early returns.
Refactor this function by replacing deep `if` nesting with guard clauses. Goal: reduce cognitive load and improve structure. Code: function processOrder(order) { if (order) { if (order.items.length > 0) { if...
Split a long function into smaller, readable, reusable units.
Refactor this long function into smaller helper functions. Goals: – Improve readability – Make code easier to test – Avoid repetition Code: def process_user_data(user): if '@' not in user['email']: raise ValueError('Invalid email') ...
Add edge case tests for a sorting algorithm.
Add test cases for this sorting function. Cover: – Empty list – One item – Already sorted – Repeated values Code: def sort_numbers(arr): return sorted(arr)
Write test cases for an async function that fetches data.
Write Jest tests for this async function. Mock `fetch()` and test: – Successful fetch – 404 or error case – Bad JSON structure Code: async function fetchUser(id) { const res = await fetch(`/api/users/${id}`); const data = await...
Create unit tests for backend validation logic in a Node.js function.
Write unit tests using `Jest` for this validation function. Test cases: – Missing fields – Invalid email – Age < 18 – Valid input Code: function validateForm(data) { if (!data.email.includes('@')) return false; if (data.age < 18) return...
Write an integration test for a Flask endpoint using Flask's test client.
Write an integration test for this Flask route using `app.test_client()`. Test: – Valid credentials – Wrong credentials – Status codes – JSON response Code: @app.route('/login', methods=['POST']) def login(): data = request.get_json() if...
List test cases to validate behavior of SQL logic for edge input.
You are testing the following SQL query. List: – Input scenarios to test (e.g. totals = 100, NULLs) – Edge logic that may fail – Verification method for expected results Query: SELECT * FROM orders WHERE total > 100 AND status = 'confirmed';
Review a function and suggest missing test cases.
You are reviewing this function for test coverage. Identify: – Edge cases not covered – Unexpected or null input – Suggestions for improved testing Code: def format_price(value): if value is None: return "N/A" return...
Generate comprehensive unit tests for a given Python function using
You are given a Python function. Write unit tests using `pytest`. Cover: – Valid input – Invalid input – Edge cases (e.g. empty lists, negative numbers) – Exceptions and assertions Code: def divide_numbers(a, b): return a / b
Fix a Flask bug where missing form data causes a crash.
This line throws a KeyError if the 'username' field is missing. Make it safe while preserving access to the form. Code: username = request.form['username']
Avoid panic due to accessing uninitialized slice in Go.
This Go code panics due to accessing an empty slice. Explain what causes it and rewrite it with a safe guard. Code: package main import "fmt" func main() { var arr []int fmt.Println(arr[0]) }
Fix function that crashes when input is None
This function crashes when given `None` instead of a list. Add type checking and make it safe for invalid input. Code: def find_even(numbers): for i in range(len(numbers)): if numbers[i] % 2 == 0: return i return...
Fix undefined function error in a React component.
This React component throws an "undefined is not a function" error. Debug the root cause and rewrite to prevent runtime failure. Component: function MyComponent({ items }) { return ( <ul> {items.map(item =>...
Fix SQL join that returns more rows than expected.
This SQL query returns more rows than expected. Investigate: – Is there a join mismatch or missing constraint? – Are duplicates introduced via many-to-one? Rewrite the query to fetch only distinct user-order pairs. Query: SELECT users.name,...
Diagnose a classic closure issue in a loop using setTimeout.
This JavaScript loop prints `5` five times instead of `0, 1, 2, 3, 4`. Explain why and rewrite it to fix the closure issue. Code: for (var i = 0; i < 5; i++) { setTimeout(() => console.log(i), 100); }
Find the issue causing an Express route to crash on POST request.
This Node.js Express route crashes when a POST request is made. Debug the issue and return a corrected, secure version. Check: – req.body may be undefined if middleware is missing – Handle missing input gracefully Code: app.post('/submit',...
Debug a TypeError caused by incompatible data types in a function.
Analyze the following Python function that raises a `TypeError` during execution. Add inline explanation and rewrite the fixed version. Example: – Understand cause of failure from traceback – Suggest type-safe handling Code: def add_items(a,...
Set up the server-side logic. Implement user authentication (signup/login) and create an API endpoint to retrieve user profile data securely.
Animate the main image on the landing page so it gently fades in when the page first loads to create a welcoming effect.
Refactor the data processing function to handle larger inputs more efficiently. Could we use a different algorithm or data structure?
Create a simple portfolio website. It needs sections for Home, About Me, and a Contact Form. Use a clean, modern design theme and placeholder content.