import { ArchLensConfig, ProjectMetadata, DatabaseTable, DatabaseRelationship, DatabaseIndex, DatabaseEnum, DatabaseGraph, DatabaseColumn, ArchitectureGraph, ArchitectureNode, CodeReviewReport, DatabaseFieldUsageReport, EnvVar, DetectedSignal, InfraResource, WorkspaceGraph, CodeReviewRule, CodeReviewIssue, CodeReviewIssueType, CodeReviewSeverity, CodeReviewCategory, WorkspaceDbFieldUsageReport, ArchitectureEdge } from '@archlens/schema';
export * from '@archlens/schema';

declare const CONFIG_FILE = ".archlensrc.json";
declare const IGNORE_FILE = ".archlensignore";
declare function defaultConfig(projectName?: string): ArchLensConfig;
declare function loadConfig(cwd: string): Promise<ArchLensConfig>;
declare function readIgnorePatterns(cwd: string): Promise<string[]>;
type InitResult = {
    configPath: string;
    ignorePath: string;
    outputDir: string;
    created: string[];
    skipped: string[];
};
declare function initializeProject(cwd: string, options?: {
    force?: boolean;
}): Promise<InitResult>;

type FileInfo = {
    path: string;
    absolutePath: string;
    extension: string;
    sizeBytes: number;
};
declare function scanFiles(cwd: string, config: ArchLensConfig): Promise<FileInfo[]>;

declare function detectProjectMetadata(cwd: string, files: FileInfo[]): Promise<ProjectMetadata>;

type ImportInfo = {
    source: string;
    specifiers: string[];
    file: string;
    line: number;
};
type ExportInfo = {
    name: string;
    kind: string;
    file: string;
    line: number;
};
type ClassInfo = {
    name: string;
    exported: boolean;
    file: string;
    line: number;
};
type FunctionInfo = {
    name: string;
    exported: boolean;
    file: string;
    line: number;
};
type RouteInfo = {
    framework: "express" | "nestjs" | "fastify";
    method: string;
    path: string;
    file: string;
    line: number;
    handler?: string;
    controller?: string;
    routerName?: string;
    mountPath?: string;
    localPath?: string;
    serviceName?: string;
    globalPrefix?: string;
};
type ExpressMountInfo = {
    basePath: string;
    routerName: string;
    file: string;
    line: number;
    importSource?: string;
};
type SourceFileAnalysis = {
    file: string;
    lineCount: number;
    sizeBytes: number;
    imports: ImportInfo[];
    exports: ExportInfo[];
    classes: ClassInfo[];
    functions: FunctionInfo[];
    routes: RouteInfo[];
    expressMounts: ExpressMountInfo[];
    todoCount: number;
};
type SourceAnalysis = {
    files: SourceFileAnalysis[];
    imports: ImportInfo[];
    exports: ExportInfo[];
    classes: ClassInfo[];
    functions: FunctionInfo[];
    routes: RouteInfo[];
    expressMounts: ExpressMountInfo[];
    todoCount: number;
};
declare function resolveImportToFile(importer: string, importSource: string, knownFiles: Set<string>): string | undefined;
declare function analyzeSourceFiles(files: FileInfo[]): Promise<SourceAnalysis>;

type ParsedDatabaseArtifacts = {
    tables: DatabaseTable[];
    relationships: DatabaseRelationship[];
    indexes: DatabaseIndex[];
    enums?: DatabaseEnum[];
};
declare function parsePrismaSchema(text: string, filePath?: string): ParsedDatabaseArtifacts;
declare function parsePrismaFiles(files: FileInfo[]): Promise<ParsedDatabaseArtifacts>;

declare function parseSqlSchema(text: string, filePath?: string): ParsedDatabaseArtifacts;
declare function parseSqlFiles(files: FileInfo[]): Promise<ParsedDatabaseArtifacts>;

declare function parseTypeOrmSource(text: string, filePath?: string): ParsedDatabaseArtifacts;
declare function parseTypeOrmFiles(files: FileInfo[]): Promise<ParsedDatabaseArtifacts>;

declare function parseMongooseSource(text: string, filePath?: string): ParsedDatabaseArtifacts;
declare function parseMongooseFiles(files: FileInfo[]): Promise<ParsedDatabaseArtifacts>;

