Validate code follows established architecture patterns (session flow, repository pattern, SSR+SWR, etc.).
Validates code compliance with FastAPI and Next.js architecture patterns.
/plugin marketplace add adelabdelgawad/fullstack-agents/plugin install adelabdelgawad-fullstack-agents-plugins-fullstack-agents@adelabdelgawad/fullstack-agentsValidate that code follows the established architecture patterns for FastAPI and Next.js.
/review patterns [entity]/validate [entity]Required Pattern:
Depends(get_session) in router__init__Validation:
# Check router has session dependency
grep -n "Depends(get_session)" api/v1/{entity}.py
# Check service receives session
grep -n "session: AsyncSession" api/services/{entity}_service.py
# Check NO session in __init__
grep -n "self._session\|self.session" api/services/{entity}_service.py api/repositories/{entity}_repository.py
Pass criteria:
# Router
@router.get("")
async def list_items(
session: AsyncSession = Depends(get_session), # REQUIRED
):
return await service.list_items(session) # Session passed
# Service
async def list_items(self, session: AsyncSession): # Session received
return await self.repository.list_items(session) # Session passed
# Repository
async def list_items(self, session: AsyncSession): # Session received
return await session.execute(query)
Required Pattern:
CamelModelValidation:
grep -n "class.*Response.*CamelModel\|class.*Response.*BaseModel" api/schemas/{entity}_schemas.py
Required Pattern:
Validation:
# Should find domain exceptions
grep -n "raise NotFoundError\|raise ConflictError\|raise ValidationError" api/services/{entity}_service.py
# Should NOT find raw HTTP exceptions
grep -n "raise HTTPException" api/services/{entity}_service.py api/repositories/{entity}_repository.py
Required Pattern:
Required Pattern:
fallbackDataValidation:
# Page should NOT have "use client"
grep -n '"use client"' app/\(pages\)/setting/{entity}/page.tsx
# Client component should use SWR
grep -n "useSWR" app/\(pages\)/setting/{entity}/_components/table/{entity}-table.tsx
# Should have fallbackData
grep -n "fallbackData" app/\(pages\)/setting/{entity}/_components/table/{entity}-table.tsx
Required Pattern:
mutate with server responseValidation:
# Should NOT have optimistic
grep -n "optimistic" app/\(pages\)/setting/{entity}/
# Should use server response
grep -n "mutate.*response\|responseMap" app/\(pages\)/setting/{entity}/
Required Pattern:
nuqs for URL stateValidation:
grep -n "useQueryState\|parseAsInteger\|parseAsString" app/\(pages\)/setting/{entity}/
Required Pattern:
## Patterns Compliance Report
**Entity:** {EntityName}
**Date:** {timestamp}
### Summary
| Pattern | Status | Notes |
|---------|--------|-------|
| Single-session-per-request | PASS | All endpoints compliant |
| CamelModel schemas | PASS | All responses inherit correctly |
| Domain exceptions | FAIL | HTTPException in service |
| Repository stateless | PASS | No state stored |
| SSR + SWR hybrid | PASS | Correct pattern |
| Server response updates | WARN | Missing in delete action |
| URL state | PASS | Using nuqs |
### Failed Checks
#### 1. Domain Exceptions Not Used
**Location:** `api/services/{entity}_service.py:67`
**Current:**
```python
raise HTTPException(status_code=404, detail="Not found")
Should be:
from api.exceptions import NotFoundError
raise NotFoundError(f"{Entity} with id {id} not found")
Location: app/(pages)/setting/{entity}/context/{entity}-context.tsx:89
Current:
await deleteEntity(id)
mutate() # Just revalidates
Recommended:
const response = await deleteEntity(id)
mutate(data => data.filter(item => item.id !== id), false)
Update service to use domain exceptions
HTTPException with domain exceptionsAdd server response handling to delete
## Quick Validation Script
For rapid validation, run:
```bash
# FastAPI entity validation
echo "=== FastAPI Patterns ==="
echo "Session in router:"
grep -c "Depends(get_session)" api/v1/{entity}.py
echo "Session in service:"
grep -c "session: AsyncSession" api/services/{entity}_service.py
echo "HTTPException in service (should be 0):"
grep -c "HTTPException" api/services/{entity}_service.py
echo ""
echo "=== Next.js Patterns ==="
echo "'use client' in page (should be 0):"
grep -c '"use client"' app/\(pages\)/setting/{entity}/page.tsx 2>/dev/null || echo "0"
echo "SWR usage:"
grep -c "useSWR" app/\(pages\)/setting/{entity}/_components/table/*.tsx 2>/dev/null || echo "0"
echo "fallbackData:"
grep -c "fallbackData" app/\(pages\)/setting/{entity}/_components/table/*.tsx 2>/dev/null || echo "0"
Designs feature architectures by analyzing existing codebase patterns and conventions, then providing comprehensive implementation blueprints with specific files to create/modify, component designs, data flows, and build sequences