# csci-499-sp23/team-2-sp23 architecture

> Architecture diagram of the GitHub repository csci-499-sp23/team-2-sp23, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/csci-499-sp23/team-2-sp23
- Repository: https://github.com/csci-499-sp23/team-2-sp23

## Overview

##### Project’s Core Components
- Client: The “client” directory contains a React-based frontend. Look for typical React layers such as components, hooks, pages, assets, and a state management structure (Redux or similar via “store”). Firebase files (e.g., firebase.json, .firebaserc) indicate that the client is deployed via Firebase Hosting.
- Server: The “server” directory is a Node.js/TypeScript backend. It includes controllers, models, routes, services, configuration constants, and even a suite of tests. Notably, there is a strong emphasis on API routes (for restaurants, users, preferences) and jobs. There are also specialized integrations such as “yelp-services” that likely deal with scraping or interfacing with Yelp for restaurant data.
- Database: The README mentions a MongoDB connection string configured in the server’s .env file, so consider this as an external component in your architecture.
- External Services: Additionally, the existence of “yelp-services” in the server directory suggests integration with external APIs or web scraping for restaurant data.

##### Relationships and Data Flows
- The frontend (client) communicates with the backend through REST API endpoints (or similar) defined by the controllers and routes in the server directory.
- Server components (controllers, services, models) interact with a MongoDB database to store and retrieve data.
- The server might also have scheduled jobs (in the “jobs” folder) that process or update data automatically (e.g., scraping coordinates or cleaning up old menus).
- External integrations (e.g., Yelp, as seen in the “yelp-services”) interact with the server to provide additional data or functionality.

##### Architectural Patterns
- Client: The use of React with modular components (pages, hooks, assets, store) suggests a component-based UI architecture with clear separation of concerns (UI rendering, API interactions, state management).
- Server: The structure is indicative of an MVC-like pattern:
- Routes define API endpoints.
- Controllers handle business logic.
- Models represent the data structure (food, restaurant, user, etc.).
- Services encapsulate the core business operations (food, menu, restaurant operations).
- Additionally, the presence of a “jobs” folder suggests a background task processing mechanism.
- Testing is emphasized in both client and server parts so consider a testing layer for unit and integration tests.

- On how the API endpoints and controllers in the server facilitate interactions between the client and the data storage.
- Testing aspect (like separate testing modules) if needed, to show the project’s stability and development practices.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Subgraph
    subgraph "Frontend (React/Firebase)"
        F1["UI Components (client/src/components)"]:::frontend
        F2["State Management (client/src/store)"]:::frontend
        F3["API Layer (client/src/api)"]:::frontend
        F4["Firebase Hosting Config (client/firebase.json & .firebaserc)"]:::frontend
    end

    %% Backend Subgraph
    subgraph "Backend (Node.js/TypeScript)"
        B1["Controllers (server/src/controllers)"]:::backend
        B2["API Routes (server/src/routes)"]:::backend
        B3["Models (server/src/models)"]:::backend
        B4["Services (server/src/services)"]:::backend
        B5["Background Jobs (server/src/jobs)"]:::backend
        B6["Yelp Services (server/src/yelp-services)"]:::backend
        B7["Server Testing Suite (server/tests)"]:::backend
    end

    %% External Systems Subgraph
    subgraph "External Systems"
        E1["MongoDB"]:::external
        E2["External API (Yelp)"]:::external
    end

    %% Testing Subgraph
    subgraph "Testing"
        T1["Client Tests (client/src/setupTests.js)"]:::testing
        T2["Server Tests (server/tests)"]:::testing
    end

    %% Connections
    F3 -->|"calls"| B2
    B2 -->|"routes_to"| B1
    B1 -->|"uses"| B4
    B4 -->|"interacts_with"| B3
    B4 -->|"stores_data_in"| E1
    B4 -->|"integrates_with"| E2
    B5 -->|"triggers"| B4
    F3 -->|"API_request"| B2

    %% Click Events
    click F1 "https://github.com/csci-499-sp23/team-2-sp23/tree/main/client/src/components"
    click F2 "https://github.com/csci-499-sp23/team-2-sp23/tree/main/client/src/store"
    click F3 "https://github.com/csci-499-sp23/team-2-sp23/tree/main/client/src/api"
    click F4 "https://github.com/csci-499-sp23/team-2-sp23/blob/main/client/firebase.json"
    click B1 "https://github.com/csci-499-sp23/team-2-sp23/tree/main/server/src/controllers"
    click B2 "https://github.com/csci-499-sp23/team-2-sp23/tree/main/server/src/routes"
    click B3 "https://github.com/csci-499-sp23/team-2-sp23/tree/main/server/src/models"
    click B4 "https://github.com/csci-499-sp23/team-2-sp23/tree/main/server/src/services"
    click B5 "https://github.com/csci-499-sp23/team-2-sp23/tree/main/server/src/jobs"
    click B6 "https://github.com/csci-499-sp23/team-2-sp23/tree/main/server/src/yelp-services"
    click B7 "https://github.com/csci-499-sp23/team-2-sp23/tree/main/server/tests"
    click T1 "https://github.com/csci-499-sp23/team-2-sp23/blob/main/client/src/setupTests.js"
    click T2 "https://github.com/csci-499-sp23/team-2-sp23/tree/main/server/tests"

    %% Styles
    classDef frontend fill:#AED6F1,stroke:#2471A3,stroke-width:2px;
    classDef backend fill:#F5B7B1,stroke:#C0392B,stroke-width:2px;
    classDef external fill:#D5F5E3,stroke:#27AE60,stroke-width:2px;
    classDef testing fill:#FDEBD0,stroke:#D35400,stroke-width:2px;
```
