# jakujobi/ada_web_analyzer architecture

> Architecture diagram of the GitHub repository jakujobi/ada_web_analyzer, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/jakujobi/ada_web_analyzer
- Repository: https://github.com/jakujobi/ada_web_analyzer

## Overview

##### Project Type and Purpose
- The project is a web-based tool designed specifically for lexical analysis, parsing, and generating a visual representation (parse tree visualization) for a subset of the Ada programming language.
- The README mentions these main features, and the file structure confirms that it’s built as a web application (using Django) combined with custom lexical and parsing functionality.

##### Key Components
a. Web Server / Django Infrastructure:
– The directory “ada_web_analyzer” contains Django’s configuration files (settings.py, asgi.py, wsgi.py, urls.py). This is the backbone of the web framework.
– Manage.py, requirements.txt, runtime.txt, and Procfile are used for running and deploying the Django app (likely on a platform like Heroku).

b. Django Application (Analysis App):
– The “analysis” directory is a Django “app” containing views (analysis/views.py), URL configurations (analysis/urls.py), templates (analysis/templates/analysis/upload_code.html), static files (CSS/JS for frontend behavior), and tests.
– The app also includes models and migrations, indicating that there is some data persistence or ORM usage for tracking analysis results, configuration, or user-related data.

c. Domain-Specific Modules:
– The “Modules” directory contains all core backend logic related to Ada code processing:
▪ LexicalAnalyzer.py – Performs lexical analysis (tokenization).
▪ RDParser.py – Dedicated to parsing the code (possibly using recursive descent methods).
▪ Definitions.py, FileHandler.py, Logger.py, and Token.py support utility functions, logging, file management, and token definitions.
– This separation shows a clear design principle: the core analysis logic is decoupled from the web-handling code.

d. Static Assets & Frontend:
– Static files in “staticfiles” and the analysis app’s “static” and “templates” directories provide the visual and interactive components (including CSS style files and JS scripts for visualizing parse trees on the client side).
– The design should highlight the separation of concerns between backend logic and UI/UX presentation.

##### Diagramming the Relationships
1. Request Handling: The Django URL routing (configured in ada_web_analyzer/urls.py and analysis/urls.py) directs requests (for example, uploading Ada code) to the appropriate view in analysis/views.py.
2. Business Logic Execution: Once the view is invoked, it calls the corresponding functions in the Modules directory (e.g., LexicalAnalyzer.py, RDParser.py) to perform the analysis.
3. Data Management: (If applicable) Any data resulting from the analysis, for example stored results or user submissions, is persisted or managed by Django models in analysis/models.py.
4. Response Rendering: After processing, the view renders a response using templates (e.g., analysis/templates/analysis/upload_code.html) enhanced by static CSS/JS files from the static directories.
– User → Web Server (HTTP request)
– Web Server → URL Router → View Controller
– View Controller → Domain Modules (for lexical analysis, parsing)
– Domain Modules → View Controller (returning processed data)
– View Controller → Template Renderer (final HTML/JS/CSS output)
– Web Server → User (HTTP response)

##### Highlighting Architectural Patterns & Design Principles
– Presentation Layer: Represented by the static assets and Django templates responsible for user interaction.
– Business Logic Layer: Represented by Django view controllers in the “analysis” app which coordinate request processing.
– Domain/Processing Layer: The “Modules” directory dedicated to Ada code analysis (lexing, parsing, visualization logic).
- MVC Pattern: Although Django follows an MTV variant (Model-Template-View), it still demonstrates the separation between routing (controller), business logic, and presentation.
– Rectangles for components (e.g., “Web Server (Django)”, “Analysis App”, “Modules for Ada Analysis”)

##### Detailed Elements
– Incoming User requests flow into the Django server, then to URL routing.
– From URL routing to Django views, then calls to Modules for processing.
– Data flow returning from the Modules to Django views, and then out to the rendered templates.
- Adding annotations or notes on:
– The use of third-party dependencies as defined in requirements.txt (which might include Django and any supporting libraries).
– Deployment configurations (Procfile, runtime.txt) as an optional side note to show the production environment flow.

## Diagram (Mermaid)

```mermaid
flowchart TD
    U("User Browser"):::external

    subgraph "Web Server Layer"
        DSS("Django Infrastructure"):::server
        UR("URL Routing"):::server
    end

    subgraph "Application Layer"
        DA("Analysis App (Django Views)"):::app
    end

    subgraph "Domain Processing"
        DM("Ada Analysis Modules"):::modules
    end

    subgraph "Presentation Layer"
        TS("Templates & Static Assets"):::presentation
    end

    U -->|"HTTP_Request"| DSS
    DSS -->|"Routes"| UR
    UR -->|"Directs_to_View"| DA
    DA -->|"Calls_Analysis"| DM
    DM -->|"Returns_Output"| DA
    DA -->|"Renders_Response"| TS
    TS -->|"HTTP_Response"| U

    click DSS "https://github.com/jakujobi/ada_web_analyzer/tree/main/ada_web_analyzer/"
    click DSS "https://github.com/jakujobi/ada_web_analyzer/blob/main/manage.py"
    click DA "https://github.com/jakujobi/ada_web_analyzer/tree/main/analysis/"
    click DM "https://github.com/jakujobi/ada_web_analyzer/tree/main/Modules/"
    click TS "https://github.com/jakujobi/ada_web_analyzer/tree/main/analysis/static/analysis/"
    click TS "https://github.com/jakujobi/ada_web_analyzer/tree/main/staticfiles/"

    classDef external fill:#B3E5FC,stroke:#0288D1,stroke-width:2px;
    classDef server fill:#FFF9C4,stroke:#FBC02D,stroke-width:2px;
    classDef app fill:#C8E6C9,stroke:#388E3C,stroke-width:2px;
    classDef modules fill:#FFECB3,stroke:#FFA000,stroke-width:2px;
    classDef presentation fill:#FFCDD2,stroke:#C62828,stroke-width:2px;
```