declare function markSensitiveColumns(columns: DatabaseColumn[]): DatabaseColumn[];
declare function buildDatabaseGraph(...artifacts: ParsedDatabaseArtifacts[]): DatabaseGraph;

declare function buildArchitectureGraph(project: ProjectMetadata, source: SourceAnalysis, database: DatabaseGraph): ArchitectureGraph;

type RiskItem = {
    severity: "low" | "medium" | "high";
    title: string;
    detail: string;
    source?: string;
};
declare function detectRisks(source: SourceAnalysis, database: DatabaseGraph): RiskItem[];

type GeneratedDocs = {
    architecture: string;
    database: string;
    api: string;
    risks: string;
};
declare function generateArchitectureDoc(project: ProjectMetadata, graph: ArchitectureGraph, source: SourceAnalysis, risks: RiskItem[]): string;
declare function generateDatabaseDoc(database: DatabaseGraph): string;
declare function generateApiDoc(source: SourceAnalysis): string;
declare function generateRisksDoc(risks: RiskItem[]): string;
declare function generateDocs(project: ProjectMetadata, graph: ArchitectureGraph, database: DatabaseGraph, source: SourceAnalysis, risks: RiskItem[]): GeneratedDocs;

type DiagramType = "context" | "container" | "erd" | "data-flow";
type DiagramFormat = "mermaid" | "json";
declare function generateContextDiagram(graph: ArchitectureGraph, database: DatabaseGraph): string;
declare function generateContainerDiagram(graph: ArchitectureGraph): string;
declare function generateErdDiagram(database: DatabaseGraph): string;
declare function generateDataFlowDiagram(graph: ArchitectureGraph, database: DatabaseGraph): string;
declare function generateDiagrams(graph: ArchitectureGraph, database: DatabaseGraph): Record<DiagramType, string>;

declare function renderGeneratedDiagram(cwd: string, type: DiagramType, format: DiagramFormat, outputDir?: string): Promise<{
    content: string;
    outputPath: string;
}>;

type ExportFormat = "markdown" | "html" | "json";
type ExportResult = {
    outputDir: string;
    files: string[];
};
declare function exportGenerated(cwd: string, format: ExportFormat, outputDir?: string): Promise<ExportResult>;

type DiffItem<T> = {
    id: string;
    before?: T;
    after?: T;
};
type GraphSnapshot = {
    architecture: ArchitectureGraph;
    database: DatabaseGraph;
    source: string;
};
type ArchitectureDiffReport = {
    from: string;
    to: string;
    addedNodes: ArchitectureNode[];
    removedNodes: ArchitectureNode[];
    changedNodes: DiffItem<ArchitectureNode>[];
    addedRoutes: ArchitectureNode[];
    removedRoutes: ArchitectureNode[];
    changedRoutes: DiffItem<ArchitectureNode>[];
    addedTables: DatabaseTable[];
    removedTables: DatabaseTable[];
    changedTables: DiffItem<DatabaseTable>[];
    addedColumns: DiffItem<string>[];
    removedColumns: DiffItem<string>[];
    changedColumns: DiffItem<string>[];
    generatedAt: string;
};
declare function loadGraphSnapshot(input: string, cwd?: string): Promise<GraphSnapshot>;
declare function diffGraphSnapshots(from: GraphSnapshot, to: GraphSnapshot): ArchitectureDiffReport;
declare function renderDiffReport(report: ArchitectureDiffReport): string;
declare function generateDiffReport(options: {
    from: string;
    to: string;
    cwd?: string;
    outputCwd?: string;
    outputDir?: string;
}): Promise<{
    report: ArchitectureDiffReport;
    markdown: string;
    outputPath: string;
}>;

type ValidationIssue = {
    severity: "error" | "warning";
    message: string;
    path?: string;
};
type ValidationResult = {
    valid: boolean;
    issues: ValidationIssue[];
    architecture?: ArchitectureGraph;
    database?: DatabaseGraph;
};
declare function validateArchitectureGraph(graph: unknown): {
    graph?: ArchitectureGraph;
    issues: ValidationIssue[];
};
declare function validateDatabaseGraph(graph: unknown): {
    graph?: DatabaseGraph;
    issues: ValidationIssue[];
};
declare function validateGeneratedOutput(cwd: string, outputDir?: string): Promise<ValidationResult>;

