NeoScan_Radiologist/.cursor/rules/projectstructurerule.mdc
2025-08-05 18:01:36 +05:30

308 lines
9.2 KiB
Plaintext

---
alwaysApply: true
---
# Physician App - Project Structure & File Naming Rules
## 📁 Directory Structure Rules
### 1. Root Level Organization
```
NeoScan_Physician/
├── app/ # Main application code
├── docs/ # Documentation
├── android/ # Android native code
├── ios/ # iOS native code
├── index.js # React Native entry point
├── package.json # Dependencies
├── tsconfig.json # TypeScript config
├── metro.config.js # Metro bundler config
├── babel.config.js # Babel config
└── .eslintrc.js # ESLint config
```
### 2. App Directory Structure
```
app/
├── modules/ # Feature-based modules
├── shared/ # Shared utilities & components
├── store/ # Redux store configuration
├── navigation/ # Navigation setup
├── theme/ # Styling & theming
├── config/ # Configuration files
├── assets/ # Static assets
├── localization/ # i18n
├── App.tsx # Root component
└── index.tsx # App entry point
```
## 🏗️ Module Architecture Rules
### 3. Module Structure (Feature-based)
Each module MUST follow this structure:
```
modules/ModuleName/
├── components/ # Reusable UI components
├── screens/ # Screen components
├── hooks/ # Custom hooks
├── redux/ # State management
├── services/ # API & external services
├── __tests__/ # Test files
└── index.ts # Module exports
```
### 4. Required Modules
- **Auth/** - Authentication & SSO
- **Dashboard/** - ER Dashboard & patient tracking
- **PatientCare/** - Patient details & medical records
- **Settings/** - User preferences & app settings
## 📝 File Naming Conventions
### 5. Component Files
- **PascalCase** for all component files
- **Suffix with type**: `.tsx` for components, `.ts` for utilities
- **Examples**:
- `LoginScreen.tsx`
- `PatientCard.tsx`
- `CriticalAlerts.tsx`
- `HospitalSSO.tsx`
### 6. Hook Files
- **camelCase** with `use` prefix
- **Examples**:
- `useAuth.ts`
- `usePatientList.ts`
- `useRealTimeAlerts.ts`
- `useCriticalAlerts.ts`
### 7. Service Files
- **camelCase** with descriptive names
- **Suffix with type**: `API.ts`, `Service.ts`
- **Examples**:
- `authAPI.ts`
- `patientCareAPI.ts`
- `notificationService.ts`
- `emrIntegration.ts`
### 8. Redux Files
- **camelCase** with descriptive suffixes
- **Examples**:
- `authSlice.ts`
- `erDashboardSlice.ts`
- `patientCareActions.ts`
- `dashboardSelectors.ts`
### 9. Test Files
- **Same name as source file** + `.test.ts` or `.test.tsx`
- **Examples**:
- `LoginScreen.test.tsx`
- `useAuth.test.ts`
- `authSlice.test.ts`
- `PatientCard.test.tsx`
## 🔧 Shared Components Rules
### 10. UI Components Structure
```
shared/components/
├── UI/ # Basic UI components
│ ├── Button.tsx
│ ├── Input.tsx
│ ├── Card.tsx
│ ├── Modal.tsx
│ ├── Badge.tsx
│ ├── Spinner.tsx
│ ├── Alert.tsx
│ ├── Dropdown.tsx
│ ├── Tabs.tsx
│ ├── ProgressBar.tsx
│ └── index.ts
├── Forms/ # Form-related components
│ ├── FormField.tsx
│ ├── ValidationMessage.tsx
│ ├── FormContainer.tsx
│ └── index.ts
├── Icons/ # Icon components
│ ├── MedicalIcons.tsx
│ ├── StatusIcons.tsx
│ ├── NavigationIcons.tsx
│ └── index.ts
└── index.ts
```
### 11. Utility Files
```
shared/utils/
├── api.ts # API utilities
├── constants.ts # App constants
├── helpers.ts # Helper functions
├── validators.ts # Validation functions
├── formatters.ts # Data formatting
├── dateUtils.ts # Date utilities
├── medicalUtils.ts # Medical-specific utilities
├── imageUtils.ts # Image processing
├── stringUtils.ts # String manipulation
└── index.ts
```
## 🎨 Assets Organization
### 12. Image Assets
```
assets/images/
├── logos/ # Hospital & app logos
├── icons/ # UI icons
│ ├── medical/ # Medical-specific icons
│ ├── ui/ # General UI icons
│ └── status/ # Status indicators
├── backgrounds/ # Background images
└── placeholders/ # Placeholder images
```
### 13. Asset Naming
- **kebab-case** for all asset files
- **Examples**:
- `hospital-logo.png`
- `critical-alert.mp3`
- `ct-scan-placeholder.png`
- `emergency-bg.jpg`
## 📱 Navigation Structure
### 14. Navigation Files
```
navigation/
├── AppNavigator.tsx # Root navigator
├── AuthNavigator.tsx # Authentication flow
├── MainNavigator.tsx # Main app flow
├── TabNavigator.tsx # Tab navigation
├── navigationTypes.ts # Type definitions
├── navigationUtils.ts # Navigation utilities
└── __tests__/
```
## 🔐 Configuration Rules
### 15. Environment & Config
```
config/
├── env.ts # Environment variables
├── api.ts # API configuration
├── websocket.ts # WebSocket config
├── notifications.ts # Notification config
├── security.ts # Security settings
└── index.ts
```
## 📚 Documentation Rules
### 16. Documentation Structure
```
docs/
├── README.md # Project overview
├── ARCHITECTURE.md # Architecture documentation
├── API.md # API documentation
├── DEPLOYMENT.md # Deployment guide
├── TESTING.md # Testing guidelines
├── SECURITY.md # Security guidelines
└── wireframes/ # UI wireframes
```
## 🧪 Testing Rules
### 17. Test Organization
- **Unit tests** alongside source files in `__tests__/` folders
- **Integration tests** in module-level `__tests__/` folders
- **E2E tests** in root-level `__tests__/` folder
- **Test utilities** in `shared/__tests__/`
## 📦 Package Management
### 18. Dependencies Organization
- **Core dependencies** in root `package.json`
- **Platform-specific** dependencies in respective folders
- **Dev dependencies** clearly separated
- **Peer dependencies** explicitly declared
## 🔄 Import/Export Rules
### 19. Import Conventions
- **Absolute imports** for shared utilities
- **Relative imports** for module-internal files
- **Index files** for clean imports
- **Barrel exports** for module APIs
### 20. Export Patterns
```typescript
// Module index.ts
export { default as ComponentName } from './components/ComponentName';
export { useHookName } from './hooks/useHookName';
export { actionName } from './redux/actions';
export type { TypeName } from './types';
```
## 🚫 Naming Restrictions
### 21. Forbidden Patterns
- ❌ No spaces in file names
- ❌ No special characters except `-` and `_`
- ❌ No uppercase in utility/service files
- ❌ No generic names like `utils.ts` or `helpers.ts`
- ❌ No abbreviations unless universally understood
### 22. Required Patterns
- ✅ Descriptive, self-documenting names
- ✅ Consistent casing within categories
- ✅ Clear separation of concerns
- ✅ Meaningful directory structure
- ✅ Proper TypeScript extensions
## 📋 File Size Guidelines
### 23. Component Limits
- **Single component files**: Max 300 lines
- **Complex components**: Split into smaller components
- **Utility files**: Max 200 lines
- **Service files**: Max 150 lines per service
### 24. Module Limits
- **Module components**: Max 10 files per category
- **Module services**: Max 5 files
- **Module hooks**: Max 8 files
- **Module redux**: Max 6 files
## 🔍 Code Organization Principles
### 25. Separation of Concerns
- **UI Logic** in components
- **Business Logic** in hooks/services
- **State Management** in Redux
- **Data Fetching** in services
- **Utilities** in shared/utils
### 26. Reusability
- **Shared components** in shared/components
- **Common utilities** in shared/utils
- **Type definitions** in shared/types
- **Constants** in shared/constants
This structure ensures maintainability, scalability, and consistency across the Physician App codebase.
and it should add proper comments in the each file for better understanding the flow.
should follow rule file while generating code.Each file should contain this as header
/*
* File: FILE_NAME.tsx
* Description: Main chat screen component
* Design & Developed by Tech4Biz Solutions
* Copyright (c) Spurrin Innovations. All rights reserved.
file footer
/*
* End of File: ChatScreen.tsx
* Design & Developed by Tech4Biz Solutions
* Copyright (c) Spurrin Innovations. All rights reserved.
*/
and it should add proper comments in the file for better understanding the flow.
should follow rule file while generating code.