|
| 1 | +# GitHub Copilot Instructions for EasyTransfer |
| 2 | + |
| 3 | +## Project Overview |
| 4 | + |
| 5 | +EasyTransfer is a free, anonymous, encrypted, and easy-to-use E2EE file transfer tool built with WebRTC and Vue.js. The project enables peer-to-peer file transfers between devices across any network using simple device codes. |
| 6 | + |
| 7 | +## Project Structure |
| 8 | + |
| 9 | +``` |
| 10 | +/client - Vue 3 + TypeScript frontend application |
| 11 | +/server - Node.js + TypeScript backend server (Socket.io) |
| 12 | +/assets - Static assets (images, icons) |
| 13 | +/.github - GitHub workflows and templates |
| 14 | +``` |
| 15 | + |
| 16 | +## Technology Stack |
| 17 | + |
| 18 | +### Client |
| 19 | +- **Framework**: Vue 3 with Composition API |
| 20 | +- **Language**: TypeScript |
| 21 | +- **Build Tool**: Vite |
| 22 | +- **State Management**: Pinia |
| 23 | +- **Real-time Communication**: Socket.io-client, WebRTC |
| 24 | +- **Styling**: Sass/SCSS |
| 25 | +- **Code Quality**: ESLint, Prettier |
| 26 | + |
| 27 | +### Server |
| 28 | +- **Runtime**: Node.js |
| 29 | +- **Language**: TypeScript |
| 30 | +- **Framework**: Socket.io |
| 31 | +- **Build**: TypeScript Compiler (tsc) |
| 32 | +- **Code Quality**: ESLint, Prettier |
| 33 | + |
| 34 | +## Development Commands |
| 35 | + |
| 36 | +### Client (in `/client` directory) |
| 37 | +```bash |
| 38 | +npm run dev # Start development server |
| 39 | +npm run build # Build for production |
| 40 | +npm run preview # Preview production build |
| 41 | +npm run lint # Run ESLint with auto-fix |
| 42 | +npm run format # Format code with Prettier |
| 43 | +``` |
| 44 | + |
| 45 | +### Server (in `/server` directory) |
| 46 | +```bash |
| 47 | +npm run dev # Build and start with nodemon |
| 48 | +npm run build # Compile TypeScript |
| 49 | +npm run start # Start production server |
| 50 | +npm run lint # Run ESLint with auto-fix |
| 51 | +npm run format # Format code with Prettier |
| 52 | +``` |
| 53 | + |
| 54 | +## Code Style Guidelines |
| 55 | + |
| 56 | +### General |
| 57 | +- Use TypeScript for type safety |
| 58 | +- Follow existing code patterns and conventions |
| 59 | +- Write clear, self-documenting code |
| 60 | +- Keep functions small and focused |
| 61 | +- Use meaningful variable and function names |
| 62 | + |
| 63 | +### Vue Components |
| 64 | +- Use Composition API with `<script setup>` syntax |
| 65 | +- Define props with TypeScript interfaces |
| 66 | +- Use reactive state management with Pinia stores |
| 67 | +- Keep components focused on single responsibilities |
| 68 | +- Use Vue 3 best practices (ref, reactive, computed, watch) |
| 69 | + |
| 70 | +### TypeScript |
| 71 | +- Enable strict type checking |
| 72 | +- Avoid `any` type - use proper types or `unknown` |
| 73 | +- Define interfaces for complex data structures |
| 74 | +- Use type guards for runtime type checking |
| 75 | +- Export types that are used across files |
| 76 | + |
| 77 | +### File Naming |
| 78 | +- Vue components: PascalCase (e.g., `FileTransfer.vue`) |
| 79 | +- TypeScript files: camelCase (e.g., `socketManager.ts`) |
| 80 | +- Utilities: camelCase with descriptive names |
| 81 | +- Constants: UPPER_SNAKE_CASE or camelCase based on context |
| 82 | + |
| 83 | +### Code Organization |
| 84 | +- Keep related functionality together |
| 85 | +- Separate business logic from UI components |
| 86 | +- Use utility functions for shared logic |
| 87 | +- Store configuration in dedicated files |
| 88 | +- Define types in separate type files when shared |
| 89 | + |
| 90 | +## Key Features to Understand |
| 91 | + |
| 92 | +### WebRTC Implementation |
| 93 | +- Peer-to-peer connection establishment |
| 94 | +- STUN/TURN server configuration |
| 95 | +- Data channel management |
| 96 | +- ICE candidate handling |
| 97 | + |
| 98 | +### Socket.io Integration |
| 99 | +- Device code generation and management |
| 100 | +- Signaling server for WebRTC |
| 101 | +- Connection state management |
| 102 | +- Error handling and reconnection logic |
| 103 | + |
| 104 | +### File Transfer Flow |
| 105 | +1. Device code generation |
| 106 | +2. Peer connection via code |
| 107 | +3. WebRTC connection establishment |
| 108 | +4. File chunking and transfer |
| 109 | +5. Progress tracking |
| 110 | +6. Transfer completion/error handling |
| 111 | + |
| 112 | +## Testing Considerations |
| 113 | + |
| 114 | +- Test WebRTC connection establishment |
| 115 | +- Verify file transfer integrity |
| 116 | +- Test connection across different networks |
| 117 | +- Validate encryption implementation |
| 118 | +- Test edge cases (large files, network interruptions) |
| 119 | + |
| 120 | +## Security Considerations |
| 121 | + |
| 122 | +- **End-to-End Encryption**: All file transfers are encrypted |
| 123 | +- **No Server Storage**: Files never stored on server |
| 124 | +- **Anonymous**: No user registration or tracking |
| 125 | +- **Secure WebRTC**: Use secure protocols (DTLS-SRTP) |
| 126 | +- Never log sensitive information |
| 127 | +- Validate and sanitize all inputs |
| 128 | +- Implement rate limiting for connections |
| 129 | + |
| 130 | +## Performance Guidelines |
| 131 | + |
| 132 | +- Optimize file chunking for transfer efficiency |
| 133 | +- Implement progress tracking without blocking |
| 134 | +- Handle large files without memory overflow |
| 135 | +- Minimize bundle size for client application |
| 136 | +- Use lazy loading for Vue components where appropriate |
| 137 | +- Optimize WebRTC configurations for different networks |
| 138 | + |
| 139 | +## Common Patterns |
| 140 | + |
| 141 | +### Pinia Store Usage |
| 142 | +```typescript |
| 143 | +import { defineStore } from 'pinia' |
| 144 | +import { ref } from 'vue' |
| 145 | + |
| 146 | +export const useMyStore = defineStore('myStore', () => { |
| 147 | + const state = ref(initialValue) |
| 148 | + |
| 149 | + const action = () => { |
| 150 | + // Action logic |
| 151 | + } |
| 152 | + |
| 153 | + return { state, action } |
| 154 | +}) |
| 155 | +``` |
| 156 | + |
| 157 | +### Socket.io Event Handling |
| 158 | +```typescript |
| 159 | +socket.on('event-name', (data) => { |
| 160 | + // Handle event |
| 161 | +}) |
| 162 | + |
| 163 | +socket.emit('event-name', data) |
| 164 | +``` |
| 165 | + |
| 166 | +### WebRTC Connection Setup |
| 167 | +```typescript |
| 168 | +const peerConnection = new RTCPeerConnection(config) |
| 169 | + |
| 170 | +peerConnection.ondatachannel = (event) => { |
| 171 | + // Handle data channel |
| 172 | +} |
| 173 | +``` |
| 174 | + |
| 175 | +## Important Files |
| 176 | + |
| 177 | +- `/client/src/main.ts` - Client application entry point |
| 178 | +- `/client/src/App.vue` - Root Vue component |
| 179 | +- `/client/src/stores/` - Pinia state management stores |
| 180 | +- `/server/src/server.ts` - Server entry point and Socket.io setup |
| 181 | +- `/client/src/config/` - Configuration files |
| 182 | +- `/client/src/utils/` - Utility functions |
| 183 | + |
| 184 | +## Documentation |
| 185 | + |
| 186 | +When making changes: |
| 187 | +- Update README.md if adding user-facing features |
| 188 | +- Update CONTRIBUTING.md if changing development process |
| 189 | +- Add comments for complex algorithms or non-obvious logic |
| 190 | +- Document WebRTC-specific configurations |
| 191 | +- Keep CHANGELOG.md updated with notable changes |
| 192 | + |
| 193 | +## Dependencies |
| 194 | + |
| 195 | +- Review existing dependencies before adding new ones |
| 196 | +- Keep dependencies up to date for security |
| 197 | +- Avoid unnecessary dependencies |
| 198 | +- Consider bundle size impact for client dependencies |
| 199 | +- Use peer dependencies appropriately |
| 200 | + |
| 201 | +## Accessibility |
| 202 | + |
| 203 | +- Ensure UI is keyboard navigable |
| 204 | +- Provide appropriate ARIA labels |
| 205 | +- Support screen readers |
| 206 | +- Maintain sufficient color contrast |
| 207 | +- Test with accessibility tools |
| 208 | + |
| 209 | +## Browser Compatibility |
| 210 | + |
| 211 | +- Support modern browsers with WebRTC capability |
| 212 | +- Chrome, Firefox, Safari, Edge latest versions |
| 213 | +- Test WebRTC feature availability |
| 214 | +- Provide fallback messages for unsupported browsers |
| 215 | + |
| 216 | +## Helpful Context for AI Tools |
| 217 | + |
| 218 | +- The project emphasizes privacy, security, and ease of use |
| 219 | +- WebRTC is core to the architecture - understand it well |
| 220 | +- Socket.io is used only for signaling, not file transfer |
| 221 | +- Files go directly peer-to-peer, never through server |
| 222 | +- Device codes are simple 4-digit identifiers |
| 223 | +- Project supports both LAN and WAN transfers |
| 224 | +- STUN/TURN servers are configurable by users |
0 commit comments