# rcom363/feed-forward architecture

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

- Interactive diagram: https://gitdiagram.com/rcom363/feed-forward
- Repository: https://github.com/rcom363/feed-forward

## Overview

##### Main Components Identification

The system should be represented with these key components:

a) Frontend Layer:
- React-based SPA with distinct user interfaces for different roles
- Form components and dashboard components
- Authentication context and protected routes
- API integration layer

b) Backend Layer:
- Express.js server with RESTful API endpoints
- Authentication middleware
- Controllers for different functionalities
- Database models and schemas
- Utility services (email, QR code generation, file upload)

c) External Services:
- MongoDB Database
- Cloudinary (for image storage)
- Email Service
- Geolocation Service

**[Client Tier] <-> [Application Tier] <-> [Data Tier]**

##### Component Relationships

a) Frontend to Backend:
- API calls through axios instance
- WebSocket connections for real-time notifications
- Protected route authentication flow

b) Backend to External Services:
- Database operations with MongoDB
- Image upload/retrieval with Cloudinary
- Email notifications
- Geolocation API interactions

##### Detailed Component Breakdown

Frontend Components:
**[User Interface Layer]**
- Public Pages (Home, Login, SignUp)
- Role-Based Dashboards
- Admin Dashboard
- City Admin Dashboard
- Donor Dashboard
- Recipient Dashboard
- Shared Components
- Form Components

Backend Components:
**[API Layer]**
- Authentication
- User Management
- Food Posts
- Food Requests
- Donations
- Admin Operations

**[Service Layer]**
- Email Service
- QR Code Generator
- File Upload Service
- Location Service

##### Data Flow Representation

- User authentication flow
- Food donation workflow
- Notification system
- QR code generation and verification
- Image upload process

##### Additional Elements

Annotations for:
- Security measures
- API endpoints grouping
- Database schema relationships
- Scalability points
- Error handling flow

