# Abstract Machine - Syntax Checker and Translator ## **Project Description** This web application is a syntax checker and code translator for multiple programming languages (Jane, C, Python, Java). It allows users to: - **Check syntax errors** in their code. - **Get AI-powered suggestions** to fix errors. - **Translate code** between languages (Jane → C, Python, Java). The application is deployed on **Azure** using Docker containers and Nginx as a reverse proxy. --- ## **Technical Implementation** ### **Cloud & Deployment** - **Public Cloud:** Microsoft Azure - **Services Used:** - **Azure App Service** (for hosting the web app). - **Docker** (containerization). - **Nginx** (web server and reverse proxy). ### **Docker Compose** - **Docker Containers:** - `nginx:alpine` (serves the static frontend). - **Volumes:** - Persistent storage for app files (`./app:/usr/share/nginx/html`). - Nginx configuration (`./nginx:/etc/nginx/conf.d`). - **Auto-Restart Policy:** - `restart: unless-stopped` (ensures the app restarts on failure). ### **Application Components** 1. **Frontend:** - HTML/CSS/JavaScript (static files served by Nginx). 2. **Backend:** - Syntax checkers (`janeParser.js`, `cSyntaxChecker.js`, `pythonSyntaxChecker.js`, `javaSyntaxChecker.js`). - AI error helper (`script.js`). - Code translator (`script.js`). ### **HTTPS & Security** - The app is accessible via **HTTPS** (certificate managed by Azure). - Nginx ensures proper routing and security. --- ## **Files & Configuration** ### **Key Files** | File | Description | |----------------------|----------------------------------------------------------------------| | `prepare-app.sh` | Starts the Docker container. | | `remove-app.sh` | Stops and removes the container. | | `Dockerfile` | Builds the Nginx-based Docker image. | | `docker-compose.yml` | Defines the container setup (ports, volumes, restart policy). | | `nginx/nginx.conf` | Configures Nginx routing. | | `app/` | Contains all frontend files (`index.html`, `style.css`, JS scripts). | ### **Scripts** Azure Management Scripts * start-app-service.sh Starts the Azure App Service instance # Authenticates with Azure and sends start request # Requires Azure CLI login and proper permissions * stop-app-service.sh Stops the Azure App Service instance # Authenticates with Azure and sends stop request # Preserves all application data * restart-app-service.sh Restarts the Azure App Service instance # Performs full restart of the Azure service # Useful for applying configuration changes Application Lifecycle Scripts * prepare-app.sh Full application deployment sequence: 1) Starts Docker containers (docker-compose up -d) 2) Triggers Azure App Service startup (start-app-service.sh) 3) Outputs deployment URL > The application has started at https://sk1bk-edgvcnfsfxfsegg2.westeurope-01.azurewebsites.net/ * remove-app.sh Complete application teardown sequence: 1) Stops Azure App Service (stop-app-service.sh) 2) Removes all Docker containers and volumes (docker-compose down -v) Implementation Notes 1) All Azure management scripts: - Require authenticated Azure CLI session - Use the same subscription/resource group context - Include proper API versioning (2022-03-01) - Handle empty request bodies with Content-Length: 0 2) Composite scripts (prepare-app.sh, remove-app.sh): - Combine container and cloud resource management - Maintain execution order dependencies - Provide user feedback via console output 3) Security: - Access tokens are obtained fresh for each execution - No long-term credential storage - Requires Contributor-level permissions on target resources --- ## **How to Use the Application** 1. **Access the Web App:** - Open: [https://sk1bk-edgvcnfsfxfsegg2.westeurope-01.azurewebsites.net/](https://sk1bk-edgvcnfsfxfsegg2.westeurope-01.azurewebsites.net/) 2. **Check Syntax:** - Select a language (Jane, C, Python, Java). - Paste your code into the text area. - Click **"Start analysis"**. 3. **Get AI Help:** - After analysis, click **"AI Help"** for error explanations. 4. **Translate Code:** - If the code is error-free, select a target language and click **"Translate"**. --- ## **Requirements for Running Scripts** - **`prepare-app.sh` and `remove-app.sh` require:** - Docker and Docker Compose installed. - Azure CLI (if redeploying to Azure). - Internet access (to pull Docker images). --- ## **External Sources** - **No third-party APIs** were used (all logic is custom). ---