# proyetei/cs-4zp6a-capstone-akanda architecture

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

- Interactive diagram: https://gitdiagram.com/proyetei/cs-4zp6a-capstone-akanda
- Repository: https://github.com/proyetei/cs-4zp6a-capstone-akanda

## Overview

##### Project Type and Purpose
- This project is a multi-component, full-stack capstone application aimed at creating automated code generators that produce tests of increasing sizes. These tests benchmark interactive proof assistants (Lean, Idris, Agda, and Coq) for measuring time and memory complexity.
- The solution involves multiple languages and technologies – Haskell for translators/grammar generation, a Go-based CLI for test orchestration and CI/CD operations (running inside Docker containers as configured by GitHub Actions), a Python Flask backend for data handling, and a web-based (HTML/CSS/JavaScript) frontend for visualization. Deployment is handled using Vercel via a mixture of static and dynamic hosting strategies.

##### File Structure
- Top-Level Directories:
- .github: Contains CI/CD workflows (GitHub Actions) that build, test, and deploy the project.
- cli: Contains Go modules that implement the command-line interface. Key files like generate-list.go, generate-range.go, info.go, and print.go indicate that the CLI is a central entry point for running tests and interfacing with the translators.
- translators: Contains Haskell code (Grammar.hs, PrintAgda.hs, PrintIdris.hs, etc.) that handles the code generation logic for different proof assistants. There are multiple sample outputs in the “good_Output” subdirectory showing examples in Agda, Idris, Lean, and Rocq.
- examples: Includes sample test cases or basic examples for several languages. This is useful for demonstration and initial testing of the generated code.
- visualization: Houses the Flask backend (app.py), data (data.json), and templates (index.html) for presenting performance visualizations on a local web interface.
- Other pertinent files:
- Dockerfile and .vercelignore/vercel.json indicate containerization and deployment specifics.
- run_test.sh and requirements.txt support local testing and setting up dependencies.
- Documentation artifacts like README.md and Software Requirements specifications.pdf provide higher-level project context and requirements.

##### README for Additional Insights
- The README explains the overall project goal (automated code generation for benchmarking purposes), the diverse technology stack, and integration points, including CI/CD pipelines (GitHub Actions), multiple language support (Haskell, Go, Python, JavaScript), and deployment to Vercel.
- It also lists useful external sources, which hints that the architecture leverages best practices for containerization, GitHub Actions, and more.

a. Main Components:
- CLI Component (Go): Acts as the user-facing command-line interface for triggering tests, invoking the code generators, and reporting timing and memory usage.
- Translators Component (Haskell): Processes abstract test definitions and translates them into specific code outputs for each supported proof assistant (Agda, Idris, Lean, and Rocq/Coq).
- Test Examples: A repository of sample test cases found in the examples folder for validation and demonstration.
- CI/CD Pipeline (GitHub Actions): Automates the build, test, and deployment process. It integrates with Docker (via the Dockerfile), and generates JSON outputs containing benchmarking data.
- Frontend UI (HTML/CSS/JavaScript): The interface for end-users to view detailed graphs and analysis of test run performance.
- Deployment (Vercel): Hosts the final system, particularly the frontend and possibly parts of the backend functionality.

b. Relationships and Interactions:
- The CLI triggers the translators to generate tests in different language formats.
- Generated tests are then run – likely inside containers initiated by GitHub Actions – and benchmarks (time/memory) are collected.
- The CI/CD workflow, defined in the .github/workflows directory, orchestrates these processes, builds Docker images, and executes tests.
- Benchmark results are output as JSON, which the backend Flask app reads.
- The Flask app serves this data via web pages for visualization.
- The frontend fetches and displays these visualizations, possibly connected to the static files served from Vercel.
- Data flow: From CLI → Translators → Test Generation → Benchmark Execution → JSON Results → Backend Visualization → Frontend.
- Control flow: CI/CD pipeline executing Docker builds/tests, then triggering deployment when tests pass.

c. Important Architectural Patterns:
- Separation of concerns: Each component (CLI for command handling, translators for code generation, backend for processing, frontend for display) is isolated.
- Modular design: The use of separate directories (cli, translators, visualization) makes it clear that components were built to be loosely coupled.
- CI/CD integration: The GitHub Actions workflows illustrate continuous integration and deployment practices.
- Containerization: Docker ensures that the testing environment stays consistent across builds and deployments.

d. Relevant Technologies, Frameworks, and Libraries:
- Languages: Haskell (translators), Go (CLI), Python (Flask backend), HTML/CSS/JavaScript (frontend).
- Deployment Platforms: Vercel (for frontend hosting), Docker (for containerization).
- CI/CD tools: GitHub Actions.
- Supporting tools: Dockerfile for container configuration, run_test.sh for local testing, configuration files such as requirements.txt and .vercelignore.

##### Instructing the Principal Software Engineer
- "CLI (Go)" for the command-line interface.
- "Translators (Haskell)" to show code generation logic.
- "Examples Repository" for demonstration outputs.
- "CI/CD Pipeline (GitHub Actions)" with subcomponents like Docker build/test.
- "Benchmark Runner" (implicit within the CI/CD flow or separate as needed).
- "Backend Visualization (Flask)" and "Frontend UI (HTML/CSS/JS)" for displaying test results.
- "Deployment (Vercel)" to indicate where the system is ultimately hosted.
- Data flow (e.g., output from translators feeding into test execution).
- Triggering/interaction (e.g., CLI submitting commands that initiate translator actions).
- Details of key external integrations like Docker within the CI/CD component.
- Provide notes or legends next to every component describing what technology or framework it uses and the role it plays.

## Diagram (Mermaid)

```mermaid
graph TD
    A["CLI (Go)"]:::cli
    B["Translators (Haskell)"]:::translators
    C["Test Examples"]:::examples
    D["CI/CD Pipeline (GitHubActions&Docker)"]:::cicd
    E["Backend Visualization (Flask)"]:::backend
    F["Frontend UI (HTML/CSS/JS)"]:::frontend
    G["Deployment (Vercel)"]:::deployment

    A -->|"triggers"| B
    B -->|"produces"| C
    C -->|"executes"| D
    D -->|"outputsJSON"| E
    E -->|"renders"| F
    F -->|"hosts"| G

    click A "https://github.com/proyetei/cs-4zp6a-capstone-akanda/tree/main/cli/"
    click B "https://github.com/proyetei/cs-4zp6a-capstone-akanda/tree/main/translators/"
    click C "https://github.com/proyetei/cs-4zp6a-capstone-akanda/tree/main/examples/"
    click D "https://github.com/proyetei/cs-4zp6a-capstone-akanda/tree/main/.github/workflows/"
    click E "https://github.com/proyetei/cs-4zp6a-capstone-akanda/blob/main/visualization/app.py"
    click F "https://github.com/proyetei/cs-4zp6a-capstone-akanda/tree/main/visualization/templates/"
    click G "https://github.com/proyetei/cs-4zp6a-capstone-akanda/blob/main/vercel.json"

    classDef cli fill:#AED6F1,stroke:#1F618D,color:#000;
    classDef translators fill:#ABEBC6,stroke:#27AE60,color:#000;
    classDef examples fill:#F9E79F,stroke:#F1C40F,color:#000;
    classDef cicd fill:#F5B7B1,stroke:#C0392B,color:#000;
    classDef backend fill:#D7BDE2,stroke:#8E44AD,color:#000;
    classDef frontend fill:#FAD7A0,stroke:#D35400,color:#000;
    classDef deployment fill:#D2B4DE,stroke:#6C3483,color:#000;
```
