# recurse-official/g50 architecture

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

- Interactive diagram: https://gitdiagram.com/recurse-official/g50
- Repository: https://github.com/recurse-official/g50

## Overview

##### Project type and purpose
- This is a full-stack web application called “Advanced Food Redistribution Network.”
- Frontend: React.js app for donors and clients.
- Backend: Node.js/Express API with real-time features via Socket.IO.
- Database: MongoDB for storing users, donations, and claims.
- External service: Google Maps API for geolocation.

##### File structure
- Top level:
- api/ – Express server entrypoint (server.js), real-time socket logic (socket.js), routes (auth.js, food.js), data models (User, FoodItem, Claim).
- client/ – React application (public/ + src/), components for Login, Signup, Home, MainPageClient, MainPageDonor, Navbar.
- Config and scripts:
- api/.env – environment variables (MONGO_URI, API keys, PORT).
- package.json files in root, api/, client/ for npm scripts.

##### README for additional insights
- Users: Donors post food details; Clients view & claim within a radius.
- Real-time status updates via Socket.IO.
- Google Maps API for mapping & distance filtering.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "React Client" 
        direction TB
        RC[/"React Client App"/]:::frontend
        Login["Login Component"]:::frontend
        Signup["Signup Component"]:::frontend
        Home["Home Component"]:::frontend
        MainClient["MainPageClient Component"]:::frontend
        MainDonor["MainPageDonor Component"]:::frontend
        Navbar["Navbar Component"]:::frontend
    end

    %% Backend Layer
    subgraph "Express API Server" 
        direction TB
        Server["server.js (Entrypoint)"]:::backend
        Socket["socket.js (WebSocket Logic)"]:::backend
        Auth["auth.js (Authentication Routes)"]:::backend
        Food["food.js (Donation & Claim Routes)"]:::backend
        Env[".env (Configuration)"]:::backend
        subgraph "Models"
            direction TB
            User["User Model"]:::backend
            FoodItem["FoodItem Model"]:::backend
            Claim["Claim Model"]:::backend
        end
    end

    %% Database
    DB[(MongoDB Database)]:::db

    %% External Service
    Maps(("Google Maps API")):::external

    %% HTTP interactions
    RC -->|"HTTP(S) Requests"| Server
    Server -->|"Queries/Updates"| DB

    %% WebSocket interactions
    RC ---|"WebSocket Events"| Socket
    Socket -->|"Emit/Listen Events"| RC

    %% API internal routing
    Server --> Auth
    Server --> Food
    Server --> Socket
    Auth --> User
    Food --> FoodItem
    Food --> Claim

    %% External calls
    RC -.->|"Maps & Geolocation"| Maps

    %% Click Events
    click RC "https://github.com/recurse-official/g50/tree/main/client/"
    click Server "https://github.com/recurse-official/g50/blob/main/api/server.js"
    click Socket "https://github.com/recurse-official/g50/blob/main/api/socket.js"
    click Auth "https://github.com/recurse-official/g50/blob/main/api/auth.js"
    click Food "https://github.com/recurse-official/g50/blob/main/api/food.js"
    click User "https://github.com/recurse-official/g50/blob/main/api/models/User.js"
    click FoodItem "https://github.com/recurse-official/g50/blob/main/api/models/FoodItem.js"
    click Claim "https://github.com/recurse-official/g50/blob/main/api/models/Claim.js"
    click Env "https://github.com/recurse-official/g50/blob/main/api/.env"
    click Login "https://github.com/recurse-official/g50/blob/main/client/src/components/Login/Login.js"
    click Signup "https://github.com/recurse-official/g50/blob/main/client/src/components/Signup/Signup.js"
    click Home "https://github.com/recurse-official/g50/blob/main/client/src/components/Home/Home.js"
    click MainClient "https://github.com/recurse-official/g50/blob/main/client/src/components/MainPageClient/MainPageClient.js"
    click MainDonor "https://github.com/recurse-official/g50/blob/main/client/src/components/MainPageDonor/MainPageDonor.js"
    click Navbar "https://github.com/recurse-official/g50/blob/main/client/src/components/Navbar/Navbar.js"
    click package "https://github.com/recurse-official/g50/blob/main/package.json"

    %% Styles
    classDef frontend fill:#ADD8E6,stroke:#000,stroke-width:1px
    classDef backend fill:#90EE90,stroke:#000,stroke-width:1px
    classDef db fill:#FFD700,stroke:#000,stroke-width:1px
    classDef external fill:#D3D3D3,stroke:#000,stroke-width:1px
```
