# atharvaj1425/aissms-pune-hack architecture

> Architecture diagram of the GitHub repository atharvaj1425/aissms-pune-hack, 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/atharvaj1425/aissms-pune-hack
- Repository: https://github.com/atharvaj1425/aissms-pune-hack

## Overview

##### Project type and purpose
- This is a full‑stack web application called “Surplus Food Redistribution Platform.”
- It connects surplus‑food donors (restaurants, caterers, bakeries) with recipients (NGOs, shelters, volunteers), using AI for predictions and a chat‑bot, plus real‑time routing and SMS notifications.

##### File structure
- Top‑level directories:
- Backend: Node.js/Express API with MVC structure (controllers, models, routes, middlewares, utils).
- Frontend: React.js application built with Vite/Webpack, component folders organized by user role (Consumer, NGO, Restaurant, Volunteer, Recipe, Chat‑bot).
- flask: Python/Flask microservice hosting AI/ML models (.pkl) for predictive analytics.
- docker-compose.yml & individual Dockerfiles: container orchestration for backend, frontend, MongoDB.
- config files: package.json, .env, azure-pipelines.yaml for CI/CD.

##### Extract architecture insights from README
- Frontend→Backend communication via REST endpoints under /api/v1.
- Backend uses MongoDB as primary datastore.
- Integration with external services:
- Google Maps API for geolocation and route optimization.
- Twilio for SMS notifications.
- Cloudinary for image/file uploads.
- Flask service provides predictive‑analytics endpoints consumed by the backend.
- Containerization via Docker Compose.

##### Main components
a. User Roles (actors): Donor App (Restaurant/Caterer UI), Recipient App (NGO/Volunteer UI), Administrator.
b. Frontend: React.js SPA served from Frontend container.
c. Backend: Express.js API server (handles auth, business logic, routes).
d. AI Microservice: Flask app exposing prediction/chatbot endpoints.
e. Datastore: MongoDB instance (with potential Redis cache for real‑time leaderboard or OTP storage, implied by volunteerRedistribute.model).
f. External Services: Google Maps API, Twilio SMS API, Cloudinary (media storage).
g. DevOps: Docker Compose orchestration, Azure Pipelines for CI/CD.

##### Component relationships and data flows
- Frontend → Backend (REST calls).
- Backend → MongoDB (driver calls).
- Backend → Flask microservice (HTTP or RPC).
- Backend → External APIs (Google Maps, Twilio, Cloudinary).
- Backend scheduling real‑time notifications to users.

##### Architectural patterns and design principles
- MVC pattern in the backend (controllers, models, routes).
- Component‑based and page‑based architecture in React.
- Microservice for AI/ML separation (Flask).
- Containerization for environment consistency and scaling.
- Role‑based access control via middleware.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Actors
    Donor["Donor / Restaurant UI"]:::user
    Recipient["Recipient / NGO / Volunteer UI"]:::user
    Admin["Administrator UI"]:::user

    %% Container boundaries
    subgraph "Docker Compose Environment"
        direction TB
        ReactClient["React.js SPA\n(Frontend Container)"]:::frontend
        ExpressAPI["Express API Server\n(Backend Container)"]:::backend
        FlaskService["Flask AI Service\n(ML Container)"]:::ai
        MongoDB["MongoDB\n(Dataset)"]:::db
        RedisCache["Redis Cache\n(OTP & Real-time)"]:::db
    end

    %% External Services
    subgraph "External Services"
        direction TB
        GoogleMapsAPI["Google Maps API"]:::external
        TwilioSMS["Twilio SMS API"]:::external
        Cloudinary["Cloudinary Media Storage"]:::external
    end

    %% DevOps
    AzureCI["Azure Pipelines"]:::ci
    DockerComposeFile["Docker Compose"]:::ci

    %% Data flows
    Donor -->|HTTP/HTTPS| ReactClient
    Recipient -->|HTTP/HTTPS| ReactClient
    Admin -->|HTTP/HTTPS| ReactClient

    ReactClient -->|REST /api/v1| ExpressAPI
    ExpressAPI -->|MongoDB Driver| MongoDB
    ExpressAPI -->|Redis Client| RedisCache
    ExpressAPI -->|HTTP /predict| FlaskService

    ExpressAPI -->|HTTP| GoogleMapsAPI
    ExpressAPI -->|HTTPS| TwilioSMS
    ExpressAPI -->|HTTPS| Cloudinary

    DockerComposeFile -->|orchestrates| ReactClient
    DockerComposeFile -->|orchestrates| ExpressAPI
    DockerComposeFile -->|orchestrates| FlaskService
    DockerComposeFile -->|orchestrates| MongoDB
    DockerComposeFile -->|orchestrates| RedisCache

    AzureCI -->|CI/CD| DockerComposeFile

    %% Click Events
    click ReactClient "https://github.com/atharvaj1425/aissms-pune-hack/tree/main/Frontend/src"
    click ExpressAPI "https://github.com/atharvaj1425/aissms-pune-hack/blob/main/Backend/src/index.js"
    click FlaskService "https://github.com/atharvaj1425/aissms-pune-hack/blob/main/flask/app.py"
    click MongoDB "https://github.com/atharvaj1425/aissms-pune-hack/blob/main/Backend/src/db/db.js"
    click RedisCache "https://github.com/atharvaj1425/aissms-pune-hack/blob/main/Backend/src/models/volunteerRedistribute.model.js"
    click DockerComposeFile "https://github.com/atharvaj1425/aissms-pune-hack/blob/main/docker-compose.yml"
    click AzureCI "https://github.com/atharvaj1425/aissms-pune-hack/blob/main/azure-pipelines.yaml"

    %% Styles
    classDef user fill:#D0E8FF,stroke:#0366D6,color:#0366D6
    classDef frontend fill:#E3F2FD,stroke:#1E88E5,color:#1E88E5
    classDef backend fill:#E8F5E9,stroke:#43A047,color:#2E7D32
    classDef ai fill:#E8F5E9,stroke:#43A047,color:#2E7D32
    classDef db fill:#FFF3E0,stroke:#FB8C00,color:#E65100
    classDef external fill:#F5F5F5,stroke:#9E9E9E,color:#616161
    classDef ci fill:#F3E5F5,stroke:#8E24AA,color:#6A1B9A
```
