mirror of
https://github.com/kyantech/Palmr.git
synced 2025-10-23 06:11:58 +00:00
8.1 KiB
8.1 KiB
GitHub Copilot Instructions for Palmr
This file contains instructions for GitHub Copilot to help contributors work effectively with the Palmr codebase.
Project Overview
Palmr is a flexible and open-source alternative to file transfer services like WeTransfer and SendGB. It's built with:
- Backend: Fastify (Node.js) with TypeScript, SQLite database, and filesystem/S3 storage
- Frontend: Next.js 15 + React + TypeScript + Shadcn/ui
- Documentation: Next.js + Fumadocs + MDX
- Package Manager: pnpm (v10.6.0)
- Monorepo Structure: Three main apps (web, server, docs) in the
apps/
directory
Architecture and Structure
Monorepo Layout
apps/
├── docs/ # Documentation site (Next.js + Fumadocs)
├── server/ # Backend API (Fastify + TypeScript)
└── web/ # Frontend application (Next.js 15)
Key Technologies
- TypeScript: Primary language for all applications
- Database: Prisma ORM with SQLite (optional S3-compatible storage)
- Authentication: Multiple OAuth providers (Google, GitHub, Discord, etc.)
- Internationalization: Multi-language support with translation scripts
- Validation: Husky pre-push hooks for linting and type checking
Development Workflow
Base Branch
Always create new branches from and submit PRs to the next
branch, not main
.
Commit Convention
Use Conventional Commits format for all commits:
<type>(<scope>): <description>
Types:
- feat: New feature
- fix: Bug fix
- docs: Documentation changes
- test: Adding or updating tests
- refactor: Code refactoring
- style: Code formatting
- chore: Maintenance tasks
Examples:
feat(web): add user authentication system
fix(api): resolve null pointer exception in user service
docs: update installation instructions in README
test(server): add unit tests for user validation
Code Quality Standards
- Linting: All apps use ESLint. Run
pnpm lint
before committing - Formatting: Use Prettier for code formatting. Run
pnpm format
- Type Checking: Run
pnpm type-check
to validate TypeScript - Validation: Run
pnpm validate
to run both linting and type checking - Pre-push Hook: Automatically validates all apps before pushing
Testing Changes
- Test incrementally during development
- Run validation locally before pushing:
pnpm validate
in each app directory - Keep changes focused on a single issue or feature
- Review your work before committing
Application-Specific Guidelines
Web App (apps/web/
)
- Framework: Next.js 15 with App Router
- Port: 3000 (development)
- Scripts:
pnpm dev
: Start development serverpnpm build
: Build for productionpnpm validate
: Run linting and type checking
- Translations: Use Python scripts in
scripts/
directorypnpm translations:check
: Check translation statuspnpm translations:sync
: Synchronize translations
Server App (apps/server/
)
- Framework: Fastify with TypeScript
- Port: 3333 (default)
- Scripts:
pnpm dev
: Start development server with watch modepnpm build
: Build TypeScript to JavaScriptpnpm validate
: Run linting and type checkingpnpm db:seed
: Seed database
- Database: Prisma ORM with SQLite
Docs App (apps/docs/
)
- Framework: Next.js with Fumadocs
- Port: 3001 (development)
- Content: MDX files in
content/docs/
- Scripts:
pnpm dev
: Start development serverpnpm build
: Build documentation sitepnpm validate
: Run linting and type checking
Code Style and Best Practices
General Guidelines
- Follow Style Guidelines: Ensure code adheres to ESLint and Prettier configurations
- TypeScript First: Always use TypeScript, avoid
any
types when possible - Component Organization: Keep components focused and single-purpose
- Error Handling: Implement proper error handling and logging
- Comments: Add comments only when necessary to explain complex logic
- Imports: Use absolute imports where configured, keep imports organized
API Development (Server)
- Use Fastify's schema validation for all routes
- Follow REST principles for endpoint design
- Implement proper authentication and authorization
- Handle errors gracefully with appropriate status codes
- Document API endpoints in the docs app
Frontend Development (Web)
- Use React Server Components where appropriate
- Implement proper loading and error states
- Follow accessibility best practices (WCAG guidelines)
- Optimize performance (lazy loading, code splitting)
- Use Shadcn/ui components for consistent UI
Documentation
- Write clear, concise documentation
- Include code examples where helpful
- Update documentation when changing functionality
- Use MDX features for interactive documentation
- Follow the existing documentation structure
Translation and Internationalization
- All user-facing strings should be translatable
- Use the Next.js internationalization system
- Translation files are in
apps/web/messages/
- Reference file:
en-US.json
- Run
pnpm translations:check
to verify translations - Mark untranslated strings with
[TO_TRANSLATE]
prefix
Common Patterns
Authentication Providers
- Provider configurations in
apps/server/src/modules/auth-providers/providers.config.ts
- Support for OAuth2 and OIDC protocols
- Field mappings for user data normalization
- Special handling for providers like GitHub that require additional API calls
File Storage
- Default: Filesystem storage
- Optional: S3-compatible object storage
- File metadata stored in SQLite database
Environment Variables
- Configure via
.env
files (not committed to repository) - Required variables documented in README or docs
- Use environment-specific configurations
Contributing Guidelines
Pull Request Process
- Fork the repository
- Create a branch from
next
:git checkout -b feature/your-feature upstream/next
- Make focused changes addressing a single issue/feature
- Write or update tests as needed
- Update documentation to reflect changes
- Ensure all validations pass:
pnpm validate
in each app - Commit using Conventional Commits
- Push to your fork
- Create Pull Request targeting the
next
branch
Code Review
- Be responsive to feedback
- Keep discussions constructive and professional
- Make requested changes promptly
- Ask questions if requirements are unclear
What to Avoid
- Don't mix unrelated changes in a single PR
- Don't skip linting or type checking
- Don't commit directly to
main
ornext
branches - Don't add unnecessary dependencies
- Don't ignore existing code style and patterns
- Don't remove or modify tests without good reason
Helpful Commands
Root Level
pnpm install # Install all dependencies
git config core.hooksPath .husky # Configure Git hooks
Per App (web/server/docs)
pnpm dev # Start development server
pnpm build # Build for production
pnpm lint # Run ESLint
pnpm lint:fix # Fix ESLint issues automatically
pnpm format # Format code with Prettier
pnpm format:check # Check code formatting
pnpm type-check # Run TypeScript type checking
pnpm validate # Run lint + type-check
Docker
docker-compose up # Start all services
docker-compose down # Stop all services
Resources
- Documentation: https://palmr.kyantech.com.br
- Contributing Guide: CONTRIBUTING.md
- Issue Tracker: GitHub Issues
- License: Apache-2.0
Getting Help
- Review existing documentation in
apps/docs/content/docs/
- Check contribution guide in
CONTRIBUTING.md
- Review existing code for patterns and examples
- Ask questions in PR discussions or issues
- Read error messages and logs carefully
Important Notes
- Beta Status: This project is in beta; expect changes and improvements
- Focus on Quality: Prioritize code quality and maintainability over speed
- Test Locally: Always test your changes locally before submitting
- Documentation Matters: Keep documentation synchronized with code
- Community First: Be respectful, patient, and constructive with all contributors