Cursor rule
front/.cursor/rules/folder-structure.mdcCursor rules
Quality
77/100
Scores the file, not the repository.Length
708 words
17 headings · 3 code blocksRepository
47
— · pushed 336 days agoLast changed
3 days ago
First indexed 3 days ago.12345# Next.js Firebase Template - Project Structure67This project follows a modular architecture pattern for Next.js applications with Firebase integration and Material-UI components.89## Folder Structure1011### `src/` - Source Code1213#### Core Directories1415- **app/** - Next.js App Router16 - **layout.tsx** - Root layout with providers17 - **page.tsx** - Home page18 - **(authenticated)/** - Protected routes (requires auth)19 - **(public)/** - Public routes (signin, signup, etc.)20 - **api/** - API routes (if needed)2122- **components/** - Reusable UI Components23 - **common/** - Shared components (LoadingScreen, SplashScreen, EmptyContent)24 - **forms/** - Form components (LoadingButton, etc.)25 - **guards/** - Authorization guards26 - **AuthGuard/** - Protected route wrapper27 - **GuestGuard/** - Public route wrapper28 - **layouts/** - Layout components29 - **ui/** - Basic UI components3031- **sections/** - Page-specific sections32 - Each page gets its own folder33 - Complex components that are page-specific3435- **lib/** - Core Libraries & Services36 - **firebase.ts** - Firebase initialization37 - **firestore.ts** - Firestore operations & collections38 - **storage.ts** - Firebase Storage operations39 - **functions.ts** - Firebase Functions calls4041- **auth/** - Authentication System42 - **AuthProvider.tsx** - Auth context provider43 - **authContext.ts** - Context definition44 - **authOperations.ts** - Auth functions (login, signup, etc.)45 - **useAuth.ts** - Auth hook46 - **types.ts** - Auth-related types4748- **theme/** - MUI Theme Configuration49 - **ThemeProvider.tsx** - Theme context provider50 - **palette.ts** - Color definitions51 - **typography.ts** - Font settings52 - **components/** - Component overrides53 - **customColors.ts** - Custom color definitions5455- **hooks/** - Custom React Hooks56 - **useFirestore.ts** - Firestore real-time subscriptions57 - **useStorage.ts** - File upload/download hooks58 - **useSnackbar.ts** - Notification hook59 - **useResponsive.ts** - Responsive breakpoints6061- **utils/** - Utility Functions62 - **format.ts** - Data formatting63 - **validation.ts** - Form validation64 - **constants.ts** - App constants6566- **types/** - TypeScript Definitions67 - **firestore.ts** - Firestore document types68 - **api.ts** - API response types69 - **common.ts** - Shared types7071### `public/` - Static Assets7273- **images/** - Static images74- **fonts/** - Custom fonts75- **icons/** - Icon files7677## Development Rules7879### 1. Component Organization8081- Keep components small and focused82- Use composition over inheritance83- Separate presentational and container components84- Always export from index files for clean imports8586### 2. State Management8788- Use React Context for global state (auth, theme, settings)89- Avoid Redux unless absolutely necessary90- Use local state for component-specific data91- Leverage Firebase real-time listeners for live data9293### 3. Firebase Integration9495- All Firestore operations through lib/firestore.ts96- Define collection references as constants97- Use TypeScript interfaces for document types98- Implement proper error handling for all Firebase operations99100### 4. Routing & Navigation101102- Use Next.js App Router conventions103- Group routes by authentication status104- Implement proper loading states105- Use Link component with href attribute106- For MUI Link, use router.push107108### 5. Theme & Styling109110- Use MUI theme variables for all styling111- Define custom colors in theme configuration112- Use sx prop for component-specific styles113- Maintain consistent spacing with theme.spacing()114115### 6. Type Safety116117- Define all data types in types/ directory118- Use strict TypeScript configuration119- Avoid 'any' type - use 'unknown' if necessary120- Create proper interfaces for all Firebase documents121122## Common Patterns123124### Protected Route125126```tsx127// app/(authenticated)/layout.tsx128export default function AuthenticatedLayout({ children }) {129 return <AuthGuard>{children}</AuthGuard>;130}131```132133### Firestore Collection Hook134135```tsx136// hooks/useCollection.ts137export function useCollection(collectionName: string) {138 const [data, setData] = useState([]);139 const [loading, setLoading] = useState(true);140141 useEffect(() => {142 const unsubscribe = onSnapshot(143 collection(db, collectionName),144 (snapshot) => {145 setData(146 snapshot.docs.map((doc) => ({147 id: doc.id,148 ...doc.data(),149 }))150 );151 setLoading(false);152 }153 );154 return unsubscribe;155 }, [collectionName]);156157 return { data, loading };158}159```160161## File Naming Conventions162163- Components: PascalCase (e.g., `UserProfile.tsx`)164- Hooks: camelCase with 'use' prefix (e.g., `useAuth.ts`)165- Utils: camelCase (e.g., `formatDate.ts`)166- Types: PascalCase for interfaces/types (e.g., `UserDoc`)167- Constants: UPPER_SNAKE_CASE (e.g., `MAX_FILE_SIZE`)168169## Import Order1701711. React/Next.js imports1722. Third-party libraries (MUI, Firebase, etc.)1733. Absolute imports (@/ paths)1744. Relative imports1755. Type imports176177Example:178179```tsx180import { useState, useEffect } from "react";181import { Box, Button } from "@mui/material";182import { collection, onSnapshot } from "firebase/firestore";183import { useAuth } from "@/auth/useAuth";184import { LoadingScreen } from "../components/LoadingScreen";185import type { UserDoc } from "@/types/firestore";186```187
Also in agency-ai-solutions/nextjs-firebase-ai-coding-template
Diff this repo’s formatsOne repository carrying more than one format is the comparison this product exists for: does anyone actually write different content in each file, or is one a copy of the other?
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| agency-ai-solutions/nextjs-firebase-ai-coding-template.cursor/rules/ADR.mdc · 47 | Cursor rules | archgitmonorepo | 50/100 | 3 days ago | |
| agency-ai-solutions/nextjs-firebase-ai-coding-template.cursor/rules/PRD.mdc · 47 | Cursor rules | database | 44/100 | 3 days ago | |
| agency-ai-solutions/nextjs-firebase-ai-coding-templateAGENTS.md · 47 | AGENTS.md | no sections | 16/100 | 3 days ago | |
| agency-ai-solutions/nextjs-firebase-ai-coding-templateback/.cursor/rules/ADR.mdc · 47 | Cursor rules | testtesting-strategygitdatabase | 52/100 | 3 days ago | |
| agency-ai-solutions/nextjs-firebase-ai-coding-templateback/.cursor/rules/backend-workflow.mdc · 47 | Cursor rules | teststyledo-notagent-behaviour | 69/100 | 3 days ago | |
| agency-ai-solutions/nextjs-firebase-ai-coding-templateback/.cursor/rules/folder-structure.mdc · 47 | Cursor rules | testarch | 52/100 | 3 days ago | |
| agency-ai-solutions/nextjs-firebase-ai-coding-templatefront/.cursor/rules/ADR.mdc · 47 | Cursor rules | teststylearchtypes+3 | 58/100 | 3 days ago | |
| agency-ai-solutions/nextjs-firebase-ai-coding-templatefront/.cursor/rules/workflow.mdc · 47 | Cursor rules | teststylesecurityapi+4 | 77/100 | 3 days ago |
Diff against .cursor/rules/ADR.mdc Diff against .cursor/rules/PRD.mdc Diff against AGENTS.md Diff against back/.cursor/rules/ADR.mdc Diff against back/.cursor/rules/backend-workflow.mdc Diff against back/.cursor/rules/folder-structure.mdc Diff against front/.cursor/rules/ADR.mdc Diff against front/.cursor/rules/workflow.mdc
Similar configs
Same format, overlapping stack, ranked by quality.
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| TechSquidTV/Hermes.cursor/rules/10-hermes-api.mdc · 45 | Cursor rules | testlint-formatstylearch+5 | 100/100 | 3 days ago | |
| hiromaily/go-crypto-wallet.cursor/rules/typescript.mdc · 126 | Cursor rules | setupbuildtestlint-format+6 | 100/100 | 3 days ago | |
| markstev/mark-starter.cursor/rules/frontend.mdc · 0 | Cursor rules | setuptestlint-formatstyle+6 | 99/100 | 3 days ago | |
| dodgecfr/combatfilms-webapp.cursor/rules/frontend.mdc · 0 | Cursor rules | setuptestlint-formatstyle+7 | 99/100 | 3 days ago | |
| deifos/clipmira-subtitles.cursor/rules/frontend.mdc · 1 | Cursor rules | setuptestlint-formatstyle+7 | 99/100 | 3 days ago | |
| Allymahmoud/case-intake-platform.cursor/rules/frontend.mdc · 0 | Cursor rules | setuptestlint-formatstyle+7 | 99/100 | 3 days ago | |
| langflow-ai/langflow.cursor/rules/docs_development.mdc · 153k | Cursor rules | setupbuildtestlint-format+7 | 97/100 | 3 days ago | |
| TechSquidTV/Hermes.cursor/rules/20-hermes-api-tests.mdc · 45 | Cursor rules | teststyletesting-strategysecurity+3 | 97/100 | 3 days ago |
