# aathisankara/autocomplete architecture

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

- Interactive diagram: https://gitdiagram.com/aathisankara/autocomplete
- Repository: https://github.com/aathisankara/autocomplete

## Overview

##### Project Type & Purpose
- This is a full-stack web application that provides an autocomplete feature powered by a pre-trained LSTM deep-learning model.
- The frontend is built with Next.js (React + TypeScript) and serves a UI for users to input text and receive autocomplete suggestions.
- The backend is a Python service (likely using FastAPI/Uvicorn) that loads PyTorch (.pt) models, performs inference, and exposes HTTP endpoints.

##### Key Elements from the File Structure
A. Top-Level Directories
- frontend/ – Next.js app (TSX pages, components, config).
- backend/ – Python service + raw data, model artifacts, training notebooks.
B. Backend Substructure
- data/encoding/*.json – character-to-integer mappings.
- data/models/*.pt – trained LSTM models.
- python/app/
- app.py – instantiates FastAPI app and routes.
- model.py – loads PyTorch model, wraps inference logic.
- schema.py – Pydantic request/response schemas.
- config.py – settings (paths, hyperparameters).
- python/main.py – entrypoint (Uvicorn).
C. Frontend Substructure
- src/app/… – Next.js “app router” pages (/, /models, /try).
- src/components/… – reusable UI elements (buttons, dropdowns, textarea).
- package.json, next.config.ts, postcss.config.mjs etc.

##### Additional Insights from README
- The README confirms usage of Python models and a Node.js/React frontend.
- Training notebooks and raw data exist but are primarily offline assets.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External User
    User["User Browser"]:::external

    %% Frontend Layer
    subgraph "Frontend Layer"
        direction TB
        FE_Pages["Next.js App Router"]:::frontend
        FE_Components["UI Components"]:::frontend
        FE_UI["Reusable UI Elements"]:::frontend
        subgraph "Config Files"
            direction TB
            NextConf["next.config.ts"]:::frontend
            ESLintConf["eslint.config.mjs"]:::frontend
            PostCSSConf["postcss.config.mjs"]:::frontend
            TSConf["tsconfig.json"]:::frontend
        end
    end

    %% Backend Layer
    subgraph "Backend Layer"
        direction TB
        API_Entrypoint["Uvicorn Entrypoint"]:::backend
        API_App["FastAPI App & Routes"]:::backend
        Schema["Pydantic Schemas"]:::backend
        Config["Backend Config"]:::backend
        Inference["Inference Engine"]:::backend
        Req_TXT["requirements.txt"]:::backend
    end

    %% Data Stores
    subgraph "Data Stores"
        direction TB
        Encodings["Encoding JSON Store"]:::datastore
        Models["Model Artifacts"]:::datastore
    end

    %% Training Tools
    subgraph "Training Tools"
        direction TB
        Notebook["Training Notebook"]:::optional
        Data_Req["Training Requirements"]:::optional
    end

    %% Data Flow
    User -->|"opens UI"| FE_Pages
    FE_Pages -->|"renders using"| FE_Components
    FE_Components -->|"uses"| FE_UI
    FE_Pages -->|"reads config"| NextConf
    FE_Pages -->|"reads config"| ESLintConf
    FE_Pages -->|"reads config"| PostCSSConf
    FE_Pages -->|"reads config"| TSConf

    FE_Pages -->|"HTTP POST JSON"| API_App
    API_Entrypoint -->|"runs"| API_App
    API_App -->|"validates via JSON"| Schema
    API_App -->|"calls inference"| Inference
    Inference -->|"loads encoding"| Encodings
    Inference -->|"loads model"| Models
    Inference -->|"returns predictions"| API_App
    API_App -->|"JSON response"| FE_Pages

    %% Click Events
    click FE_Pages "https://github.com/aathisankara/autocomplete/tree/main/frontend/src/app"
    click FE_Components "https://github.com/aathisankara/autocomplete/tree/main/frontend/src/components"
    click FE_UI "https://github.com/aathisankara/autocomplete/tree/main/frontend/src/components/ui"
    click NextConf "https://github.com/aathisankara/autocomplete/blob/main/frontend/next.config.ts"
    click ESLintConf "https://github.com/aathisankara/autocomplete/blob/main/frontend/eslint.config.mjs"
    click PostCSSConf "https://github.com/aathisankara/autocomplete/blob/main/frontend/postcss.config.mjs"
    click TSConf "https://github.com/aathisankara/autocomplete/blob/main/frontend/tsconfig.json"
    click API_App "https://github.com/aathisankara/autocomplete/blob/main/backend/python/app/app.py"
    click API_Entrypoint "https://github.com/aathisankara/autocomplete/blob/main/backend/python/main.py"
    click Inference "https://github.com/aathisankara/autocomplete/blob/main/backend/python/app/model.py"
    click Schema "https://github.com/aathisankara/autocomplete/blob/main/backend/python/app/schema.py"
    click Config "https://github.com/aathisankara/autocomplete/blob/main/backend/python/app/config.py"
    click Encodings "https://github.com/aathisankara/autocomplete/tree/main/backend/data/encoding"
    click Models "https://github.com/aathisankara/autocomplete/tree/main/backend/data/models"
    click Notebook "https://github.com/aathisankara/autocomplete/blob/main/backend/data/Train.ipynb"
    click Data_Req "https://github.com/aathisankara/autocomplete/blob/main/backend/data/requirements.txt"
    click Req_TXT "https://github.com/aathisankara/autocomplete/blob/main/backend/python/requirements.txt"

    %% Styles
    classDef external fill:#f0f0f0,stroke:#999
    classDef frontend fill:#bbdefb,stroke:#1e88e5
    classDef backend fill:#c8e6c9,stroke:#2e7d32
    classDef datastore fill:#ffe0b2,stroke:#ef6c00
    classDef optional fill:#e0e0e0,stroke:#757575,stroke-dasharray:5 5
```