type ScanSummary = {
    projectName: string;
    generatedAt: string;
    filesScanned: number;
    languages: string[];
    frameworks: string[];
    routes: number;
    tables: number;
    nodes: number;
    edges: number;
    risks: number;
    reviewIssues?: number;
    modules: string[];
    packageManager?: string;
    services: Array<{
        name: string;
        path: string;
        packageManager?: string;
        frameworks: string[];
        languages: string[];
    }>;
    apiRoutes: Array<{
        method: string;
        path: string;
        file: string;
        line?: number;
        framework?: string;
        controller?: string;
        handler?: string;
        serviceName?: string;
        globalPrefix?: string;
        localPath?: string;
    }>;
    architectureNodes: number;
    sourceFiles: number;
};
type ScanResult = {
    cwd: string;
    outputDir: string;
    files: FileInfo[];
    project: ProjectMetadata;
    source: SourceAnalysis;
    architectureGraph: ArchitectureGraph;
    databaseGraph: DatabaseGraph;
    docs: GeneratedDocs;
    diagrams: Record<DiagramType, string>;
    risks: RiskItem[];
    review?: CodeReviewReport;
    dbFieldUsage?: DatabaseFieldUsageReport;
    summary: ScanSummary;
};
declare function scanProject(cwd?: string): Promise<ScanResult>;

type EnvScanResult = {
    env: EnvVar[];
    ignoredRealEnvFiles: string[];
};
declare function scanEnvironmentSignals(cwd: string, files: FileInfo[]): Promise<EnvScanResult>;

type DependencyInferenceResult = {
    signals: DetectedSignal[];
};
declare function inferArchitectureSignalsFromDependencies(args: {
    dependencies: Record<string, string>;
    packageJsonPath: string;
}): DependencyInferenceResult;

type InfraScanResult = {
    infra: InfraResource[];
    exposedPorts: number[];
    dockerServices: string[];
    dockerDependsOn: Array<{
        service: string;
        dependsOn: string[];
    }>;
};
declare function scanInfrastructureSignals(cwd: string, files: FileInfo[]): Promise<InfraScanResult>;

type CodeIntegrationScanResult = {
    signals: DetectedSignal[];
    envKeyReferences: string[];
};
declare function scanCodeIntegrationSignals(files: FileInfo[]): Promise<CodeIntegrationScanResult>;

type ServiceCandidate = {
    id: string;
    name: string;
    path: string;
    markers: string[];
};
declare function detectWorkspaceServices(rootDir: string): Promise<ServiceCandidate[]>;

type WorkspaceScanResult = {
    workspace: WorkspaceGraph;
};
declare function scanWorkspace(rootDir?: string, outputDir?: string): Promise<WorkspaceScanResult>;

type SolutionArtifacts = {
    envVars: EnvVar[];
    dependencySignals: DetectedSignal[];
    infraResources: InfraResource[];
    codeSignals: DetectedSignal[];
    docs: {
        environment: string;
        integrations: string;
        infrastructure: string;
    };
    diagrams: {
        solution: string;
    };
};
declare function buildSolutionDiagram(args: {
    projectLabel: string;
    frameworks: string[];
    signals: DetectedSignal[];
}): string;
declare function buildSolutionArtifacts(args: {
    projectLabel: string;
    frameworks: string[];
    envVars: EnvVar[];
    ignoredRealEnvFiles: string[];
    dependencySignals: DetectedSignal[];
    infraResources: InfraResource[];
    exposedPorts: number[];
    codeSignals: DetectedSignal[];
}): SolutionArtifacts;

declare function detectSolutionRisks(args: {
    envVars: EnvVar[];
    ignoredRealEnvFiles: string[];
    dependencySignals: DetectedSignal[];
    codeSignals: DetectedSignal[];
    exposedPorts: number[];
    databaseGraph: DatabaseGraph;
}): RiskItem[];

type ReviewSourceFile = {
    path: string;
    absolutePath: string;
    extension: string;
    language: string;
    module?: string;
    sizeBytes: number;
    text: string;
    lines: string[];
};
type RuleContext = {
    cwd: string;
    project: ProjectMetadata;
    files: ReviewSourceFile[];
    source: SourceAnalysis;
    architectureGraph: ArchitectureGraph;
    databaseGraph: DatabaseGraph;
    config: ArchLensConfig;
};
type RuleResult = Omit<CodeReviewIssue, "id">;
type RuleDefinition = CodeReviewRule & {
    run: (context: RuleContext) => RuleResult[];
};
type RuleIssueInput = {
    type: CodeReviewIssueType;
    filePath: string;
    line?: number;
    column?: number;
    endLine?: number;
    module?: string;
    framework?: string;
    evidence?: string[];
    recommendation?: string;
    remediation?: string;
    confidence?: number;
    tags?: string[];
    title?: string;
    description?: string;
    severity?: CodeReviewSeverity;
    category?: CodeReviewCategory;
};

