feat: implement AI-powered requirement analysis with hidden internal pricing logic (#76)#80
Conversation
…ic (#76) - Add Firebase Cloud Function (analyzeProject) that reads pricing config from Firestore and calls Gemini API server-side, returning only safe client-facing data (features, complexity, cost range, timeline, explanation) - Add ProjectEstimation dashboard page for clients to submit project descriptions and receive instant AI-generated cost estimates - Add PricingConfig admin page to manage feature prices, complexity multipliers, and estimation rules in Firestore - Add estimation history with expandable records - Store all pricing logic, prompts, and formulas exclusively server-side; API responses never leak internal calculation data - Add routes (/dashboard/estimation, /dashboard/pricing-config) and sidebar navigation entries - Update firebase.json with functions configuration Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
…rministic pricing - AI prompt now only performs feature extraction/classification with category names (no prices, multipliers, or formulas ever sent to AI) - Cost calculation, timeline estimation, and explanation generation all happen deterministically server-side in computeEstimate() - getPricingConfig() now merges Firestore data with defaults and validates numeric bounds to prevent partial/corrupt config - validateClassification() performs thorough type/enum validation of AI output before any downstream processing - No free-form AI text is returned to the client; explanation is built server-side from classification metadata Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
…store index - getPricingConfig: validate all numeric fields, feature prices, and multipliers - validateClassification: reject categories not in allowed pricing set - Trim description server-side before validation - PricingConfig.tsx: remove hardcoded DEFAULT_CONFIG with pricing values; load purely from Firestore with access-denied handling - Add firestore.indexes.json with composite index for estimations query (userId ASC + createdAt DESC) Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
|
Caution Review failedPull request was closed or merged during review 📝 WalkthroughWalkthroughAdds an end-to-end AI project cost estimation feature. A new Firebase Cloud Function calls the Gemini API to classify project descriptions, applies server-side pricing configuration loaded from Firestore, and persists results. The frontend gains an estimation submission page with history, an admin pricing configuration page, shared TypeScript types, and a service layer. Infrastructure files (firebase.json, firestore index, functions package/tsconfig) are added to support the new functions workspace. ChangesAI Project Estimation Feature
Sequence Diagram(s)sequenceDiagram
participant User as User (Browser)
participant ProjectEstimation as ProjectEstimation Page
participant estimationService as estimationService
participant analyzeProject as analyzeProject (Cloud Function)
participant Gemini as Gemini API
participant Firestore as Firestore
User->>ProjectEstimation: submit project description
ProjectEstimation->>estimationService: analyzeProject(description)
estimationService->>analyzeProject: httpsCallable("analyzeProject", { description })
analyzeProject->>Firestore: getDoc(pricingConfig/default)
Firestore-->>analyzeProject: pricing config
analyzeProject->>Gemini: generateContent(classificationPrompt)
Gemini-->>analyzeProject: JSON feature classification
analyzeProject->>analyzeProject: validateClassification() + computeEstimate()
analyzeProject->>Firestore: addDoc(estimations, result)
analyzeProject-->>estimationService: EstimationResult payload
estimationService-->>ProjectEstimation: mapped EstimationResult
ProjectEstimation-->>User: render cost/timeline/feature breakdown
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
|
Visit the preview URL for this PR (updated for commit 07c8f32): https://servio-0--pr80-devin-1781985064-ai-qw3dqurv.web.app (expires Sat, 27 Jun 2026 19:52:37 GMT) 🔥 via Firebase Hosting GitHub Action 🌎 Sign: 15915abb5951eb298a844eda460b24f444d93a69 |
hrx01-dev
left a comment
There was a problem hiding this comment.
do the changes suggested by @coderabbitai also don't do cloud functions from firebase that requires blaze plan use some free alternative or leave that thing otherwise
|
Superseded — restructured to remove Firebase Cloud Functions dependency per review feedback. |
Summary
Adds an AI-powered project estimation system where clients enter a natural-language project description and receive an instant cost/timeline estimate — while all pricing formulas, multipliers, and profit margins remain completely hidden server-side.
Supersedes #77 and #79 (closed due to branch protection rules preventing follow-up pushes).
Architecture (secure two-phase design)
Key security property: the AI prompt never receives pricing values, multipliers, or formulas — it only gets feature category names for classification. All cost/timeline/explanation generation is deterministic server-side code in
computeEstimate(). This prevents prompt-injection attacks from leaking internal pricing through free-form AI output.What's new
functions/src/index.ts— Firebase Cloud Function (analyzeProject):buildClassificationPrompt()sends only feature category names to AI (no prices)validateClassification(data, allowedCategories)performs strict type/enum/category validationcomputeEstimate()deterministically computes costs, timeline, and explanationgetPricingConfig()merges Firestore data with defaults, validates all numeric fields (prices >= 0, multipliers > 0, min <= max, etc.)src/dashboard/pages/ProjectEstimation.tsx— Client estimation page:src/dashboard/pages/PricingConfig.tsx— Admin pricing config page:pricingConfig/defaultin Firestorefirestore.indexes.json— Composite index forestimationscollection (userIdASC +createdAtDESC)Deployment prerequisites
firebase functions:secrets:set GEMINI_API_KEYcd functions && npm install && cd .. && firebase deploy --only functionsfirebase deploy --only firestore:indexespricingConfigcollection to admin-only access in Firestore security rulesCloses #76
Link to Devin session: https://app.devin.ai/sessions/c46ef0652e464fe8b81fbb3cc5147eb3
Requested by: @hrx01-dev
Summary by CodeRabbit
Release Notes
New Features
Chores