# jubairanjumrony/parcelify architecture

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

- Interactive diagram: https://gitdiagram.com/jubairanjumrony/parcelify
- Repository: https://github.com/jubairanjumrony/parcelify

## Overview

##### Project Type and Purpose
- This is a full-stack MERN (MongoDB, Express.js, React, Node.js) Parcel Management System.
- Purpose: allow users to book parcels, admins to assign them, and delivery personnel to update statuses, with real-time tracking, payments via Stripe, and Firebase-based authentication.

##### File Structure
- Top level separates Client-Side (React) and Server-Side (Node/Express).
- Client-Side/src: React components split into Shared, Layouts, Pages, Providers, Routes, hooks, and Firebase config.
- Server-Side: index.js, package.json – a single Express app likely connecting to MongoDB and exposing REST endpoints.
- Config files: vite.config.js (frontend build), eslint.config.js (linting), .gitignore, .env references in README.

##### README Insights
- Tech stack calls out React Router, Axios, TailwindCSS, React Query, ApexCharts on front end; Express, MongoDB on back end; Firebase Auth; Stripe for payments.
- Features emphasize role-based routing (AdminRoute, PrivateRoute, DeliveryMenRoute), real-time data fetch (React Query), real-time map integration (external service), data visualization (ApexCharts), notifications, and responsive UI.

##### Main Components
a. Frontend (React App)
- Components: Shared UI (Navbar, Footer, Spinner), Pages (Home, Login, SignUp, Dashboard variants), Layouts (Main, Dashboard), Providers (Auth), Routes (Public, Private, Role-based).
- State & Data Layer: React Query for server interaction, Axios clients (public & secure), Firebase SDK for auth.
b. Backend (Express API)
- REST API endpoints for users, parcels, assignments, payments, statistics.
- Middleware: JWT validation or Firebase token verification, role checks.
- Third-party integrations: Stripe webhooks, Firebase Admin (if used).
c. Database
- MongoDB collections: users, parcels, payments, delivery assignments, logs.
d. External Services
- Firebase Authentication service (Auth flow).
- Stripe Payment Gateway (client-side stripe.js & server webhook).
- (Optional) Map provider API for live map integration.

##### Relationships & Data Flows
- User Browser ↔ React UI ↔ React Query/Axios ↔ Express API
- Express API ↔ MongoDB (CRUD)
- React UI ↔ Firebase Auth (login/signup/token)
- React UI ↔ Stripe Elements for checkout ↔ Stripe API
- Express API ↔ Stripe Webhooks (listen for payment events)
- Express API ↔ (Optional) Map API for geocoding/directions

##### Architectural Patterns & Principles
- Separation of concerns: UI vs business logic vs data persistence.
- Role-based routing and access control in both client (Routes) and server (middleware).
- React Query for caching and real-time updates.
- Component-based React architecture: Shared, Layouts, Pages.
- RESTful API design on backend.
- Environment config (.env) for secrets.

- Labels for each component (e.g., “ParcelController”, “AuthProvider”, “useAxiosSecure”).
- Optional: annotate protocols (HTTP/HTTPS, WebSocket if real-time used) and ports.

## Diagram (Mermaid)

