Data Directory Structure
Legend uses a file-based storage system where all entity data, documentation, and branding assets are stored as plain text files in a structured directory layout. This approach provides transparency, portability, and easy integration with version control systems like Git.
Data Directory Location
Section titled “Data Directory Location”The data directory location is controlled by the LEGEND_DATA_DIR environment variable. By default, it is set to /app/data inside the Docker container, which is typically mounted to a host directory for persistence.
Default structure:
Directory
data/Directory
catalog/Entity YAML filesDirectory
landmarks/Landmark entities- …
Directory
people/Person entities- …
Directory
teams/Team entities- …
Directory
docs/Documentation filesDirectory
landmarks/Documentation for landmarks- …
Directory
people/Documentation for people- …
Directory
teams/Documentation for teams- …
Directory
branding/Custom branding assetslogo.pngCustom logofavicon-16.png16x16 faviconfavicon-32.png32x32 faviconfavicon-180.png180x180 favicon
Directory
backups/Database backupslegend-2024-01-15-020000.dblegend-2024-01-16-020000.dblegend-manual-2024-01-17-143022.db
Catalog Structure
Section titled “Catalog Structure”The catalog directory contains YAML files for each entity. Each entity type has its own subdirectory:
Landmarks:
data/catalog/landmarks/├── billing-api.yaml├── client-portal.yaml├── document-hub.yaml└── identity-provider.yamlPeople:
data/catalog/people/├── alex-johnson.yaml├── avery-allen.yaml└── jamie-kim.yamlTeams:
data/catalog/teams/├── client-services.yaml├── operations-and-production.yaml└── program-delivery.yamlEntity YAML Structure
Section titled “Entity YAML Structure”Each entity is stored as a YAML file with a standardized structure. Here’s an example of a landmark entity:
id: billing-apikind: landmarkmetadata: name: Billing API description: Payment processing and invoice management service category: service icon: credit-card tags: - production - critical - payments owner: type: team id: operations-and-production links: - title: Service Dashboard url: https://grafana.example.local/d/billing-api icon: chart-line - title: Runbook url: https://wiki.example.local/runbooks/billing-api icon: book - title: Repository url: https://github.com/example-org/billing-api icon: code relationships: dependsOn: - identity-provider - document-hub dependedOnBy: - resource-capacity-planner associations: [] accessGroups: [] editGroups: [] pinned: false featured: false active: truecreatedAt: 2024-01-10T14:23:45.123ZupdatedAt: 2024-01-15T09:45:12.456ZKey fields:
- id: Unique identifier for the entity (used in file names and relationships)
- kind: Entity type (landmark, person, or team)
- metadata: All entity properties
- name: Display name
- description: Brief summary
- category: Landmark category (only for landmarks)
- icon: FontAwesome icon name or custom URL
- tags: Array of tag names
- owner: Owner reference (team or person)
- links: Array of navigation links
- relationships: Dependencies and associations
- accessGroups: Groups that can view this entity
- editGroups: Groups that can edit this entity
- pinned: Whether the entity is pinned
- featured: Whether the entity is featured
- active: Whether the entity is active
- createdAt: Timestamp when the entity was created
- updatedAt: Timestamp when the entity was last modified
Documentation Files
Section titled “Documentation Files”Documentation files are stored in the docs/ directory, organized by entity type and entity ID:
data/docs/├── landmarks/│ ├── billing-api/│ │ ├── runbook.md│ │ ├── architecture.md│ │ └── incident-playbook.md│ └── client-portal/│ ├── user-guide.md│ └── api-docs.md├── people/│ └── alex-johnson/│ └── bio.md└── teams/ └── operations-and-production/ ├── team-charter.md └── onboarding.mdEach documentation file is a standard Markdown file with full syntax support:
# Billing API Runbook
## OverviewThis runbook covers common operational tasks for the Billing API service.
## Restarting the Service1. SSH into the production server2. Run `systemctl restart billing-api`3. Verify the service is running: `systemctl status billing-api`
## Common Issues
### High Latency- Check database connection pool- Review recent deployments- Monitor CPU and memory usage
### Payment Processing Failures- Verify payment gateway connectivity- Check error logs: `journalctl -u billing-api -f`- Review payment gateway status pageBranding Assets
Section titled “Branding Assets”Custom branding assets are stored in the branding/ directory:
data/branding/├── logo.png # Custom logo (uploaded via admin panel)├── favicon-16.png # 16x16 favicon├── favicon-32.png # 32x32 favicon└── favicon-180.png # 180x180 favicon (Apple touch icon)These files are uploaded through the admin panel and are not typically edited manually. If you need to update branding assets, use the admin interface rather than modifying files directly.
Editing YAML Files Directly
Section titled “Editing YAML Files Directly”Advanced users can edit YAML files directly using a text editor. This is useful for:
- Bulk updates to multiple entities
- Importing entities from external sources
- Version controlling entity definitions
- Automating entity creation with scripts
To edit YAML files directly:
- Access the data directory on your host system
- Navigate to the appropriate entity directory
- Edit the YAML file using a text editor
- Save the file
- Restart the Legend container to reload the data
Validation requirements:
- Valid YAML syntax
- Required fields present (id, kind, metadata.name)
- Unique entity IDs
- Valid relationship references
- Proper date formats (ISO 8601)
Reloading changes: After editing YAML files, you must restart the Legend container to reload the data:
docker compose restart legendOr if using Docker Run:
docker restart legendVersion Controlling the Catalog
Section titled “Version Controlling the Catalog”Because the catalog is stored as plain text YAML files, you can version control it using Git. This provides several benefits:
- Change history: Track who changed what and when
- Collaboration: Multiple people can propose changes through pull requests
- Rollback: Revert to previous versions if needed
- Code review: Review changes before they’re applied
- Automation: Integrate with CI/CD pipelines for automated deployments
Setting up Git version control:
-
Initialize a Git repository in your data directory:
Terminal window cd /path/to/legend-datagit init -
Create a
.gitignorefile to exclude files that shouldn’t be version controlled:Terminal window # Exclude backupsbackups/# Exclude database files*.db# Exclude temporary files*.tmp*.swp# Exclude OS files.DS_StoreThumbs.db -
Add and commit the catalog:
Terminal window git add catalog/ docs/git commit -m "Initial catalog commit" -
Push to a remote repository:
Terminal window git remote add origin https://github.com/your-org/legend-catalog.gitgit push -u origin main
Workflow for catalog changes:
-
Create a feature branch:
Terminal window git checkout -b add-new-service -
Make changes to YAML files
-
Commit changes:
Terminal window git add catalog/landmarks/new-service.yamlgit commit -m "Add new service: Payment Gateway" -
Push and create a pull request:
Terminal window git push origin add-new-service -
After review and merge, pull changes on the production server:
Terminal window git pull origin main -
Restart Legend to reload the catalog:
Terminal window docker compose restart legend
Data Portability
Section titled “Data Portability”The file-based storage system makes Legend data highly portable:
Migrating to a new server:
- Copy the entire data directory to the new server
- Configure the new Legend instance to use the same data directory
- Start the new instance
- All data is preserved
Backing up data:
- Copy the data directory to a backup location
- Use your server’s backup tools to include the data directory
- Store backups offsite for disaster recovery
Sharing data between instances:
- Copy specific entity YAML files between instances
- Use Git to synchronize catalogs across environments
- Export and import entities using YAML files
Troubleshooting
Section titled “Troubleshooting”Changes not appearing after editing YAML:
- Ensure you saved the file with valid YAML syntax
- Restart the Legend container to reload the data
- Check container logs for parsing errors
- Verify the file is in the correct directory
Entity not loading:
- Check YAML syntax for errors
- Ensure all required fields are present
- Verify the entity ID is unique
- Check that relationship references are valid
Documentation not appearing:
- Ensure the documentation file is in the correct directory
- Verify the file name matches the entity ID
- Check file permissions (must be readable by the container)
- Restart the container to reload documentation
Git conflicts after pulling changes:
- Resolve merge conflicts in YAML files
- Ensure entity IDs remain unique after merge
- Test the catalog locally before deploying
- Restart the container after resolving conflicts
Best Practices
Section titled “Best Practices”File Organization:
- Use consistent naming conventions for entity IDs (lowercase, hyphenated)
- Keep YAML files well-formatted and readable
- Use comments in YAML files to explain complex configurations
- Organize documentation files logically within entity directories
Version Control:
- Commit changes frequently with descriptive messages
- Use branches for major changes or experiments
- Review pull requests before merging
- Tag releases for important milestones
Backup Strategy:
- Back up the entire data directory regularly
- Store backups offsite for disaster recovery
- Test restore procedures periodically
- Keep multiple backup versions for rollback options
Collaboration:
- Use pull requests for catalog changes
- Document your catalog structure and conventions
- Provide templates for common entity types
- Train team members on YAML syntax and Legend data model
Next Steps
Section titled “Next Steps”After understanding the data directory structure, proceed to Environment Variables Reference to review all configuration options, or Troubleshooting for help with common issues.