type CodeReviewInput = {
    cwd: string;
    project: ProjectMetadata;
    files: FileInfo[];
    source: SourceAnalysis;
    architectureGraph: ArchitectureGraph;
    databaseGraph: DatabaseGraph;
    config: ArchLensConfig;
    generatedAt?: string;
};
type RuleRunner = {
    rules: RuleDefinition[];
    run: (context: RuleContext) => RuleResult[];
};
declare const allReviewRules: RuleDefinition[];
declare function generateCodeReviewReport(input: CodeReviewInput): Promise<CodeReviewReport>;
declare function writeCodeReviewOutputs(cwd: string, outputDir: string, report: CodeReviewReport): Promise<void>;

declare function writeCodeReviewJsonReport(filePath: string, report: CodeReviewReport): Promise<void>;
declare function writeCodeReviewRulesJson(filePath: string, rules: CodeReviewRule[]): Promise<void>;

declare function renderCodeReviewMarkdown(report: CodeReviewReport): string;
declare function writeCodeReviewMarkdownReport(filePath: string, report: CodeReviewReport): Promise<void>;

declare const backendRules: RuleDefinition[];

declare const frontendRules: RuleDefinition[];

declare const databaseRules: RuleDefinition[];

declare const redisRules: RuleDefinition[];

declare const securityRules: RuleDefinition[];

declare const performanceRules: RuleDefinition[];

declare const architectureRules: RuleDefinition[];

type FileInfoInput = FileInfo & {
    text?: string;
};

declare function buildDatabaseFieldUsageReport(input: {
    projectName: string;
    rootPath: string;
    databaseGraph: DatabaseGraph;
    files: FileInfoInput[];
    routes: RouteInfo[];
    generatedAt?: string;
}): Promise<DatabaseFieldUsageReport>;

declare function writeDbUsageOutputs(cwd: string, outputDir: string, report: DatabaseFieldUsageReport): Promise<void>;

type DbUsageQuery = {
    table?: string;
    field?: string;
    impact?: boolean;
};
declare function filterDbUsageReport(report: DatabaseFieldUsageReport, query: DbUsageQuery): {
    report: DatabaseFieldUsageReport;
    impact?: ImpactView;
};
type ImpactView = {
    label: string;
    riskLevel: "low" | "medium" | "high";
    files: string[];
    modules: string[];
    apis: string[];
    functions: string[];
    classes: string[];
    usageBreakdown: Record<string, number>;
    highImpact: boolean;
};
declare function formatDbUsageCliOutput(report: DatabaseFieldUsageReport, query: DbUsageQuery, impact?: ImpactView): string;

declare function mergeWorkspaceDbFieldUsage(input: {
    workspaceName: string;
    rootPath: string;
    services: Array<{
        name: string;
        path: string;
        report: DatabaseFieldUsageReport;
    }>;
    generatedAt?: string;
}): WorkspaceDbFieldUsageReport;
declare function writeWorkspaceDbUsageReport(rootDir: string, outputDir: string, report: WorkspaceDbFieldUsageReport): Promise<void>;

declare function generateDbFieldUsageSummaryMd(report: DatabaseFieldUsageReport): string;
declare function generateDbFieldUsageDoc(report: DatabaseFieldUsageReport): string;

type GroundedEvidence = {
    architecture: {
        nodes: ArchitectureNode[];
        edges: ArchitectureEdge[];
    };
    database: {
        tables: DatabaseTable[];
        relationships: DatabaseRelationship[];
    };
    docs: {
        file: string;
        excerpt: string;
    }[];
};
type GroundedContextResult = {
    question: string;
    context: string;
    evidence: GroundedEvidence;
};
declare function retrieveGroundedEvidence(args: {
    architecture: ArchitectureGraph;
    database: DatabaseGraph;
    docs: Record<string, string>;
    question: string;
    maxNodes?: number;
    maxTables?: number;
    maxColumnsPerTable?: number;
    maxDocLines?: number;
}): GroundedEvidence;
declare function formatGroundedContext(args: {
    question: string;
    evidence: GroundedEvidence;
}): string;
declare function buildGroundedContextFromProject(args: {
    cwd?: string;
    outputDir?: string;
    question: string;
    maxNodes?: number;
    maxTables?: number;
    maxColumnsPerTable?: number;
    maxDocLines?: number;
}): Promise<GroundedContextResult>;
declare function chatWithGrounding(args: {
    cwd?: string;
    question: string;
}): Promise<{
    answer: string;
    groundedContext: string;
    providerUsed?: string;
}>;