```mermaid
flowchart TD
    UserBrowser((User Browser)):::external

    subgraph "Client-Side (React)"
        subgraph "UI Components"
            Navbar["Navbar"]:::frontend
            Footer["Footer"]:::frontend
            Spinner["Loading Spinner"]:::frontend
            SocialLogin["Social Login Buttons"]:::frontend
        end

        subgraph "Layouts"
            MainLayout["Main Layout"]:::frontend
            DashboardLayout["Dashboard Layout"]:::frontend
        end

        subgraph "Pages"
            HomePage["Home Page"]:::frontend
            LoginPage["Login Page"]:::frontend
            SignUpPage["SignUp Page"]:::frontend
            ErrorPage["Global Error Page"]:::frontend

            subgraph "Dashboard - Admin"
                AllUsers["All Users"]:::frontend
                AllParcels["All Parcels"]:::frontend
                AllDeliveryMen["All Delivery Men"]:::frontend
                Statistics["Statistics"]:::frontend
            end

            subgraph "Dashboard - DeliveryMen"
                MyDeliveries["My Deliveries"]:::frontend
                MyReviews["My Reviews"]:::frontend
            end

            subgraph "Dashboard - User"
                BookParcel["Book Parcel"]:::frontend
                MyParcel["My Parcels"]:::frontend
                MyProfile["My Profile"]:::frontend
                UpdateParcel["Update Parcel"]:::frontend

                subgraph "Payment Flow"
                    CheckoutForm["Checkout Form"]:::frontend
                    PaymentPage["Payment Page"]:::frontend
                    PaymentHistory["Payment History"]:::frontend
                end
            end
        end

        subgraph "Routes & Providers"
            AuthProvider["AuthProvider"]:::frontend
            Routes["Routes"]:::frontend
            PrivateRoute["PrivateRoute"]:::frontend
            AdminRoute["AdminRoute"]:::frontend
            DeliveryMenRoute["DeliveryMenRoute"]:::frontend
        end

        subgraph "Data Layer"
            useAxiosPublic["useAxiosPublic"]:::frontend
            useAxiosSecure["useAxiosSecure"]:::frontend
            useUsers["useUsers"]:::frontend
            useParcels["useParcels"]:::frontend
            useMyParcels["useMyParcels"]:::frontend
            useDeliveryMen["useDeliveryMen"]:::frontend
            useAdmin["useAdmin"]:::frontend
            useAuth["useAuth"]:::frontend
        end
    end

    subgraph "Server-Side (Express)"
        ExpressAPI["Express API"]:::backend
        PackageJSON["package.json"]:::backend
    end

    Firebase((Firebase Auth Service)):::cloud
    StripeAPI((Stripe API)):::cloud
    MapAPI((Map Provider API)):::cloud
    StripeWebhooks((Stripe Webhook Endpoint)):::cloud
    MongoDB[(MongoDB)]:::database

    %% Connections
    UserBrowser -->|Interacts with| Navbar
    Navbar -->|Uses| AuthProvider
    AuthProvider -->|Authenticates| Firebase
    BookParcel -->|Mutation via| useAxiosSecure
    useAxiosSecure -->|HTTP Calls| ExpressAPI
    ExpressAPI -->|CRUD Operations| MongoDB
    ExpressAPI -->|Listens to| StripeWebhooks
    ExpressAPI -->|Requests| MapAPI
    PaymentPage -->|Stripe Elements| StripeAPI

    %% Click Events
    click Navbar "https://github.com/jubairanjumrony/parcelify/blob/main/Client-Side/src/Components/Shared/Navbar.jsx"
    click Footer "https://github.com/jubairanjumrony/parcelify/blob/main/Client-Side/src/Components/Shared/Footer.jsx"
    click Spinner "https://github.com/jubairanjumrony/parcelify/blob/main/Client-Side/src/Components/Shared/LoadingSpinner.jsx"
    click SocialLogin "https://github.com/jubairanjumrony/parcelify/blob/main/Client-Side/src/Components/Shared/SocialLogin.jsx"
    click MainLayout "https://github.com/jubairanjumrony/parcelify/blob/main/Client-Side/src/Layouts/MainLayouts.jsx"
    click DashboardLayout "https://github.com/jubairanjumrony/parcelify/blob/main/Client-Side/src/Layouts/Dashboard.jsx"
    click HomePage "https://github.com/jubairanjumrony/parcelify/blob/main/Client-Side/src/Pages/ErrorPage/Home/Home.jsx"
    click LoginPage "https://github.com/jubairanjumrony/parcelify/blob/main/Client-Side/src/Pages/ErrorPage/login/Login.jsx"
    click SignUpPage "https://github.com/jubairanjumrony/parcelify/blob/main/Client-Side/src/Pages/ErrorPage/signUp/SignUp.jsx"
    click ErrorPage "https://github.com/jubairanjumrony/parcelify/blob/main/Client-Side/src/Pages/ErrorPage/ErrorPage.jsx"
    click AllUsers "https://github.com/jubairanjumrony/parcelify/blob/main/Client-Side/src/Pages/ErrorPage/Dashboard/Admin/AllUsers/AllUsers.jsx"
    click AllParcels "https://github.com/jubairanjumrony/parcelify/blob/main/Client-Side/src/Pages/ErrorPage/Dashboard/Admin/AllParcel/AllParcel.jsx"
    click AllDeliveryMen "https://github.com/jubairanjumrony/parcelify/blob/main/Client-Side/src/Pages/ErrorPage/Dashboard/Admin/AllDeliveryMen/AllDeliveryMen.jsx"
    click Statistics "https://github.com/jubairanjumrony/parcelify/blob/main/Client-Side/src/Pages/ErrorPage/Dashboard/Admin/Statistics/Statistics.jsx"
    click MyDeliveries "https://github.com/jubairanjumrony/parcelify/blob/main/Client-Side/src/Pages/ErrorPage/Dashboard/DeliveryMen/MyDeliveries.jsx"
    click MyReviews "https://github.com/jubairanjumrony/parcelify/blob/main/Client-Side/src/Pages/ErrorPage/Dashboard/DeliveryMen/MyReviews.jsx"
    click BookParcel "https://github.com/jubairanjumrony/parcelify/blob/main/Client-Side/src/Pages/ErrorPage/Dashboard/user/BookParcel.jsx"
    click MyParcel "https://github.com/jubairanjumrony/parcelify/blob/main/Client-Side/src/Pages/ErrorPage/Dashboard/user/MyParcel.jsx"
    click MyProfile "https://github.com/jubairanjumrony/parcelify/blob/main/Client-Side/src/Pages/ErrorPage/Dashboard/user/MyProfile.jsx"
    click UpdateParcel "https://github.com/jubairanjumrony/parcelify/blob/main/Client-Side/src/Pages/ErrorPage/Dashboard/user/UpdateParcel.jsx"
    click CheckoutForm "https://github.com/jubairanjumrony/parcelify/blob/main/Client-Side/src/Pages/ErrorPage/Dashboard/user/Payment/CheckoutForm.jsx"
    click PaymentPage "https://github.com/jubairanjumrony/parcelify/blob/main/Client-Side/src/Pages/ErrorPage/Dashboard/user/Payment/Payment.jsx"
    click PaymentHistory "https://github.com/jubairanjumrony/parcelify/blob/main/Client-Side/src/Pages/ErrorPage/Dashboard/user/Payment/PaymentHistory.jsx"
    click Routes "https://github.com/jubairanjumrony/parcelify/blob/main/Client-Side/src/Routes/Routes.jsx"
    click PrivateRoute "https://github.com/jubairanjumrony/parcelify/blob/main/Client-Side/src/Routes/PrivateRoute.jsx"
    click AdminRoute "https://github.com/jubairanjumrony/parcelify/blob/main/Client-Side/src/Routes/AdminRoute.jsx"
    click DeliveryMenRoute "https://github.com/jubairanjumrony/parcelify/blob/main/Client-Side/src/Routes/DeliveryMenRoute.jsx"
    click useAxiosPublic "https://github.com/jubairanjumrony/parcelify/blob/main/Client-Side/src/hooks/useAxiosPublic.jsx"
    click useAxiosSecure "https://github.com/jubairanjumrony/parcelify/blob/main/Client-Side/src/hooks/useAxiosSecure.jsx"
    click useUsers "https://github.com/jubairanjumrony/parcelify/blob/main/Client-Side/src/hooks/useUsers.jsx"
    click useParcels "https://github.com/jubairanjumrony/parcelify/blob/main/Client-Side/src/hooks/useParcels.jsx"
    click useMyParcels "https://github.com/jubairanjumrony/parcelify/blob/main/Client-Side/src/hooks/useMyParcels.jsx"
    click useDeliveryMen "https://github.com/jubairanjumrony/parcelify/blob/main/Client-Side/src/hooks/useDeliveryMen.jsx"
    click useAdmin "https://github.com/jubairanjumrony/parcelify/blob/main/Client-Side/src/hooks/useAdmin.jsx"
    click useAuth "https://github.com/jubairanjumrony/parcelify/blob/main/Client-Side/src/hooks/useAuth.jsx"
    click AuthProvider "https://github.com/jubairanjumrony/parcelify/blob/main/Client-Side/src/Providers/AuthProvider.jsx"
    click Firebase "https://github.com/jubairanjumrony/parcelify/blob/main/Client-Side/src/Firebase/firebase.config.js"
    click ExpressAPI "https://github.com/jubairanjumrony/parcelify/blob/main/Server-Side/index.js"
    click PackageJSON "https://github.com/jubairanjumrony/parcelify/blob/main/Server-Side/package.json"

    %% Styles
    classDef frontend fill:#D0E8FF,stroke:#0366d6
    classDef backend fill:#DFFFE0,stroke:#228B22
    classDef database fill:#FFE0B3,stroke:#DAA520
    classDef cloud fill:#E8E8E8,stroke:#888
    classDef external fill:#F0F0F0,stroke:#999,stroke-dasharray: 5 5
```
