Architecture Overview¶
This document provides an overview of the internal architecture of Code Context Analyzer.
๐งฑ High-Level Components¶
The project is composed of several modular layers:
User CLI (cca)
โ
Source Resolver (local path or GitHub URL)
โ
File Discovery (discover_files)
โ
Language Parsers (Python, JS)
โ
Formatter (structured summary)
โ
CLI Output (terminal or clipboard)
๐ Directory Structure¶
code_context_analyzer/
โโโ /
โ โโโ main.py
โ โโโ __init__.py
โโโ analyzer/
โ โโโ clipboard.py
โ โโโ discovery.py
โ โโโ __init__.py
โโโ analyzer\parsers/
โ โโโ base.py
โ โโโ js_parser.py
โ โโโ python_parser.py
โ โโโ __init__.py
โโโ cli/
โ โโโ __init__.py
โโโ dto/
โ โโโ models.py
โ โโโ __init__.py
โโโ formatters/
โ โโโ base.py
โ โโโ default.py
โ โโโ factory.py
โ โโโ html_formatter.py
โ โโโ json_formatter.py
โ โโโ yaml_formatter.py
โ โโโ __init__.py
โโโ repo_system/
โ โโโ handler.py
โ โโโ session.py
โ โโโ __init__.py
โโโ utils/
โโโ dto_converter.py
โโโ temp_dir.py
โโโ __init__.py
๐ Process Flow¶
- User invokes CLI
The user runs:
cca <source> --ignore <some, ingore, patterns>
-
RepositoryHandler resolves the source
-
If local path: it validates the directory
-
If GitHub URL: it clones the repo to a temp dir
-
walks through the directory
-
Yields paths and their inferred language
-
Filters based on extension, test files, max files
-
Parsers process each file
-
Python parser uses
ast
to find classes, functions, constants -
JS parser uses regex to extract functions/classes
-
Formatter builds structured output
-
Outputs hierarchy based on folder/module structure
-
Optional truncation
-
Output sent to terminal or clipboard
-
If
--no-clipboard
is passed, summary is copied automatically
๐ Extensibility¶
To add support for a new language:
- Create a new parser in
parsers/
(e.g.go_parser.py
) - Implement the
ParserProtocol
- Register the parser in registry
Example:
from .go_parser import GoParser
registry = {
"python": PythonParser(),
"js": JSParser(),
"go": GoParser(), # new
}
๐งช Testing and Maintenance¶
- All modules are designed to be testable independently
- Temp directories are safely handled via context manager
- CLI arguments can be tested via unit or integration tests
For detailed module documentation, see Module Reference.