| doc_id | DBS-PROJ-008 |
|---|---|
| doc_title | Contributing to Database System |
| doc_version | 1.0.0 |
| doc_date | 2026-04-04 |
| doc_status | Released |
| project | database_system |
| category | PROJ |
SSOT: This document is the single source of truth for Contributing to Database System.
Version: 0.1.0.0 Last Updated: 2025-11-11
Thank you for your interest in contributing to Database System! This guide will help you get started.
- Code of Conduct
- Getting Started
- Development Setup
- Making Changes
- Code Style
- Testing
- Documentation
- Submitting Changes
- Review Process
This project adheres to a code of conduct. By participating, you are expected to:
- Be respectful and inclusive
- Welcome newcomers and help them learn
- Focus on what is best for the community
- Show empathy towards other community members
Before contributing, ensure you have:
- C++17 compatible compiler (C++20 for async features)
- macOS: Xcode 10+ or Clang 5+
- Linux: GCC 7+ or Clang 5+
- Windows: Visual Studio 2017+ or MinGW-w64
- CMake 3.16 or higher
- Git
- Database-specific prerequisites:
- PostgreSQL development libraries (libpqxx, libpq, OpenSSL)
- SQLite development library (sqlite3)
- MongoDB C++ driver (mongocxx, bsoncxx)
- Redis client library (hiredis)
- Optional dependencies:
- common_system (for Result and ecosystem integration)
- thread_system (for high-performance async operations)
- logger_system (for integrated logging)
- monitoring_system (for performance metrics)
New to open source? Start here:
-
Browse issues labeled
good first issue: -
Read the documentation:
- Architecture Guide
- API Reference
- Build Guide
- Improvement Plan
-
Join discussions:
# Fork the repository on GitHub, then clone your fork
git clone https://github.com/YOUR_USERNAME/database_system.git
cd database_system
# Add upstream remote
git remote add upstream https://github.com/kcenon/database_system.git# Install vcpkg if not already installed
git clone https://github.com/Microsoft/vcpkg.git
cd vcpkg
./bootstrap-vcpkg.sh # Linux/macOS
# OR
bootstrap-vcpkg.bat # Windows
# Install all database dependencies
vcpkg install libpqxx openssl sqlite3 mongo-cxx-driver hiredisUbuntu/Debian:
sudo apt-get update
sudo apt-get install \
libpqxx-dev libpq-dev libssl-dev \
libsqlite3-dev \
libmongocxx-dev libbsoncxx-dev \
libhiredis-devmacOS:
brew install libpqxx postgresql openssl sqlite mongo-cxx-driver hiredisWindows: Use vcpkg (recommended) as manual installation is complex.
# Create build directory
mkdir build && cd build
# Configure with desired backends
cmake .. \
-DUSE_POSTGRESQL=ON \
-DUSE_SQLITE=ON \
-DUSE_MONGODB=ON \
-DUSE_REDIS=ON \
-DBUILD_DATABASE_SAMPLES=ON \
-DUSE_UNIT_TEST=ON
# Build
cmake --build . -j$(nproc)# Run all unit tests
ctest --output-on-failure
# Run specific test
ctest -R database_test
# Run with verbose output
ctest -VVRecommended tools:
# Code formatter (clang-format)
# Usually comes with clang installation
# Static analyzers
sudo apt-get install clang-tidy cppcheck # Linux
brew install clang-tidy cppcheck # macOS
# Markdown linter
npm install -g markdownlint-cli
# Link checker
npm install -g markdown-link-check-
Create a feature branch:
git checkout -b feature/your-feature-name # or git checkout -b fix/your-bug-fix -
Make your changes:
- Write clean, documented code
- Follow code style guidelines
- Add tests for new features
- Update documentation
-
Commit your changes:
git add . git commit -m "feat(backend): add MongoDB aggregation pipeline support"
-
Keep your branch updated:
git fetch upstream git rebase upstream/main
-
Push to your fork:
git push origin feature/your-feature-name
Follow Conventional Commits:
<type>(<scope>): <subject>
<body>
<footer>
Types:
feat: New featurefix: Bug fixdocs: Documentation changesstyle: Code style changes (formatting, no logic change)refactor: Code refactoringperf: Performance improvementstest: Adding or updating testsbuild: Build system changesci: CI/CD changeschore: Maintenance tasks
Scopes (database_system specific):
core: Core database abstraction layerbackend: Database backend implementations (postgres, sqlite, mongodb, redis)orm: ORM frameworkpool: Connection poolingquery: Query builderssecurity: Security features (TLS, RBAC, audit)monitoring: Performance monitoringasync: Async operationsadapter: Adapter pattern implementations
Examples:
feat(backend): add PostgreSQL JSONB support
Implement native JSONB operations for PostgreSQL backend.
Includes query builder integration and ORM mapping.
Closes #123
fix(pool): resolve connection leak in health checker
Add proper connection release in health check failure path.
Fixes memory leak detected by AddressSanitizer.
Fixes #456
docs(api): update connection pool configuration examples
- Add new pool sizing recommendations
- Update timeout configuration
- Add multi-backend pool examples
perf(query): optimize prepared statement caching
Implement LRU cache for prepared statements.
Reduces query latency by 15% in benchmark tests.
Benchmark results:
- Before: 1.2ms avg query time
- After: 1.02ms avg query time
Database System follows modern C++ best practices:
-
C++ Standard: Use C++17 features (C++20 for optional async/coroutines)
-
Naming Conventions:
snake_casefor variables, functions, filesPascalCasefor class namesUPPER_CASEfor constants and macros_suffix for private members (optional but preferred)
-
Formatting:
- Indentation: Tabs (not spaces)
- Line length: 100-120 characters
- Braces: K&R style (opening brace on same line)
namespace database {
/**
* @brief Manages database connections and provides query execution interface
*/
class database_manager {
public:
database_manager();
explicit database_manager(std::shared_ptr<database_context> context);
~database_manager();
/**
* @brief Set the database backend type
* @param database_type Type of database (postgres, sqlite, mongodb, redis, etc.)
* @return true if successful, false otherwise
*/
bool set_mode(const database_types& database_type);
/**
* @brief Check if database is connected
* @return true if connected, false otherwise
*/
bool is_connected() const noexcept;
private:
void cleanup_connections();
bool connected_;
std::unique_ptr<database_base> database_;
std::shared_ptr<database_context> context_;
std::shared_ptr<connection_pool_manager> pool_manager_;
};
} // namespace database- No warnings: Code must compile without warnings (
-Wall -Wextra -Wpedantic) - Modern C++: Use RAII, smart pointers, STL algorithms
- Const-correctness: Mark methods and parameters
constwhen possible - Exception safety: Provide at least basic exception safety guarantee
- Thread safety: Document thread-safety guarantees
- Resource management: Use smart pointers (
std::shared_ptr,std::unique_ptr)
Use #pragma once (preferred in this codebase):
#pragma once
#include <memory>
#include "database_types.h"
namespace database {
// ... declarations
}// 1. Corresponding header (for .cpp files)
#include "database/database_manager.h"
// 2. C system headers
#include <cstdint>
#include <cstring>
// 3. C++ standard library headers
#include <memory>
#include <string>
#include <vector>
// 4. Other library headers
#include <pqxx/pqxx>
// 5. Project headers
#include "database/connection_pool.h"
#include "database/query_builder.h"Run static analysis before submitting:
# Clang-Tidy
clang-tidy src/**/*.cpp -- -std=c++17
# Cppcheck
cppcheck --enable=all --std=c++17 database/- Use prepared statements for parameterized queries
- Leverage JSONB for semi-structured data
- Use CTEs for complex queries
- Enable WAL mode for concurrent access
- Use FTS5 for full-text search
- Proper transaction handling
- Use aggregation pipeline for complex queries
- Implement proper index strategies
- Handle BSON types correctly
- Use pipelining for batch operations
- Implement proper key expiration
- Handle data type conversions
All new features and bug fixes MUST include tests.
#include <gtest/gtest.h>
#include <database/database_manager.h>
namespace database::test {
TEST(DatabaseManager, BasicConnection) {
// Arrange
database_manager manager;
// Act
bool result = manager.set_mode(database_types::postgres);
// Assert
EXPECT_TRUE(result);
}
TEST(DatabaseManager, ConnectionPooling) {
// Test connection pool functionality
database_manager manager;
connection_pool_config config;
config.min_connections = 5;
config.max_connections = 20;
bool created = manager.create_connection_pool(database_types::postgres, config);
EXPECT_TRUE(created);
auto pool = manager.get_connection_pool(database_types::postgres);
EXPECT_NE(pool, nullptr);
}
TEST(DatabaseManager, ErrorHandling) {
// Test error cases
database_manager manager;
// Should fail - not connected
auto result = manager.select_query("SELECT * FROM users");
EXPECT_TRUE(result.empty());
}
TEST(DatabaseManager, ThreadSafety) {
// Test concurrent access
database_manager manager;
manager.set_mode(database_types::sqlite);
std::vector<std::thread> threads;
for (int i = 0; i < 10; ++i) {
threads.emplace_back([&manager]() {
auto result = manager.select_query("SELECT 1");
EXPECT_FALSE(result.empty());
});
}
for (auto& thread : threads) {
thread.join();
}
}
} // namespace database::test# All tests
ctest --output-on-failure
# Specific test suite
ctest -R ConnectionPoolTest
# With verbose output
ctest -VV
# With sanitizers (recommended before PR)
cmake -DCMAKE_CXX_FLAGS="-fsanitize=address,undefined" ..
cmake --build .
ctestEach database backend requires specific testing:
# Ensure PostgreSQL is running
sudo systemctl start postgresql
# OR
docker run -d -p 5432:5432 -e POSTGRES_PASSWORD=test postgres
# Run PostgreSQL-specific tests
ctest -R postgres_test# No server required
ctest -R sqlite_test# Ensure MongoDB is running
sudo systemctl start mongod
# OR
docker run -d -p 27017:27017 mongo
# Run MongoDB-specific tests
ctest -R mongodb_test# Ensure Redis is running
sudo systemctl start redis
# OR
docker run -d -p 6379:6379 redis
# Run Redis-specific tests
ctest -R redis_testAim for >80% code coverage for new code:
# Generate coverage report
cmake -DCMAKE_BUILD_TYPE=Debug -DENABLE_COVERAGE=ON ..
cmake --build .
ctest
lcov --capture --directory . --output-file coverage.info
genhtml coverage.info --output-directory coverage_report
# Open coverage report
open coverage_report/index.html # macOS
xdg-open coverage_report/index.html # LinuxFor performance-sensitive changes, provide benchmarks:
cd benchmarks
cmake ..
cmake --build .
./connection_pool_bench
./query_execution_bench
./transaction_benchInclude before/after performance numbers in pull request description.
Current benchmarks (baseline):
- Connection Pool: 0.1ms acquisition time
- Simple SELECT: 1.2ms (PostgreSQL), 0.8ms (SQLite), 0.3ms (Redis)
- Complex JOIN: 15ms (PostgreSQL)
- Bulk INSERT (1K): 45ms (PostgreSQL)
Use Doxygen-style comments:
/**
* @brief Execute a SELECT query and return results
*
* Executes the given SQL SELECT query and returns the results as a vector
* of rows. Each row is a map of column names to values. Supports all standard
* SQL data types with proper type conversion.
*
* @param query SQL SELECT query to execute
* @return Vector of rows (each row is a map of column->value)
* @throws std::runtime_error If query execution fails or database not connected
*
* @example
* ```cpp
* auto results = db.select_query("SELECT id, name FROM users WHERE age > 18");
* for (const auto& row : results) {
* auto id = std::get<int64_t>(row.at("id"));
* auto name = std::get<std::string>(row.at("name"));
* }
* ```
*/
database_result select_query(const std::string& query);Update documentation when:
- Adding new features
- Changing existing APIs
- Fixing bugs that affect usage
- Adding new backend support
- Modifying security features
Required updates:
- Update README.md if user-facing change
- Update API_REFERENCE.md for API changes
- Add entry to CHANGELOG.md
- Update examples if behavior changes
- Update Korean translations (.kr.md files)
- Update BUILD_GUIDE.md for new dependencies
Documentation checklist:
# Lint markdown
markdownlint docs/**/*.md
# Check links
markdown-link-check docs/**/*.md
# Spell check
cspell docs/**/*.mdEnsure your changes meet these criteria:
- Code compiles without warnings
- All tests pass (22/23 tests passing, 1 skipped is acceptable)
- New tests added for new features
- Code follows style guidelines (tabs, K&R braces, snake_case)
- Documentation updated
- Commit messages follow conventions
- No merge conflicts with
mainbranch - Static analysis passes (clang-tidy, cppcheck)
- Backend-specific tests pass (if applicable)
-
Push your branch:
git push origin feature/your-feature-name
-
Open pull request on GitHub:
- Title: Brief description (50 chars or less)
- Description: Detailed explanation including:
- What changed and why
- Related issue numbers (#123)
- Breaking changes (if any)
- Testing performed
- Performance impact (if applicable)
- Backend compatibility notes
-
Pull request template:
## Description
Brief description of changes
## Type of Change
- [ ] Bug fix
- [ ] New feature
- [ ] Breaking change
- [ ] Documentation update
- [ ] Backend implementation
- [ ] Performance improvement
- [ ] Security enhancement
## Backend Impact
- [ ] PostgreSQL
- [ ] SQLite
- [ ] MongoDB
- [ ] Redis
- [ ] Core abstraction layer
## Related Issues
Closes #123
## Testing
- [ ] All tests pass (22/23)
- [ ] Added new tests
- [ ] Manual testing performed
- [ ] Backend-specific testing completed
- [ ] Performance benchmarks run (if applicable)
## Checklist
- [ ] Code follows style guidelines
- [ ] Self-reviewed code
- [ ] Commented complex code
- [ ] Updated documentation
- [ ] No new warnings
- [ ] Added tests for changes
- [ ] All tests passing
- [ ] Thread-safety verified
- [ ] Memory leaks checked (AddressSanitizer)For work-in-progress changes:
- Mark PR as "Draft"
- Use
[WIP]prefix in title - Request early feedback if needed
-
Automated checks: CI/CD runs automatically
- Build verification (Linux, macOS, Windows)
- Test suite (all 5 backends)
- Code style checks
- Static analysis (clang-tidy, cppcheck)
- Memory leak detection (AddressSanitizer)
- Thread safety verification (ThreadSanitizer)
-
Code review: Maintainers will review your code
- Usually within 1-3 business days
- May request changes
- Be responsive to feedback
- Focus on correctness, performance, and security
-
Approval: Once approved and checks pass
- PR will be merged by maintainers
- Your contribution appears in next release!
# Make requested changes
git add .
git commit -m "address review feedback: improve error handling"
git push origin feature/your-feature-nameNo need to create a new PR - just push to same branch.
# Update your local main branch
git checkout main
git pull upstream main
# Delete feature branch (optional)
git branch -d feature/your-feature-name
git push origin --delete feature/your-feature-namemain- Stable codedevelop- Integration branch for next release (if used)feature/*- New featuresfix/*- Bug fixesdocs/*- Documentation updatesperf/*- Performance improvementsrefactor/*- Code refactoring
Current Status: Active development
- Major releases: Every 6-12 months (breaking changes, new backends)
- Minor releases: Monthly (new features, improvements)
- Patch releases: As needed for critical bugs
Current Version: 1.0.0 (Phase 2 completed, Phase 3 C++17 migration complete)
Follows Semantic Versioning:
- MAJOR.MINOR.PATCH (e.g., 1.0.0)
Breaking Changes: Requires major version bump New Features: Minor version bump Bug Fixes: Patch version bump
-
Backend Implementations
- Improve existing backend performance
- Add new database backend support
- Enhance backend plugin architecture
-
ORM Framework
- Enhanced entity mapping
- Advanced relationship support
- Schema migration system
-
Security Features
- Additional authentication methods
- Advanced encryption options
- Improved audit logging
- Threat detection enhancements
-
Performance Optimization
- Query optimization algorithms
- Advanced caching strategies
- Connection pool improvements
- Bulk operation enhancements
-
Testing & Quality
- Increase test coverage (target: 90%+)
- Add more integration tests
- Improve benchmark coverage
- Thread safety verification
- COPY command support
- Advanced JSONB operations
- Partition table support
- Replication support
- Virtual table support
- Extension loading
- Backup/restore utilities
- Write-ahead logging improvements
- Aggregation pipeline optimization
- GridFS support
- Sharding support
- Change streams
- Redis Cluster support
- Redis Streams
- Module support
- Geo-spatial operations
- Documentation: docs/
- Examples: samples/
- Build Guide: docs/guides/BUILD_GUIDE.md
- Architecture: docs/ARCHITECTURE.md
- API Reference: docs/API_REFERENCE.md
- Improvement Plan: Improvement Plan
- Questions: GitHub Discussions
- Bug reports: GitHub Issues
- Feature requests: GitHub Issues
- Security issues: Email maintainers directly (see SECURITY.md)
Contributors are recognized in:
- CHANGELOG.md - Listed in release notes
- GitHub Contributors - Automatically tracked
- Project README - Significant contributors highlighted
By contributing to database_system, you agree that your contributions will be licensed under the BSD 3-Clause License.
Your contributions make database_system better for everyone. We appreciate your time and effort!
Maintainers: @kcenon Last Updated: 2025-11-11