Prompt Details
Model
Chat - (gpt-5.6)
Token size
4,447
Example input
[APPLICATION_REQUIREMENTS]: invoice management SaaS. Users can create, send, track, and download invoices.
[USERS_AND_USER_JOURNEYS]: Business Owner: creates invoices, manages customers, views payment status. Staff: creates and sends invoices but cannot manage account settings. Customer: receives invoice through email and views/downloads it.
[FRONTEND_REQUIREMENTS]: Login/Register Dashboard Customers Create/Edit Invoice Invoice Details Settings Responsive web UI
[AUTHENTICATION_SECURITY_AND_ACCESS]: Email/password authentication Business Owner and Staff roles Staff cannot access account settings Users can only access data belonging to their organization
[TECHNICAL_AND_DEPLOYMENT_CONSTRAINTS]: Next.js + TypeScript Node.js backend PostgreSQL REST API Docker Deploy on a cloud platform Small development team Prefer a modular monolith over microservices
Example output
1. π Executive Summary
Product: AI-powered Invoice Management SaaS
Target users:
Business owners
Business staff
Customers receiving invoices
Core functionality:
User authentication
Organization-based access
Customer management
Invoice creation and editing
Invoice sending
Invoice status tracking
Invoice PDF generation/download
Basic dashboard
Account settings
Recommended architecture:
Browser
β
Next.js Frontend
β
REST API
β
Node.js Modular Monolith
β
Business Logic / Services
β
PostgreSQL
β
External Services
βββ Email Provider
βββ PDF Generation
Major implementation decisions:
Use a modular monolith rather than microservices.
Keep server state in the data-fetching layer rather than duplicating it in global client state.
Enforce organization isolation on the server.
Treat authentication and authorization separately.
Generate invoice numbers server-side.
Use database transactions for invoice creation and related records.
Use asynchronous processing for email delivery if sending does not need to block the API response.
Key assumption: The application is multi-tenant, meaning multiple businesses use the same application while their data remains isolated.
Major risks:
Incorrect organization-level authorization could expose another business's data.
Duplicate invoice numbers could occur without proper database constraints.
Email provider failures could affect invoice delivery.
PDF generation could become slow for large or complex invoices.
---
2. π§ Feature & User Journey Map
Journey A β Business Owner Login
Login Screen
β
Submit credentials
β
POST /api/auth/login
β
Authentication Service
β
Verify password
β
Create session
β
Return authenticated session
β
Dashboard
Success state: User reaches dashboard.
Failure states:
Invalid credentials
Disabled account
Server error
Rate limit exceeded
---
Journey B β Create Invoice
Dashboard
β
Create Invoice
β
Select Customer
β
Add Invoice Items
β
Client Validation
β
POST /api/invoices
β
Invoice Service
β
Authorization Check
β
Generate Invoice Number
β
Database Transaction
β
Invoice Created
β
Return Invoice
β
Invoice Details Screen
Database operations:
Read customer
Create invoice
Create invoice items
Completion state: Invoice status becomes DRAFT.
---
Journey C β Send Invoice
Invoice Details
β
Click Send
β
POST /api/invoices/{id}/send
β
Authorization
β
Validate invoice
β
Generate PDF
β
Queue Email Job
β
Worker sends email
β
Update invoice delivery state
β
UI displays result
Possible failures:
Customer has no valid email
Invoice does not exist
User lacks permission
Email provider unavailable
PDF generation fails
---
Feature-to-Journey Map
Feature Primary User Journey Core Product
Authentication Owner/Staff Login Yes
Customer Management Owner/Staff Customer CRUD Yes
Invoice Creation Owner/Staff Create Invoice Yes
Invoice Sending Owner/Staff Send Invoice Yes
Invoice Tracking Owner/Staff View Status Yes
PDF Download Owner/Staff/Customer Download Invoice Yes
Dashboard Owner/Staff View Overview Yes
Settings Owner Manage Account Supporting
---
3. π¨ Frontend Blueprint
Routes
/login
/register
/dashboard
/customers
/customers/[id]
/invoices
/invoices/new
/invoices/[id]
/settings
/invoice/[publicToken]
The final route can provide customers with a controlled public invoice view without exposing internal application data.
---
Dashboard
Purpose: Show invoice activity and high-level business information.
Components:
DashboardHeader
InvoiceSummaryCards
RecentInvoicesTable
InvoiceStatusFilter
EmptyState
LoadingSkeleton
ErrorState
API dependencies:
GET /api/dashboard/summary
GET /api/invoices
Authentication: Required.
Authorization: User must belong to the organization.
---
Customers Screen
Components:
CustomerTable
CustomerSearch
CustomerForm
CustomerDeleteDialog
Pagination
EmptyState
API dependencies:
GET /api/customers
POST /api/customers
GET /api/customers/{id}
PATCH /api/customers/{id}
DELETE /api/customers/{id}
---
Create Invoice Screen
Components:
CustomerSelector
InvoiceItemEditor
QuantityInput
UnitPriceInput
TaxInput
InvoiceTotals
NotesField
SaveDraftButton
SaveAndSendButton
Local state:
Form values
Validation errors
Modal visibility
Server state:
Customers
Existing invoice data
UI states:
Loading
Empty customer list
Validation failure
Saving
Save success
Save failure
---
4. π§© Frontend Component & State Design
Component Responsibility State API
LoginForm Authentication form Local Login API
CustomerTable Display customers Server Customers API
CustomerForm Create/edit customer Local Customer API
InvoiceItemEditor Manage line items Local None
InvoiceTable Display invoices Server Invoice API
InvoiceForm Create invoice Local Invoice API
StatusBadge Display status None None
SendInvoiceButton Send invoice Loading state Send API
State separation
UI state:
Dialog open/closed
Selected filters
Form state
Temporary validation messages
Server state:
Customers
Invoices
Dashboard data
Auth/session state:
Current user
Organization
Role
Session status
Avoid storing duplicate invoice/customer datasets in a global state store.
---
5. βοΈ Backend Blueprint
Backend Modules
src/
βββ auth/
βββ organizations/
βββ users/
βββ customers/
βββ invoices/
βββ dashboard/
βββ email/
βββ pdf/
βββ authorization/
βββ database/
βββ jobs/
βββ shared/
---
Auth Module
Responsibility:
Registration
Login
Logout
Session validation
Password hashing
Password reset if included later
Dependencies:
User repository
Session repository
Security boundary: Authentication credentials never leave the server.
---
Customer Module
Responsibilities:
Create customer
Read customer
Update customer
Delete customer
Security: Every customer query must be scoped to the authenticated user's organization.
---
Invoice Module
Responsibilities:
Invoice creation
Invoice editing
Invoice retrieval
Invoice numbering
Status changes
Invoice sending
Business logic:
Customer must belong to the same organization.
Invoice items must contain valid quantities/prices.
Invoice number must be generated server-side.
Only permitted roles can perform each operation.
Invoice status transitions must follow defined rules.
---
6. π API Specification
Method Endpoint Purpose Auth Request Response Errors
POST /api/auth/register Register user No Email/password/org Session/user 400, 409
POST /api/auth/login Login No Email/password Session 401, 429
POST /api/auth/logout Logout Yes None Success 401
GET /api/customers List customers Yes Query/filter Customer list 401, 403
POST /api/customers Create customer Yes Customer data Customer 400, 403
PATCH /api/customers/{id} Update customer Yes Changed fields Customer 400, 403, 404
DELETE /api/customers/{id} Delete customer Yes None Success 403, 404
GET /api/invoices List invoices Yes Filters Invoice list 401, 403
POST /api/invoices Create invoice Yes Invoice data Invoice 400, 403
GET /api/invoices/{id} Get invoice Yes None Invoice 403, 404
PATCH /api/invoices/{id} Edit invoice Yes Invoice data Invoice 400, 403, 404
POST /api/invoices/{id}/send Send invoice Yes None Delivery state 400, 403, 404, 502
GET /api/invoices/{id}/pdf Download PDF Yes None PDF 403, 404, 500
GET /api/dashboard/summary Dashboard data Yes None Summary 401
Error structure
Use a consistent format:
{
"error": {
"code": "VALIDATION_ERROR",
"message": "The invoice contains invalid data.",
"details": {}
}
}
Internal stack traces should remain server-side.
---
7. ποΈ Database Specification
Organization
Field Type Requirement
id UUID Primary key
name VARCHAR Required
created_at TIMESTAMP Required
updated_at TIMESTAMP Required
---
User
Field Type Requirement
id UUID Primary key
organization_id UUID Foreign key
email VARCHAR Unique within required scope
password_hash TEXT Required
role ENUM Owner/Staff
created_at TIMESTAMP Required
updated_at TIMESTAMP Required
---
Customer
Field Type Requirement
id UUID Primary key
organization_id UUID Foreign key
name VARCHAR Required
email VARCHAR Optional/required based on send requirement
phone VARCHAR Optional
address TEXT Optional
created_at TIMESTAMP Required
updated_at TIMESTAMP Required
---
Invoice
Field Type Requirement
id UUID Primary key
organization_id UUID Foreign key
customer_id UUID Foreign key
invoice_number VARCHAR Unique per organization
status ENUM Draft/Sent/Paid/etc.
subtotal DECIMAL Required
tax DECIMAL Required
total DECIMAL Required
created_at TIMESTAMP Required
updated_at TIMESTAMP Required
---
Invoice Item
Field Type Requirement
id UUID Primary key
invoice_id UUID Foreign key
description TEXT Required
quantity DECIMAL Required
unit_price DECIMAL Required
amount DECIMAL Required
Important constraints
organization β users
organization β customers
organization β invoices
customer β invoices
invoice β invoice_items
Recommended indexes:
users(organization_id)
customers(organization_id)
invoices(organization_id, created_at)
invoices(organization_id, invoice_number)
invoices(customer_id)
invoice_items(invoice_id)
Invoice creation should use a transaction so the invoice and its items are created consistently.
---
8. π Authentication & Authorization
Authentication Flow
Login
β
Frontend sends credentials over HTTPS
β
Backend validates credentials
β
Password hash verification
β
Session created
β
Secure session cookie
β
Authenticated API requests
A secure, HTTP-only session cookie is preferable to exposing long-lived authentication tokens to browser JavaScript for this web application.
---
Roles
Owner
Can:
Manage customers
Create/edit invoices
Send invoices
Download invoices
View dashboard
Manage organization settings
Staff
Can:
Manage customers
Create/edit invoices
Send invoices
Download invoices
View dashboard
Cannot:
Manage organization settings
Customer
Can:
View their invoice through the controlled customer-facing mechanism
Download their invoice
---
Authorization Matrix
Role Resource Action Allowed Conditions
Owner Customers CRUD Yes Own organization
Staff Customers CRUD Yes Own organization
Owner Invoices CRUD Yes Own organization
Staff Invoices CRUD Yes Own organization
Owner Settings Manage Yes Own organization
Staff Settings Manage No Server enforced
Customer Invoice View Yes Authorized invoice
Customer Organization View No Never expose organization data
The backend must check both role permission and resource ownership/organization membership.
---
9. π End-to-End Feature Implementation Matrix
Feature Frontend API Backend Database Auth Tests Status
Login LoginForm /auth/login Auth Module Users/Sessions Public β Session Auth tests Planned
Customers Customer screens /customers Customer Module Customers Owner/Staff CRUD tests Planned
Invoice creation InvoiceForm POST /invoices Invoice Module Invoice + Items Owner/Staff Business tests Planned
Invoice viewing InvoiceDetails GET /invoices/{id} Invoice Module Invoice Owner/Staff Access tests Planned
Invoice sending Send button /send Invoice + Email Invoice state Owner/Staff Integration tests Planned
PDF Download button /pdf PDF Service Invoice data Authorized user PDF tests Planned
Dashboard Dashboard /dashboard/summary Dashboard Module Invoice data Owner/Staff API tests Planned
Settings Settings UI Settings API Organization Module Organization Owner Authorization tests Planned
---
10. π Integration Architecture
Email Provider
Purpose: Send invoice emails.
Send Invoice API
β
Validate Invoice
β
Create Email Job
β
Worker
β
Email Provider
β
Delivery Result
β
Update Delivery State
Failure handling
Timeout: retry with controlled backoff.
Temporary provider failure: retry.
Permanent rejection: mark delivery failed.
Do not retry indefinitely.
Log provider error without exposing credentials.
---
PDF Generation
PDF generation can initially run inside the backend if invoice documents are small and generation is fast.
A separate worker becomes appropriate only if actual workload measurements show that PDF generation materially affects API responsiveness.
---
11. π‘οΈ Security & Error Handling
Input Validation
Validate at both appropriate boundaries:
Frontend:
Required fields
Email format
Numeric fields
User-friendly validation
Backend:
Required fields
Data types
Business rules
Organization ownership
Role permissions
Backend validation remains authoritative.
---
Security Controls
HTTPS in production
Secure password hashing
HTTP-only secure session cookies
CSRF protection appropriate to the chosen authentication architecture
Server-side authorization
Parameterized database queries/ORM
Rate limiting on login
Rate limiting on sensitive endpoints
Secrets stored in environment/secret management system
No credentials in frontend bundles
Dependency vulnerability scanning
Security event logging
Sanitized error responses
---
Error Categories
400 Validation Error
401 Authentication Error
403 Authorization Error
404 Resource Not Found
409 Conflict
429 Rate Limited
500 Internal Server Error
502 External Service Error
Frontend should convert these into understandable messages without exposing internal implementation details.
---
12. π§ͺ Testing Plan
Frontend
Test:
Login form validation
Customer form
Invoice item calculations
Loading states
Empty states
Error states
Send invoice interaction
Responsive layouts
Backend
Test:
Password verification
Session creation
Customer CRUD
Invoice calculations
Invoice numbering
Status transitions
Organization isolation
Role authorization
Database
Test:
Foreign keys
Unique invoice numbers
Required fields
Invoice/invoice-item consistency
Migration execution
Integration
Test:
Create customer
β
Create invoice
β
Generate PDF
β
Send invoice
β
Verify delivery state
Security
Critical tests:
Staff β Settings β DENIED
Organization A β Organization B invoice β DENIED
Unauthenticated β Protected API β DENIED
Customer β Another customer's invoice β DENIED
---
13. π Observability Plan
Logs
Log:
API request failures
Authentication failures
Authorization failures
Invoice creation failures
Email failures
PDF failures
Background job failures
Do not log:
Passwords
Session secrets
API keys
Sensitive customer information unnecessarily
Metrics
Track:
API response latency
HTTP error rate
Login failure rate
Invoice creation failures
Email delivery failures
PDF generation duration
Background job failures
Database errors
Alerts
Potential alerts:
Sustained API 5xx increase
Database connectivity failures
Email delivery failure spike
Worker/job failure spike
Authentication anomaly
---
14. ποΈ Development Task Breakdown
Task ID Layer Task Dependency Priority Definition of Done
FS-001 Foundation Create repositories and project structure None P0 Frontend/backend run locally
FS-002 DevOps Configure environment variables FS-001 P0 Dev/staging configuration works
FS-003 Database Create PostgreSQL schema FS-001 P0 Migrations execute successfully
FS-004 Database Add constraints/indexes FS-003 P0 Integrity tests pass
FS-005 Auth Implement registration/login FS-003 P0 Auth workflow works
FS-006 Auth Implement session handling FS-005 P0 Protected API works
FS-007 Auth Implement authorization middleware FS-006 P0 Unauthorized access is blocked
FS-008 Backend Customer module FS-007 P0 Customer CRUD works
FS-009 Backend Invoice module FS-008 P0 Invoice creation works
FS-010 Backend Invoice numbering FS-009 P0 No duplicate numbers
FS-011 Frontend Application layout/routes FS-001 P0 Routes render
FS-012 Frontend Authentication UI FS-005 P0 User can log in
FS-013 Frontend Customer UI FS-008 P0 Customer CRUD works
FS-014 Frontend Invoice UI FS-009 P0 Invoice workflow works
FS-015 Backend PDF generation FS-009 P1 Valid PDF generated
FS-016 Backend Email integration FS-015 P1 Invoice email delivered
FS-017 Backend Dashboard API FS-009 P1 Summary returned
FS-018 Frontend Dashboard UI FS-017 P1 Dashboard displays data
FS-019 Testing E2E workflows FS-014 P0 Critical journeys pass
FS-020 DevOps Production deployment FS-019 P0 Production deployment succeeds
FS-021 Observability Logging/monitoring FS-020 P0 Critical failures observable
---
15. π¦ Implementation Sequence
Phase 1 β Foundation
Repository
β
Frontend/backend structure
β
Environment configuration
β
CI
β
Basic deployment pipeline
Phase 2 β Database
Organizations
β
Users
β
Customers
β
Invoices
β
Invoice Items
β
Indexes + constraints
Phase 3 β Authentication
Registration
β
Login
β
Session
β
Logout
β
Authorization middleware
Phase 4 β Core Backend
Customer Module
β
Invoice Module
β
Invoice numbering
β
Business rules
Phase 5 β Frontend
Layouts
β
Authentication screens
β
Dashboard
β
Customers
β
Invoice creation
β
Invoice details
Phase 6 β Integrations
PDF generation
β
Email integration
β
Background worker if needed
Phase 7 β Testing
Unit
β
API
β
Authorization
β
Integration
β
E2E
β
Security validation
Phase 8 β Launch
Production configuration
β
Database migration
β
Deployment
β
Health checks
β
Smoke tests
β
Monitoring
The critical dependency is authorization before exposing customer/invoice APIs, because multi-tenant data isolation must be enforced from the first protected feature.
---
16. β οΈ Technical Risk Register
Risk Likelihood Impact Mitigation Validation
Cross-organization data exposure Medium High Organization-scoped queries + authorization tests Access-boundary tests
Duplicate invoice numbers Medium High Database uniqueness + transaction strategy Concurrent creation test
Email provider outage Medium Medium Retry + failure state Integration failure test
PDF generation slow Medium Medium Measure generation time Performance test
Session misconfiguration Low/Medium High Secure cookie configuration Authentication security tests
Database migration failure Low/Medium High Backups + migration testing Staging migration
API abuse Medium Medium Rate limiting Load/security tests
---
17. π Deployment & Release Plan
Environments
Development
β
Staging
β
Production
CI/CD
Every pull request:
Install dependencies
β
Lint
β
Type checking
β
Unit tests
β
Build
Before production:
Integration tests
β
E2E tests
β
Security checks
β
Deploy
β
Migration
β
Health check
β
Smoke test
Configuration
Separate:
Development configuration
Staging configuration
Production configuration
Secrets must be supplied through the deployment environment or secret-management system.
Database migration
Production migrations should:
Be version controlled
Be tested in staging
Be backward-compatible where possible
Have a rollback/recovery plan
Rollback
Application rollback should be possible independently where feasible.
Database rollback should not rely blindly on reversing destructive migrations; use backups or forward-fix migrations when appropriate.
---
18. β
Definition of Done
A feature is not complete merely because its UI works.
For Invoice Creation, for example:
Functional invoice form works.
Client validation works.
Backend validation works.
Authorized users can create invoices.
Unauthorized users are rejected.
Customer ownership is verified.
Invoice number is generated safely.
Invoice and items are stored transactionally.
Loading state exists.
Success state exists.
Failure state exists.
API tests pass.
Business-logic tests pass.
Authorization tests pass.
Database constraint tests pass.
E2E invoice workflow passes.
Errors are logged appropriately.
Documentation is updated.
The same standard should apply to every critical feature.
---
19. π Assumptions & Open Questions
Assumptions
The application supports multiple organizations.
Each user belongs to an organization.
Owner and Staff are the initial application roles.
Customers do not require full application accounts initially.
REST is sufficient for the initial application.
PostgreSQL is sufficient for the expected initial scale.
Email and PDF generation are the only external service dependencies specified.
Open Questions
1. Should customers have accounts or only secure invoice links?
2. Should invoices support taxes at item level or invoice level?
3. What exact invoice statuses are required?
4. Should invoice editing be allowed after sending?
5. Is payment processing required?
6. Is payment tracking manual or integrated with a payment provider?
7. Is password reset required for the first release?
8. Is email verification required?
9. What invoice numbering format should each organization use?
10. What is the expected number of organizations, users, and invoices?
11. Which cloud provider should host the application?
12. What compliance requirements apply to customer/business data?
These decisions should be validated before implementation of the affected features.
---
20. π FINAL BUILD CHECKLIST
Frontend
[ ] Routes implemented
[ ] Responsive layouts implemented
[ ] Forms implemented
[ ] Loading states implemented
[ ] Empty states implemented
[ ] Error states implemented
[ ] Client validation implemented
Backend
[ ] Domain modules implemented
[ ] Business rules implemented
[ ] Service boundaries defined
[ ] Error handling standardized
[ ] Authorization enforced server-side
Database
[ ] Schema implemented
[ ] Migrations version controlled
[ ] Foreign keys configured
[ ] Unique constraints configured
[ ] Required indexes added
[ ] Transaction boundaries tested
APIs
[ ] Authentication endpoints
[ ] Customer endpoints
[ ] Invoice endpoints
[ ] Dashboard endpoint
[ ] PDF endpoint
[ ] Consistent error responses
[ ] Validation implemented
[ ] Rate limits applied where appropriate
Authentication
[ ] Registration
[ ] Login
[ ] Logout
[ ] Session management
[ ] Password security
[ ] Account recovery requirements resolved
Authorization
[ ] Owner permissions
[ ] Staff permissions
[ ] Customer access
[ ] Organization isolation
[ ] Object-level authorization
[ ] Negative authorization tests
Integrations
[ ] PDF generation
[ ] Email provider
[ ] Timeout handling
[ ] Retry policy
[ ] Failure states
[ ] Credential management
Security
[ ] HTTPS
[ ] Secure sessions
[ ] Input validation
[ ] Injection protection
[ ] Rate limiting
[ ] Secrets protection
[ ] Dependency scanning
[ ] Security logging
Testing
[ ] Unit tests
[ ] Component tests
[ ] API tests
[ ] Database tests
[ ] Authorization tests
[ ] Integration tests
[ ] E2E tests
[ ] Security tests
Observability
[ ] Application logs
[ ] Error tracking
[ ] API metrics
[ ] Database monitoring
[ ] Job monitoring
[ ] Authentication event monitoring
[ ] Alerts
Deployment
[ ] Development environment
[ ] Staging environment
[ ] Production environment
[ ] CI/CD
[ ] Secrets configuration
[ ] Database migration process
[ ] Rollback/recovery plan
[ ] Production smoke tests
[ ] Health checks
Documentation
[ ] Architecture documented
[ ] API contracts documented
[ ] Database schema documented
[ ] Environment variables documented
[ ] Deployment procedure documented
[ ] Recovery procedure documented
[ ] Feature Definition of Done documented
By purchasing this prompt, you agree to our terms of service
GPT-5.6
π¨ Map frontend screens and components
βοΈ Design backend modules and business logic
ποΈ Define database entities and relationships
π Map APIs to frontend requirements
π Design authentication & authorization
π§© Identify integrations and dependencies
π‘οΈ Define security requirements
π§ͺ Create testing requirements
π Build a practical development roadmap
Turn your application requirements into one connected implementation plan that developers can follow from the first component to production depl
...more
Added 3 weeks ago