This system design should effectively communicate both the technical architecture and the business logic of the FeedForward platform.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client["Client Tier"]
        direction TB
        FE[Frontend Application]:::frontend
        click FE "https://github.com/RCOM363/feed-forward/blob/main/frontend/src/App.jsx"
        
        subgraph UI["User Interface Components"]
            direction TB
            PP[Public Pages]:::frontend
            
            subgraph Dashboards["Role-Based Dashboards"]
                direction TB
                AD[Admin Dashboard]:::frontend
                click AD "https://github.com/RCOM363/feed-forward/blob/main/frontend/src/components/dashboardComponents/AdminDashboard.jsx"
                CAD[City Admin Dashboard]:::frontend
                click CAD "https://github.com/RCOM363/feed-forward/blob/main/frontend/src/components/dashboardComponents/CityAdminDashboard.jsx"
                DD[Donor Dashboard]:::frontend
                click DD "https://github.com/RCOM363/feed-forward/blob/main/frontend/src/components/dashboardComponents/DonorDashboard.jsx"
                RD[Recipient Dashboard]:::frontend
                click RD "https://github.com/RCOM363/feed-forward/blob/main/frontend/src/components/dashboardComponents/RecipientDashboard.jsx"
            end
            
            subgraph Forms["Form Components"]
                direction TB
                FW[Form Wrapper]:::frontend
                click FW "https://github.com/RCOM363/feed-forward/blob/main/frontend/src/components/formComponents/FormWrapper.jsx"
                IC[Input Components]:::frontend
                click IC "https://github.com/RCOM363/feed-forward/blob/main/frontend/src/components/formComponents/Input.jsx"
                FI[File Input]:::frontend
                click FI "https://github.com/RCOM363/feed-forward/blob/main/frontend/src/components/formComponents/FileInput.jsx"
                SC[Select Component]:::frontend
                click SC "https://github.com/RCOM363/feed-forward/blob/main/frontend/src/components/formComponents/Select.jsx"
            end
        end
        
        subgraph Auth["Authentication"]
            AC[Auth Context]:::auth
            click AC "https://github.com/RCOM363/feed-forward/blob/main/frontend/src/context/AuthContext.jsx"
            PR[Protected Routes]:::auth
            click PR "https://github.com/RCOM363/feed-forward/blob/main/frontend/src/components/ProtectedRoute.jsx"
        end
        
        subgraph API["API Integration"]
            AX[Axios Instance]:::api
            click AX "https://github.com/RCOM363/feed-forward/blob/main/frontend/src/utils/axiosInstance.js"
            AA[Admin API]:::api
            click AA "https://github.com/RCOM363/feed-forward/blob/main/frontend/src/api/admin.js"
            DA[Donation API]:::api
            click DA "https://github.com/RCOM363/feed-forward/blob/main/frontend/src/api/donation.js"
            FPA[Food Posts API]:::api
            click FPA "https://github.com/RCOM363/feed-forward/blob/main/frontend/src/api/foodPosts.js"
            UA[Users API]:::api
            click UA "https://github.com/RCOM363/feed-forward/blob/main/frontend/src/api/users.js"
        end
    end
    
    subgraph Server["Application Tier"]
        direction TB
        BE[Backend Server]:::backend
        click BE "https://github.com/RCOM363/feed-forward/blob/main/backend/src/app.js"
        
        subgraph Controllers["Controllers"]
            direction TB
            ADC[Admin Controller]:::backend
            click ADC "https://github.com/RCOM363/feed-forward/blob/main/backend/src/controllers/admin.controller.js"
            CADC[City Admin Controller]:::backend
            click CADC "https://github.com/RCOM363/feed-forward/blob/main/backend/src/controllers/cityAdmin.controller.js"
            DC[Donation Controller]:::backend
            click DC "https://github.com/RCOM363/feed-forward/blob/main/backend/src/controllers/donation.controller.js"
            FPC[Food Post Controller]:::backend
            click FPC "https://github.com/RCOM363/feed-forward/blob/main/backend/src/controllers/foodPost.controller.js"
            UC[User Controller]:::backend
            click UC "https://github.com/RCOM363/feed-forward/blob/main/backend/src/controllers/user.controller.js"
        end
        
        subgraph Middleware["Middleware"]
            AM[Auth Middleware]:::auth
            click AM "https://github.com/RCOM363/feed-forward/blob/main/backend/src/middlewares/auth.middleware.js"
        end
        
        subgraph Utils["Utility Services"]
            direction TB
            CS[Cloudinary Service]:::util
            click CS "https://github.com/RCOM363/feed-forward/blob/main/backend/src/utils/cloudinary.js"
            ES[Email Service]:::util
            click ES "https://github.com/RCOM363/feed-forward/blob/main/backend/src/utils/mailer.js"
            QR[QR Code Generator]:::util
            click QR "https://github.com/RCOM363/feed-forward/blob/main/backend/src/utils/generateQRCode.js"
            GEO[Geolocation Service]:::util
            click GEO "https://github.com/RCOM363/feed-forward/blob/main/frontend/src/api/fetchCoordinates.js"
        end
    end
    
    subgraph Data["Data Tier"]
        direction TB
        DB[(MongoDB)]:::database
        
        subgraph Models["Database Models"]
            direction TB
            UM[User Model]:::database
            click UM "https://github.com/RCOM363/feed-forward/blob/main/backend/src/models/user.model.js"
            DM[Donation Model]:::database
            click DM "https://github.com/RCOM363/feed-forward/blob/main/backend/src/models/donation.model.js"
            FPM[Food Post Model]:::database
            click FPM "https://github.com/RCOM363/feed-forward/blob/main/backend/src/models/foodpost.model.js"
            LM[Location Model]:::database
            click LM "https://github.com/RCOM363/feed-forward/blob/main/backend/src/models/location.model.js"
        end
        
        CLD[(Cloudinary)]:::external
    end
    
    %% Connections
    FE --> AC
    AC --> PR
    FE --> API
    API --> BE
    BE --> AM
    AM --> Controllers
    Controllers --> Utils
    Controllers --> Models
    Models --> DB
    Utils --> CLD
    
    %% Styles
    classDef frontend fill:#3498db,stroke:#2980b9,color:white
    classDef backend fill:#2ecc71,stroke:#27ae60,color:white
    classDef auth fill:#9b59b6,stroke:#8e44ad,color:white
    classDef api fill:#e74c3c,stroke:#c0392b,color:white
    classDef database fill:#f1c40f,stroke:#f39c12,color:white
    classDef external fill:#95a5a6,stroke:#7f8c8d,color:white
    classDef util fill:#1abc9c,stroke:#16a085,color:white
```
