mirror of
https://github.com/navidrome/navidrome.git
synced 2025-07-14 15:41:18 +03:00
2.2 KiB
2.2 KiB
Navidrome Code Guidelines
This is a music streaming server written in Go with a React frontend. The application manages music libraries, provides streaming capabilities, and offers various features like artist information, artwork handling, and external service integrations.
Code Standards
Backend (Go)
- Follow standard Go conventions and idioms
- Use context propagation for cancellation signals
- Write unit tests for new functionality using Ginkgo/Gomega
- Use mutex appropriately for concurrent operations
- Implement interfaces for dependencies to facilitate testing
Frontend (React)
- Use functional components with hooks
- Follow React best practices for state management
- Implement PropTypes for component properties
- Prefer using React-Admin and Material-UI components
- Icons should be imported from
react-icons
only - Follow existing patterns for API interaction
Repository Structure
core/
: Server-side business logic (artwork handling, playback, etc.)ui/
: React frontend componentsmodel/
: Data models and repository interfacesserver/
: API endpoints and server implementationutils/
: Shared utility functionspersistence/
: Database access layerscanner/
: Music library scanning functionality
Key Guidelines
- Maintain cache management patterns for performance
- Follow the existing concurrency patterns (mutex, atomic)
- Use the testing framework appropriately (Ginkgo/Gomega for Go)
- Keep UI components focused and reusable
- Document configuration options in code
- Consider performance implications when working with music libraries
- Follow existing error handling patterns
- Ensure compatibility with external services (LastFM, Spotify)
Development Workflow
- Test changes thoroughly, especially around concurrent operations
- Validate both backend and frontend interactions
- Consider how changes will affect user experience and performance
- Test with different music library sizes and configurations
- Always run formatting and linting before committing changes
Important commands
make build
: Build the applicationmake test
: Run Go tests- To run tests for a specific package, use
make test PKG=./pkgname/...
make lintall
: Run lintersmake format
: Format code