This document provides guidance for AI agents (including GitHub Copilot Workspace, autonomous coding agents, and other AI-powered development tools) working with the EasyTransfer codebase.
EasyTransfer is an end-to-end encrypted, anonymous file transfer application that enables peer-to-peer file sharing across any network using simple device codes.
Core Technologies:
- Frontend: Vue 3 + TypeScript + Vite + Pinia
- Backend: Node.js + TypeScript + Socket.io
- Communication: WebRTC (peer-to-peer) + Socket.io (signaling)
├── client/ # Vue.js frontend application
│ ├── src/
│ │ ├── components/ # Vue components
│ │ ├── stores/ # Pinia state stores
│ │ ├── utils/ # Utility functions
│ │ ├── config/ # Configuration files
│ │ └── types/ # TypeScript type definitions
│ └── package.json
├── server/ # Node.js backend server
│ ├── src/
│ │ └── server.ts # Main server file
│ └── package.json
├── assets/ # Static assets
└── .github/ # GitHub workflows and templates
# Client setup
cd client
npm install
# Server setup
cd ../server
npm install# Start client dev server (in /client)
npm run dev
# Start server in dev mode (in /server)
npm run dev# Build client (in /client)
npm run build
# Build server (in /server)
npm run build# Lint and format client (in /client)
npm run lint
npm run format
# Lint and format server (in /server)
npm run lint
npm run format
# Run tests (in /client or /server)
npm test # Run all tests
npm run test:watch # Run tests in watch mode
npm run test:ui # Run tests with UIFollow the Conventional Commits specification for semantic commit messages:
<type>(<scope>): <description>
[optional body]
[optional footer(s)]
- feat: A new feature
- fix: A bug fix
- docs: Documentation only changes
- style: Changes that don't affect code meaning (formatting, whitespace)
- refactor: Code change that neither fixes a bug nor adds a feature
- perf: Performance improvement
- test: Adding or updating tests
- build: Changes to build system or dependencies
- ci: Changes to CI configuration files and scripts
- chore: Other changes that don't modify src or test files
feature(client): add dark mode theme support
fix(server): resolve connection timeout issue
docs(readme): update installation instructions
test(client): add FileChunkManager unit tests
refactor(utils): extract ID generation to utils
ci: add automated testing to GitHub Actions
chore(dependencies): update dependencies to latest versions- Use present tense (
addnotadded) - Use imperative mood (
movenotmoves) - Keep first line under 72 characters
- Reference issues/PRs in footer when applicable
- Break long descriptions into body paragraphs
- Files are transferred directly between peers using WebRTC data channels
- Server acts only as a signaling server for connection establishment
- No file data passes through the server (true peer-to-peer)
Device A Socket.io Server Device B
| | |
|---(1) Generate Code------->| |
| |<---(2) Connect w/ Code---|
|<---(3) Exchange Signals--->|<---(3) Exchange Signals-|
| | |
|------------(4) WebRTC Connection------------------->|
|<-----------(5) Direct File Transfer----------------->|
- Uses Pinia for Vue state management
- Stores handle connection state, peer information, transfer progress
- Reactive updates drive UI changes
- E2EE: All transfers are end-to-end encrypted via WebRTC
- Anonymous: No user accounts or personal information
- No Storage: Files never stored on server
- Configurable Servers: Users can specify their own STUN/TURN servers
- Supports multiple file types and sizes
- Chunked transfer for large files
- Progress tracking
- Simultaneous multi-file transfers
- Support for text messages
- Works across LAN and WAN
- NAT traversal using STUN/TURN
- Handles various network configurations
- Fallback mechanisms for connection issues
-
Understand Before Modifying
- Read existing code in the area you're modifying
- Understand the WebRTC flow if touching connection logic
- Check related Pinia stores for state dependencies
-
Minimal Changes Principle
- Make the smallest possible change to achieve the goal
- Don't refactor unrelated code
- Preserve existing functionality
-
Type Safety
- Always use TypeScript types
- Don't use
any- define proper types - Update type definitions when changing data structures
-
Test Your Changes
- Run linting:
npm run lint - Run formatting:
npm run format - Build the project:
npm run build - Test locally with both client and server running
- Run linting:
<script setup lang="ts">
import { ref, computed } from 'vue'
interface Props {
// Define props
}
const props = defineProps<Props>()
const emit = defineEmits<{
eventName: [payload: string]
}>()
// Component logic here
</script>
<template>
<!-- Template here -->
</template>
<style scoped lang="scss">
/* Styles here */
</style>io.on('connection', (socket) => {
socket.on('event-name', (data) => {
// Handle event
socket.emit('response-event', responseData)
})
})import { socket } from '@/config/socket'
socket.on('event-name', (data) => {
// Handle event
})
socket.emit('event-name', payload)import { defineStore } from 'pinia'
import { ref } from 'vue'
export const useMyStore = defineStore('myStore', () => {
// State
const myState = ref<Type>(initialValue)
// Actions
function myAction() {
// Logic here
}
// Getters (computed)
const myGetter = computed(() => {
return /* computed value */
})
return {
myState,
myAction,
myGetter
}
})| Task | Location |
|---|---|
| Add UI component | /client/src/components/ |
| Modify connection logic | /client/src/stores/ or /client/src/utils/ |
| Add server event handler | /server/src/server.ts |
| Update configuration | /client/src/config/ |
| Add type definitions | /client/src/types/ or component file |
| Modify styles | Component <style> section or /client/src/assets/ |
The project uses Vitest for comprehensive unit testing:
-
Client Tests (157 tests):
- FileChunkManager (28 tests): file slicing, chunk management, merging, validation
- msgType utilities (33 tests): link detection, file type identification
- FileProtocol (24 tests): message parsing, encoding/decoding, round-trip validation
- RetryManager (28 tests): timeout handling, retry logic, state management
- ThemeManager (17 tests): theme application, color validation, accessibility
- WebRTC Connection Workflow (27 tests): connection lifecycle, signaling, data channels
-
Server Tests (13 tests): ID generation, character validation, collision prevention
# In /client or /server directory
npm test # Run all tests once
npm run test:watch # Run tests in watch mode (auto-rerun on changes)
npm run test:ui # Run tests with interactive UI- WebRTC Connection: Verify peers can connect through signaling
- File Transfer: Test various file sizes and types
- Protocol Handling: Validate message encoding/decoding
- Retry Logic: Test timeout handling and retry mechanisms
- Error Handling: Test disconnections and failures
- UI Components: Verify theming and state management
- Write tests for new utilities and functions
- Mock external dependencies (WebRTC, Socket.io)
- Test edge cases and error conditions
- Keep tests focused and isolated
- Run tests before committing changes
- Problem: Connections fail in certain network configurations
- Solution: Ensure STUN/TURN configuration is correct; test with different network setups
- Problem: Large file transfers cause memory overflow
- Solution: Use proper chunking; avoid loading entire files into memory
- Problem: UI doesn't update when state changes
- Solution: Use Vue reactivity properly (ref, reactive); ensure Pinia stores are used correctly
- Problem: Mismatched event names between client and server
- Solution: Define event names as constants; keep client and server in sync
- Problem: Type mismatches cause build errors
- Solution: Define proper interfaces; avoid
any; use type guards
- Use Vue DevTools for component inspection
- Check browser console for WebRTC errors
- Monitor Network tab for Socket.io traffic
- Use
console.logstrategically (remove before committing)
- Use
nodemonfor auto-restart during development - Check server logs for Socket.io connections
- Use Node.js debugger for complex issues
- Monitor connection count and cleanup
- Check ICE candidate gathering
- Verify STUN/TURN server connectivity
- Monitor data channel state
- Check for firewall/NAT issues
The project uses GitHub Actions for:
- Lint and Format Check (
check.yml): Runs on PRs and main branch - Pre-build (
pre-build.yml): Validates builds - Deploy (
deploy.yml): Deploys to production
Before committing changes:
- Run
npm run lintin both client and server - Run
npm run formatin both client and server - Run
npm testin both client and server (all tests pass) - Build succeeds:
npm run buildin both directories - Manual testing completed (if applicable)
- No console.log statements left in code
- TypeScript types are correct
- No new ESLint warnings
- Changes follow existing code style
- Commit message follows semantic commit format
- Evaluate necessity: Is this dependency really needed?
- Check security: Use
npm auditto check for vulnerabilities - Consider bundle size: Will this bloat the client bundle?
- Check license: Ensure license compatibility (project uses MIT)
- Install appropriately:
- Production:
npm install <package> - Development:
npm install -D <package>
- Production:
- Use Dependabot for automated updates (already configured)
- Test thoroughly after updating major versions
- Check CHANGELOG of dependencies for breaking changes
- ✅ Never log sensitive data (file contents, user info)
- ✅ Validate and sanitize all inputs
- ✅ Use HTTPS in production
- ✅ Keep dependencies updated
- ✅ Implement rate limiting on server endpoints
- ✅ Use secure WebRTC protocols (DTLS-SRTP)
- ❌ Storing files on server
- ❌ Logging connection details or file metadata
- ❌ Using
anytype in security-critical code - ❌ Exposing internal server details in errors
- ❌ Committing secrets or API keys
When making changes, update:
- README.md: For user-facing features
- CONTRIBUTING.md: For development process changes
- CHANGELOG.md: For notable changes
- This file (AGENTS.md): For new patterns or guidelines
- Code comments: For complex logic only
- Vue 3 Documentation
- Pinia Documentation
- Vite Documentation
- Socket.io Documentation
- WebRTC API
- TypeScript Documentation
If you're an AI agent and encounter:
- Unclear code: Check related files and commit history
- Missing context: Review README.md and related documentation
- Uncertain about approach: Follow existing patterns in the codebase
- Breaking changes: Preserve backward compatibility; document changes
- Prioritize user privacy and security in all changes
- Keep the application simple and easy to use - complexity should be hidden
- Test WebRTC functionality thoroughly - it's the core feature
- Follow TypeScript best practices - type safety is important
- Maintain code quality - run linters and formatters
- Think about edge cases - network issues, large files, multiple connections
- Document complex changes - help future developers (human or AI)
Good luck, and happy coding! 🚀