Skip to content

Database Schema

pi22by7 edited this page Oct 26, 2025 · 1 revision

In Memoria - Database Schema

This document provides a detailed overview of the SQLite database schema used by In Memoria to store its learned intelligence. The schema is defined in src/storage/schema.sql and managed by the DatabaseMigrator in src/storage/migrations.ts.

Schema Overview

The database is designed to be a local, persistent store for all knowledge gathered about a codebase. It includes tables for semantic concepts, learned patterns, architectural decisions, and more.


Table Reference

semantic_concepts

This is one of the most important tables. It stores every individual semantic concept (like a class, function, or interface) extracted from the source code.

Column Type Description
id TEXT Primary Key. A unique identifier for the concept.
concept_name TEXT The name of the concept (e.g., "UserService", "calculateTotal").
concept_type TEXT The type of concept (e.g., 'class', 'function', 'interface').
confidence_score REAL A score from 0.0 to 1.0 indicating the confidence of the extraction.
relationships TEXT A JSON object storing relationships to other concepts (e.g., {"calls": ["other_id"]}).
evolution_history TEXT A JSON object tracking how the concept has changed over time across different analysis sessions.
file_path TEXT The absolute path to the file where the concept is defined.
line_range TEXT A JSON object with start and end line numbers.
created_at DATETIME The timestamp when the concept was first recorded.
updated_at DATETIME The timestamp when the concept was last updated.
  • Indexes: idx_semantic_concepts_type, idx_semantic_concepts_file

developer_patterns

Stores the coding patterns that have been learned from the codebase over time.

Column Type Description
pattern_id TEXT Primary Key. A unique identifier for the pattern.
pattern_type TEXT The category of the pattern (e.g., 'naming', 'structure', 'implementation').
pattern_content TEXT A JSON object containing the specific details of the pattern (e.g., for a naming pattern, { "case": "camelCase" }).
frequency INTEGER The number of times this pattern has been observed.
contexts TEXT A JSON array of contexts where the pattern applies (e.g., ["typescript", "function"]).
examples TEXT A JSON array of code snippets demonstrating the pattern.
confidence REAL A score from 0.0 to 1.0 indicating the confidence that this is a deliberate pattern.
created_at DATETIME The timestamp when the pattern was first learned.
last_seen DATETIME The timestamp when this pattern was last observed.
  • Indexes: idx_developer_patterns_type, idx_developer_patterns_frequency

project_blueprint Tables

These tables store the high-level project overview, enabling the get_project_blueprint tool.

feature_map

Maps high-level application features to the files that implement them.

Column Type Description
id TEXT Primary Key.
project_path TEXT The root path of the project this feature belongs to.
feature_name TEXT The name of the feature (e.g., 'authentication', 'api').
primary_files TEXT A JSON array of the main files implementing this feature.
related_files TEXT A JSON array of auxiliary files related to this feature.

entry_points

Stores the identified entry points for the application.

Column Type Description
id TEXT Primary Key.
project_path TEXT The root path of the project.
entry_type TEXT The type of entry point (e.g., 'web', 'api', 'cli').
file_path TEXT The path to the entry point file.
framework TEXT The framework associated with this entry point (e.g., 'React', 'Express').

key_directories

Stores the locations of important, conventionally named directories.

Column Type Description
id TEXT Primary Key.
project_path TEXT The root path of the project.
directory_path TEXT The path to the key directory (e.g., src/components).
directory_type TEXT The type of directory (e.g., 'components', 'services', 'utils').
file_count INTEGER The number of files within that directory.

work_sessions & project_decisions

These tables track the development context across sessions, providing a "work memory".

work_sessions

Records a timeline of development activity.

Column Type Description
id TEXT Primary Key.
project_path TEXT The project being worked on.
session_start DATETIME When the work session began.
session_end DATETIME When the work session ended (NULL if active).
last_feature TEXT The last feature that was being worked on.
current_files TEXT A JSON array of files that were open or being edited.
pending_tasks TEXT A JSON array of tasks the developer was planning to do.

project_decisions

Stores architectural and implementation decisions made during development, often contributed by an AI agent via the contribute_insights tool.

Column Type Description
id TEXT Primary Key.
project_path TEXT The relevant project.
decision_key TEXT A key for the decision (e.g., 'state_management_library').
decision_value TEXT The value of the decision (e.g., 'Redux').
reasoning TEXT The rationale behind the decision.
made_at DATETIME When the decision was recorded.

ai_insights

This table is a log of contributions made by AI agents, which can be validated and promoted into the main knowledge base.

Column Type Description
insight_id TEXT Primary Key.
insight_type TEXT The type of insight (e.g., 'bug_pattern', 'optimization').
insight_content TEXT A JSON object with the full content of the insight.
confidence_score REAL The AI agent's confidence in its own insight.
source_agent TEXT An identifier for the agent that contributed the insight.
validation_status TEXT The status of the insight ('pending', 'validated', 'rejected').

Clone this wiki locally