# bobtrolledu/git_hackathon architecture

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

- Interactive diagram: https://gitdiagram.com/bobtrolledu/git_hackathon
- Repository: https://github.com/bobtrolledu/git_hackathon

## Overview

##### Project Overview and Purpose
- The project is a full-stack web application designed to support newcomers, immigrants, and refugees by providing critical information about relocation. It integrates expert insights, neighborhood recommendations, and geospatial data to help inform resettlement decisions.
- The frontend is built in React (using Next.js), whereas the backend is implemented in Django and exposes a REST API. It also leverages external services like Mapbox for geospatial visualization and an LLM (likely via the provided openAI_API.py) to process a large 400k+ datapoint geographical dataset.

##### Main Components
a. Frontend (React/Next.js):
– Located in the welcomehomefront directory.
– Consists of UI components (e.g., AnimatedList, MapComponent, various UI widgets) and hooks, along with static assets (e.g., geoJSON files used by Mapbox).
– Manages the interactive user experience including displaying maps, location cards, and toggling UI modes.
b. Backend (Django):
– Found under the GIT_Hackathon directory with the main project folder and the Welcome_Home Django app.
– Hosts the REST API endpoints that facilitate data exchange with the frontend.
– Contains business logic spread across views, models, and serializers.
– Handles data ingestion through scripts (uploadcsv.py, grabImage.py) and LLM integration (openAI_API.py).
– Maintains administrative tasks (migrations, settings, URLs etc.).
c. Database:
– An AWS RDS-hosted PostgreSQL instance is used to store essential data.
– Data might be imported from CSV and Excel files found in the Welcome_Home/dataCSVFiles directory.
d. External Services:
– LLM Service: The backend uses an LLM (as hinted by openAI_API.py) to process and query large amounts of data efficiently.
– AWS RDS: Database hosting service for PostgreSQL.

##### Relationships and Interactions
- The React frontend communicates with the Django backend through REST API calls.
- The Django backend serves data from the PostgreSQL database and processes resources through its business logic.
- Data processing and enrichment (using the LLM) occur server-side before returning customized insights to the frontend.
- The frontend’s use of Mapbox ensures that user actions on the map (like zoom, pan, or selecting a neighborhood) trigger API calls to fetch or update related data.

##### Architectural Patterns and Design Principles
– Separation of concerns: Clearly divided responsibilities between the presentation layer (React frontend) and business/data logic (Django backend).
– RESTful design: API endpoints in the backend that facilitate communication across components.
– Modular design: The separation of different functionalities into designated directories (e.g., the ‘Welcome_Home’ Django app, separate data ingestion scripts, and comprehensive UI components) supports scalability and maintainability.
– External integration: Use of third-party APIs (Mapbox) and cloud services (AWS RDS) enhances the system’s functionality by offloading specialized tasks.

##### Specific Elements
– Clear labels: Each major component (Frontend, Backend, Database, External Services/LLM, CSV/Excel Data Ingestion) should be clearly marked.
- From the frontend to the backend (API calls).
- From the backend to the database (queries, data storage).
- From the backend to external services (Mapbox API calls or LLM processing).
– Integration points: Show where the CSV/Excel data files feed into the backend (via data ingestion scripts) and how that data ends up in the PostgreSQL database.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Frontend Layer"
        F["React/Next.js Frontend"]:::frontend
        UI["UI Components"]:::frontend
        MC["MapComponent (Mapbox Integration)"]:::frontend
        GD["GeoJSON Data"]:::frontend
        F --> UI
        F --> MC
        MC ---|"loads"| GD
    end

    %% Backend Layer
    subgraph "Backend Layer"
        BE["Django REST API"]:::backend
        BL["Business Logic (Views, Models, Serializers)"]:::backend
        LLM["LLM Integration Module"]:::backend
        DI["Data Ingestion Scripts"]:::backend
        BE --> BL
        BE --> LLM
        BE --> DI

        %% Data Ingestion Subgraph within Backend
        subgraph "Data Ingestion"
            DS["CSV/Excel Files"]:::ingestion
            UP["uploadcsv.py"]:::ingestion
            GI["grabImage.py"]:::ingestion
            DS --> UP
            DS --> GI
        end
    end

    %% External Services and Database
    MB["Mapbox API"]:::external
    DB["PostgreSQL Database (AWS RDS)"]:::database

    %% Connections between layers and services
    F -->|"HTTP/REST"| BE
    BE -->|"SQL"| DB
    BE -->|"APIcall"| MB
    DS -->|"DataImport"| DB
    BE -->|"LLMProcess"| LLM
    LLM -->|"Response"| BE

    %% Click Events for Component Mapping
    click F "https://github.com/bobtrolledu/git_hackathon/tree/main/welcomehomefront"
    click MC "https://github.com/bobtrolledu/git_hackathon/blob/main/welcomehomefront/src/app/MapComponent.tsx"
    click GD "https://github.com/bobtrolledu/git_hackathon/blob/main/welcomehomefront/public/torontoNeighbourhood-brafx6.geojson"
    click BE "https://github.com/bobtrolledu/git_hackathon/tree/main/GIT_Hackathon/GIT_Hackathon"
    click BL "https://github.com/bobtrolledu/git_hackathon/tree/main/GIT_Hackathon/Welcome_Home"
    click DS "https://github.com/bobtrolledu/git_hackathon/tree/main/GIT_Hackathon/Welcome_Home/dataCSVFiles"
    click UP "https://github.com/bobtrolledu/git_hackathon/blob/main/GIT_Hackathon/uploadcsv.py"
    click GI "https://github.com/bobtrolledu/git_hackathon/blob/main/GIT_Hackathon/grabImage.py"
    click LLM "https://github.com/bobtrolledu/git_hackathon/blob/main/GIT_Hackathon/Welcome_Home/openAI_API.py"

    %% Styles
    classDef frontend fill:#bbdefb,stroke:#0d47a1,stroke-width:2px;
    classDef backend fill:#c8e6c9,stroke:#1b5e20,stroke-width:2px;
    classDef ingestion fill:#e1bee7,stroke:#6a1b9a,stroke-width:2px;
    classDef database fill:#fff9c4,stroke:#f9a825,stroke-width:2px;
    classDef external fill:#ffcdd2,stroke:#b71c1c,stroke-width:2px;
```
