Security-First Database Schema Documentation Generator
Generate comprehensive, readable documentation from your database schema without exposing source code. Perfect for compliance, onboarding, and external sharing.
- 🛡️ Security-First: Extracts metadata only, never source code (procedures, triggers, views)
- 📊 Comprehensive: Covers Tables, Views, Routines, Sequences, Triggers, Synonyms, and Indexes
- 💼 Multi-DBMS: Supports Oracle, PostgreSQL, MySQL, SQL Server, SQLite
- 📝 Multiple Formats: Generate Markdown, HTML, or PDF documentation
- ⚙️ Highly Configurable: YAML-based configuration with granular control
- 🚀 Fast & Lightweight: Written in Go, single binary deployment
# Clone the repository
git clone https://github.com/yourusername/pocket-doc.git
cd pocket-doc
# Build
go build -o dbms-to-doc ./cmd/dbms-to-doc
# Or install
go install ./cmd/dbms-to-doc# 1. Create configuration
cp config.example.yaml config.yaml
# 2. Edit config.yaml with your database credentials
vim config.yaml
# 3. Generate documentation
./dbms-to-doc -config config.yaml| Object Type | Information Included |
|---|---|
| Tables | Name, columns, data types, constraints, indexes, row counts |
| Views | Name, columns, dependencies (no SQL definition) |
| Routines | Name, type, parameters, return type, signature (no body) |
| Sequences | Min/max values, increment, current value |
| Triggers | Name, timing, event, target table (no trigger code) |
| Synonyms | Name, target object, owner |
| Indexes | Name, columns, type, uniqueness |
| Columns | Name, data type, nullable, default, constraints |
The following are NEVER extracted to prevent IP leakage:
- ❌ Stored procedure/function bodies
- ❌ Trigger implementation code
- ❌ View SQL definitions
- ❌ Any executable scripts or logic
database:
type: "oracle"
host: "localhost"
port: 1521
database: "ORCL"
username: "system"
password: "oracle"
output:
format: "markdown"
output_dir: "./output"
include_toc: true
language: "en"
extract:
include_tables: true
include_views: true
include_routines: true
include_sequences: true
include_triggers: true
include_synonyms: true
exclude_system: trueSee config.example.yaml for all options.
pocket-doc/
├── cmd/dbms-to-doc/ # CLI application
├── internal/
│ ├── model/ # Schema data models
│ ├── extractor/ # Database extractors (interface + implementations)
│ ├── config/ # Configuration (Viper-compatible)
│ ├── generator/ # Document generators (Markdown, HTML, PDF)
│ └── template/ # Documentation templates
├── docs/ # Architecture documentation
├── tools/ # Validation and build tools
└── config.example.yaml # Configuration template
type Extractor interface {
Connect(ctx context.Context) error
GetTables(ctx context.Context) ([]model.Table, error)
GetViews(ctx context.Context) ([]model.View, error)
GetRoutines(ctx context.Context) ([]model.Routine, error)
GetSequences(ctx context.Context) ([]model.Sequence, error)
GetTriggers(ctx context.Context) ([]model.Trigger, error)
GetSynonyms(ctx context.Context) ([]model.Synonym, error)
ExtractSchema(ctx context.Context) (*model.Schema, error)
}| Database | Status | Version |
|---|---|---|
| Oracle | 🚧 In Progress | 11g+ |
| PostgreSQL | 📋 Planned | 12+ |
| MySQL | 📋 Planned | 8.0+ |
| SQL Server | 📋 Planned | 2017+ |
| SQLite | 📋 Planned | 3.x |
- Phase 1 Architecture - Design decisions and data models
- Architecture Diagrams - Visual system overview
- Self-Check Report - Compliance validation
- Configuration Guide - All configuration options
Ensure compliance with security and quality rules:
go run tools/validate_phase1.goExpected Output:
✅ PASS Rule: NO SOURCE CODE FIELDS (Security)
✅ PASS Rule: COMMENT FIELDS ON ALL STRUCTS (Rich Metadata)
✅ PASS Rule: FULL OBJECT COVERAGE
✅ PASS Rule: VIPER COMPATIBILITY (mapstructure tags)
✅ ALL CHECKS PASSED - Phase 1 Complete!
- No Source Code Extraction: Procedures, functions, triggers, and views are documented by signature/metadata only
- Safe for External Sharing: Generated documentation contains no proprietary logic
- Compliance-Ready: Suitable for security audits and public wikis
- Configurable Filtering: Exclude sensitive schemas or tables
Contributions are welcome! To add support for a new database:
- Implement the
Extractorinterface - Add to factory in
internal/extractor/factory.go - Write tests
- Update documentation
MIT License - see LICENSE file for details.
- Lightweight: < 10MB binary
- Fast: Extract 1000+ database objects in seconds
- Low Memory: Streaming extraction for large databases
- Concurrent: Parallel object extraction
- Issues: GitHub Issues
- Discussions: GitHub Discussions
Built with ❤️ and Go
Secure your code. Document your schema.