# hack4impact-uiuc/life-after-hate architecture

> Architecture diagram of the GitHub repository hack4impact-uiuc/life-after-hate, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-17). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/hack4impact-uiuc/life-after-hate
- Repository: https://github.com/hack4impact-uiuc/life-after-hate

## Overview

##### Main Components
- Frontend – Represented by the “frontend” directory, implemented in React with Redux state management. Key aspects include pages, components (such as modals, maps, and navigation), and testing (Cypress). Note that the frontend has its own Dockerfile.
- Backend – Represented by the “backend” directory, which contains an Express application that defines various API endpoints (e.g., for authentication, user, resource, etc.). Backend models (using Mongoose) and utilities (like authentication middleware, error handling, and resource parsing) should be highlighted.
- Database – The backend is configured to connect to a MongoDB instance (as seen in the .env file with the DB_URI).
- External Services – Include Google OAuth for authentication, Mapbox/MapQuest APIs for map rendering and geocoding, and possibly other third-party integrations.
- Containerization & DevOps – Docker and Docker Compose are used for development/testing and deployment. Also include CI/CD pipelines (GitHub Actions workflows and Codecov).

##### Relationships and Interactions
- Backend interacting with the Database (MongoDB) via Mongoose models.
- Connections from the Backend to external services (Google OAuth for user login and Mapbox/MapQuest for geospatial data).
- Optionally, include the testing infrastructure (Cypress scripts for the frontend and Mocha tests on the backend) to showcase how quality assurance is integrated.
- If desired, note the Docker orchestration as a surrounding layer that encapsulates the entire stack (frontend, backend, and database).

##### Architectural Patterns and Design Principles
- MVC Style / Layered Architecture – Highlight how the models, routes, controllers, and middleware within the backend follow an organized, layered pattern. On the frontend, show how components and Redux state management are structured.
- Microservice Considerations – Although this isn’t a microservice architecture per se, use containers (Docker) to indicate that each major component is decoupled and can be scaled separately.
- Security / Authentication – Emphasize the Passport-based authentication mechanism using Google OAuth along with authorization middleware.

##### Technologies, Frameworks, and Libraries
- Frontend: React, Redux, CSS/SCSS modules, DeckGL and MapboxGL for maps.
- Backend: Express, Mongoose (MongoDB), Passport for auth, Joi for validation, Fuse.js for fuzzy search, and Ramda for utilities.
- DevOps: Docker (with separate Dockerfiles for frontend and backend), Docker Compose, GitHub Actions for CI, and Codecov for code coverage.

##### Elements
- Use clear, descriptive labels for each component—for example, “Frontend (React/Redux)”, “Backend API (Express)”, “Database (MongoDB)”, “Auth Service (Google OAuth)”, “Map Services (Mapbox/MapQuest)”, and “DevOps (Docker Compose & CI/CD)”.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Frontend Layer"
        F1("Frontend (React/Redux)"):::frontend
        F2("React Application (src)"):::frontend
        F3("Cypress Testing"):::test
        F4("Map Components"):::frontend
    end

    %% Backend Layer
    subgraph "Backend Layer"
        B1("Backend API (Express/Mongoose)"):::backend
        B2("API Routes (routes/)"):::backend
        B3("Mongoose Models (models/)"):::backend
        B4("Utilities & Middleware"):::backend
        B5("Backend Tests (test/)"):::test
    end

    %% Database
    D("Database (MongoDB)"):::db

    %% External Services
    subgraph "External Services"
        E1("Google OAuth"):::external
        E2("Map Services (Mapbox/MapQuest)"):::external
    end

    %% DevOps & Containerization
    subgraph "DevOps & Containerization"
        D2("Frontend Dockerfile"):::devops
        D3("Frontend Dockerfile.prod"):::devops
        D4("Backend Dockerfile"):::devops
        D5("Docker Compose Setup"):::devops
        CI("CI/CD Pipelines"):::devops
    end

    %% Connections within Frontend
    F1 -->|"contains"| F2
    F1 -->|"runs"| F3
    F1 -->|"renders"| F4

    %% Frontend to Backend
    F1 -->|"API_requests"| B1

    %% Backend internal structure
    B1 -->|"defines"| B2
    B1 -->|"uses"| B3
    B1 -->|"employs"| B4
    B1 -->|"tests"| B5

    %% Backend to Database and External Services
    B1 -->|"Uses_DB"| D
    B1 -->|"Integrates"| E1
    B1 -->|"Integrates"| E2

    %% Map Components integration with Map Services
    F4 -->|"Utilizes"| E2

    %% DevOps associations (dashed connections)
    D2 --- F1
    D3 --- F1
    D4 --- B1
    D5 --- F1
    D5 --- B1
    D5 --- D
    CI --- D5

    %% Click Events for Frontend
    click F1 "https://github.com/hack4impact-uiuc/life-after-hate/tree/master/frontend/"
    click F2 "https://github.com/hack4impact-uiuc/life-after-hate/tree/master/frontend/src"
    click F3 "https://github.com/hack4impact-uiuc/life-after-hate/tree/master/frontend/cypress"
    click F4 "https://github.com/hack4impact-uiuc/life-after-hate/tree/master/frontend/src/pages/MapView/Map"

    %% Click Events for Backend
    click B1 "https://github.com/hack4impact-uiuc/life-after-hate/blob/master/backend/app.js"
    click B2 "https://github.com/hack4impact-uiuc/life-after-hate/tree/master/backend/routes/"
    click B3 "https://github.com/hack4impact-uiuc/life-after-hate/tree/master/backend/models/"
    click B4 "https://github.com/hack4impact-uiuc/life-after-hate/blob/master/backend/utils/passport-setup.js"
    click B5 "https://github.com/hack4impact-uiuc/life-after-hate/tree/master/backend/test/"

    %% Click Events for DevOps & Containerization
    click D2 "https://github.com/hack4impact-uiuc/life-after-hate/tree/master/frontend/Dockerfile"
    click D3 "https://github.com/hack4impact-uiuc/life-after-hate/blob/master/frontend/Dockerfile.prod"
    click D4 "https://github.com/hack4impact-uiuc/life-after-hate/tree/master/backend/Dockerfile"
    click D5 "https://github.com/hack4impact-uiuc/life-after-hate/blob/master/docker-compose.yml"
    click CI "https://github.com/hack4impact-uiuc/life-after-hate/tree/master/.github/workflows/"

    %% Click Event for External Services (Google OAuth)
    click E1 "https://github.com/hack4impact-uiuc/life-after-hate/blob/master/backend/utils/passport-setup.js"

    %% Styles
    classDef frontend fill:#add8e6,stroke:#000,stroke-width:2px;
    classDef backend fill:#90ee90,stroke:#000,stroke-width:2px;
    classDef db fill:#f4a460,stroke:#000,stroke-width:2px;
    classDef external fill:#dda0dd,stroke:#000,stroke-width:2px;
    classDef devops fill:#ffcccb,stroke:#000,stroke-width:2px;
    classDef test fill:#ffffcc,stroke:#000,stroke-width:2px;
```
