|
| 1 | +# Copilot Instructions for Nitrite Database |
| 2 | + |
| 3 | +## Project Overview |
| 4 | + |
| 5 | +Nitrite Database is an open source embedded NoSQL database for Java. It's a multi-module Maven project that supports both in-memory and file-based persistent storage. |
| 6 | + |
| 7 | +**Key Features:** |
| 8 | +- Embedded, serverless document store |
| 9 | +- Document-oriented with schema-less collections |
| 10 | +- Extensible storage engines (MVStore, RocksDB) |
| 11 | +- Full-text search and indexing |
| 12 | +- Transaction support |
| 13 | +- Android compatibility (API Level 26+) |
| 14 | + |
| 15 | +## Repository Structure |
| 16 | + |
| 17 | +This is a multi-module Maven project with the following modules: |
| 18 | + |
| 19 | +- `nitrite` - Core database module |
| 20 | +- `nitrite-bom` - Bill of materials for dependency management |
| 21 | +- `nitrite-jackson-mapper` - Jackson-based JSON mapper |
| 22 | +- `nitrite-mvstore-adapter` - MVStore storage adapter |
| 23 | +- `nitrite-rocksdb-adapter` - RocksDB storage adapter |
| 24 | +- `nitrite-spatial` - Spatial indexing support |
| 25 | +- `nitrite-support` - Support utilities |
| 26 | +- `nitrite-native-tests` - GraalVM native image tests |
| 27 | +- `potassium-nitrite` - Kotlin extension |
| 28 | + |
| 29 | +## Development Environment |
| 30 | + |
| 31 | +### Java Versions |
| 32 | +- **Minimum supported:** Java 11 (as configured in pom.xml) |
| 33 | +- **Primary testing:** Java 11 and 17 |
| 34 | +- **Native image testing:** Java 17 and 21 with GraalVM |
| 35 | + |
| 36 | +### Build Tool |
| 37 | +Maven is the build tool. Key commands: |
| 38 | + |
| 39 | +```bash |
| 40 | +# Build the project |
| 41 | +mvn clean install |
| 42 | + |
| 43 | +# Build without tests |
| 44 | +mvn clean install -DskipTests |
| 45 | + |
| 46 | +# Run tests only |
| 47 | +mvn test |
| 48 | + |
| 49 | +# Build specific module |
| 50 | +mvn -pl nitrite clean install |
| 51 | +``` |
| 52 | + |
| 53 | +## Code Guidelines |
| 54 | + |
| 55 | +### Java Standards |
| 56 | +1. **Minimum compatibility:** Code must compile and run on Java 11 (as per maven.compiler.source=11 in pom.xml) |
| 57 | +2. **Code style:** Follow existing code formatting in the repository (see `.editorconfig`) |
| 58 | +3. **Dependencies:** Check `pom.xml` files before adding new dependencies |
| 59 | +4. **API changes:** Be cautious with public API changes - this is a library used by others |
| 60 | + |
| 61 | +### Testing Requirements |
| 62 | +1. **Always run tests:** Execute `mvn test` before submitting changes |
| 63 | +2. **Write tests:** New features should include unit tests |
| 64 | +3. **Test coverage:** Maintain or improve code coverage (tracked via CodeCov) |
| 65 | +4. **Cross-platform:** Consider Linux, macOS, and Windows compatibility |
| 66 | + |
| 67 | +### Module-Specific Guidelines |
| 68 | +- When modifying storage adapters (`nitrite-mvstore-adapter`, `nitrite-rocksdb-adapter`), ensure compatibility with the core module |
| 69 | +- Changes to `nitrite` core module may require updates to adapter modules |
| 70 | +- Kotlin extension (`potassium-nitrite`) should mirror Java API capabilities |
| 71 | + |
| 72 | +## Pull Request Best Practices |
| 73 | + |
| 74 | +### Before Creating a PR |
| 75 | +1. Run full build: `mvn clean install` |
| 76 | +2. Ensure all tests pass across Java 11 and 17 |
| 77 | +3. Check for compilation warnings |
| 78 | +4. Update documentation if changing public APIs |
| 79 | +5. Add or update tests for your changes |
| 80 | + |
| 81 | +### PR Scope |
| 82 | +- Keep PRs focused on a single issue or feature |
| 83 | +- Include issue references in PR description |
| 84 | +- Document breaking changes clearly |
| 85 | +- Update CHANGELOG.md for significant changes |
| 86 | + |
| 87 | +### Review Process |
| 88 | +- All PRs require review before merging |
| 89 | +- CI must pass (build on Linux, macOS, Windows) |
| 90 | +- CodeQL security analysis must pass |
| 91 | +- Code coverage should not decrease significantly |
| 92 | + |
| 93 | +## Security Considerations |
| 94 | + |
| 95 | +1. **No secrets in code:** Never commit API keys, passwords, or credentials |
| 96 | +2. **Input validation:** Validate all user inputs, especially in query operations |
| 97 | +3. **File operations:** Be careful with file I/O operations in storage adapters |
| 98 | +4. **Dependencies:** Check for known vulnerabilities in dependencies |
| 99 | +5. **CodeQL:** Address any CodeQL security findings |
| 100 | + |
| 101 | +## Common Tasks |
| 102 | + |
| 103 | +### Good Tasks for Copilot |
| 104 | +- Bug fixes in specific modules |
| 105 | +- Adding unit tests to improve coverage |
| 106 | +- Documentation updates (JavaDoc, README) |
| 107 | +- Code style and formatting improvements |
| 108 | +- Refactoring isolated methods/classes |
| 109 | +- Adding new query operators or filters |
| 110 | +- Implementing feature requests with clear specifications |
| 111 | + |
| 112 | +### Tasks Requiring Human Review |
| 113 | +- Breaking API changes |
| 114 | +- Changes to core database engine logic |
| 115 | +- Modifications to transaction handling |
| 116 | +- Storage format changes |
| 117 | +- Security-sensitive operations |
| 118 | +- Multi-module architectural changes |
| 119 | + |
| 120 | +## Documentation |
| 121 | + |
| 122 | +- **JavaDoc:** All public APIs must have JavaDoc comments |
| 123 | +- **README updates:** Update README.md if changing features or usage |
| 124 | +- **User guide:** Major features may need documentation at https://nitrite.dizitart.com |
| 125 | +- **Code comments:** Add comments for complex logic, not obvious code |
| 126 | + |
| 127 | +## Gradle vs Maven |
| 128 | +This project uses **Maven**, not Gradle. All build commands should use `mvn`. |
| 129 | + |
| 130 | +## Related Projects |
| 131 | + |
| 132 | +- **Potassium Nitrite:** Kotlin extension within this repository |
| 133 | +- **Nitrite Flutter:** Separate repository for Flutter/Dart version |
| 134 | +- **Deprecated:** Nitrite DataGate and Nitrite Explorer (no longer maintained) |
| 135 | + |
| 136 | +## Communication |
| 137 | + |
| 138 | +- **Issues:** Use GitHub issues for bugs and feature requests |
| 139 | +- **Discussions:** Use GitHub Discussions for questions and community interaction |
| 140 | +- **Contributing:** See CONTRIBUTING.md for detailed contribution guidelines |
| 141 | + |
| 142 | +## Additional Resources |
| 143 | + |
| 144 | +- **Website:** https://nitrite.dizitart.com |
| 145 | +- **Documentation:** https://nitrite.dizitart.com/java-sdk/getting-started/index.html |
| 146 | +- **API Docs:** https://javadoc.io/doc/org.dizitart/nitrite |
| 147 | +- **GitHub:** https://github.com/nitrite/nitrite-java |
0 commit comments