type LlmChatMessage = {
    role: "system" | "user" | "assistant";
    content: string;
};
type LlmChatRequest = {
    model?: string;
    messages: LlmChatMessage[];
    apiKey?: string;
};
type LlmProvider = {
    provider: string;
    chat: (request: LlmChatRequest) => Promise<string>;
};

declare function resolveApiKey(llmConfig: ArchLensConfig["llm"]): string | undefined;
declare function createConfiguredProvider(llmConfig: ArchLensConfig["llm"]): LlmProvider | undefined;
declare function buildProviderChatRequest(args: {
    llmConfig: ArchLensConfig["llm"];
    messages: LlmChatMessage[];
}): LlmChatRequest;

export { type ArchitectureDiffReport, CONFIG_FILE, type ClassInfo, type CodeIntegrationScanResult, type CodeReviewInput, type DbUsageQuery, type DependencyInferenceResult, type DiagramFormat, type DiagramType, type DiffItem, type EnvScanResult, type ExportFormat, type ExportInfo, type ExportResult, type ExpressMountInfo, type FileInfo, type FunctionInfo, type GeneratedDocs, type GraphSnapshot, type GroundedContextResult, type GroundedEvidence, IGNORE_FILE, type ImpactView, type ImportInfo, type InfraScanResult, type InitResult, type LlmChatMessage, type LlmChatRequest, type LlmProvider, type ParsedDatabaseArtifacts, type ReviewSourceFile, type RiskItem, type RouteInfo, type RuleContext, type RuleDefinition, type RuleIssueInput, type RuleResult, type RuleRunner, type ScanResult, type ScanSummary, type ServiceCandidate, type SolutionArtifacts, type SourceAnalysis, type SourceFileAnalysis, type ValidationIssue, type ValidationResult, type WorkspaceScanResult, allReviewRules, analyzeSourceFiles, architectureRules, backendRules, buildArchitectureGraph, buildDatabaseFieldUsageReport, buildDatabaseGraph, buildGroundedContextFromProject, buildProviderChatRequest, buildSolutionArtifacts, buildSolutionDiagram, chatWithGrounding, createConfiguredProvider, databaseRules, defaultConfig, detectProjectMetadata, detectRisks, detectSolutionRisks, detectWorkspaceServices, diffGraphSnapshots, exportGenerated, filterDbUsageReport, formatDbUsageCliOutput, formatGroundedContext, frontendRules, generateApiDoc, generateArchitectureDoc, generateCodeReviewReport, generateContainerDiagram, generateContextDiagram, generateDataFlowDiagram, generateDatabaseDoc, generateDbFieldUsageDoc, generateDbFieldUsageSummaryMd, generateDiagrams, generateDiffReport, generateDocs, generateErdDiagram, generateRisksDoc, inferArchitectureSignalsFromDependencies, initializeProject, loadConfig, loadGraphSnapshot, markSensitiveColumns, mergeWorkspaceDbFieldUsage, parseMongooseFiles, parseMongooseSource, parsePrismaFiles, parsePrismaSchema, parseSqlFiles, parseSqlSchema, parseTypeOrmFiles, parseTypeOrmSource, performanceRules, readIgnorePatterns, redisRules, renderCodeReviewMarkdown, renderDiffReport, renderGeneratedDiagram, resolveApiKey, resolveImportToFile, retrieveGroundedEvidence, scanCodeIntegrationSignals, scanEnvironmentSignals, scanFiles, scanInfrastructureSignals, scanProject, scanWorkspace, securityRules, validateArchitectureGraph, validateDatabaseGraph, validateGeneratedOutput, writeCodeReviewJsonReport, writeCodeReviewMarkdownReport, writeCodeReviewOutputs, writeCodeReviewRulesJson, writeDbUsageOutputs, writeWorkspaceDbUsageReport };
