# 23abhishek2024/foundify architecture

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

- Interactive diagram: https://gitdiagram.com/23abhishek2024/foundify
- Repository: https://github.com/23abhishek2024/foundify

## Overview

##### Project type and purpose
- Foundify is a monolithic full-stack web application for campus lost-and-found management.
- It provides user authentication, item posting, real-time chat, notifications, and admin approval.

##### File structure
- Top-level files:
– app.js: Express server entrypoint
– .env, package.json: config and dependencies
- Directories:
– models/: Mongoose schemas (user, lostItem, foundItem, comment, message)
– routes/: Express route modules (user, items, chat, notification)
– views/: EJS templates (pages and partials)
– public/: Static assets (CSS, client JS, uploads)
– node_modules/: third-party libraries

##### README for additional insights
- Tech stack: Node.js, Express, MongoDB/Mongoose, EJS, Socket.io
- Architectural patterns: MVC (models/routes/views), REST APIs, event-driven WebSocket chat
- Features: CRUD APIs, real-time messaging, notifications

##### Detailed separation of components
- Client/UI:
– Pages: login.ejs, index.ejs, chat.ejs, profile.ejs, reportLost/Found.ejs
– Static JS: public/js/socket.js
– Stylesheet: public/style.css
- Server – Routing layer:
– routes/user.js, items.js, chat.js, notification.js
– Middleware: session/JWT auth, file-upload
- Server – Business logic & data layer:
– models/*.js (User, LostItem, FoundItem, Comment, Message)
– admin approval logic inside items route/controller
- Real-time messaging:
– Socket.io initialization in app.js
– message persistence with Message model
- Data persistence & storage:
– MongoDB collections mapped via Mongoose
– public/uploads for image files

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client/UI Layer
    subgraph "Client/UI Layer"
        direction TB
        Browser["Browser"]:::frontend
        subgraph "Views (EJS Templates)"
            direction TB
            Login["login.ejs"]:::frontend
            Register["register.ejs"]:::frontend
            Profile["profile.ejs"]:::frontend
            UserProfile["userProfile.ejs"]:::frontend
            Index["index.ejs"]:::frontend
            ReportLost["reportLost.ejs"]:::frontend
            ReportFound["reportFound.ejs"]:::frontend
            ChatView["chat.ejs"]:::frontend
            Inbox["inbox.ejs"]:::frontend
            MessagesPartial["messagesPartial.ejs"]:::frontend
            Header["header.ejs"]:::frontend
            Footer["footer.ejs"]:::frontend
        end
        StaticCSS["style.css"]:::frontend
        StaticSocketJS["socket.js"]:::frontend
    end

    %% Backend Layer
    subgraph "Backend Layer"
        direction TB
        Server["Express Server<br/>(app.js)"]:::backend
        subgraph "REST API Layer"
            direction TB
            UserRoutes["routes/user.js"]:::backend
            ItemRoutes["routes/items.js"]:::backend
            ChatRoutes["routes/chat.js"]:::backend
            NotificationRoutes["routes/notification.js"]:::backend
        end
        subgraph "Real-time Layer"
            direction TB
            SocketIO["Socket.io"]:::backend
        end
        subgraph "Business Logic & Data Layer"
            direction TB
            UserModel["models/user.js"]:::backend
            LostItemModel["models/lostItem.js"]:::backend
            FoundItemModel["models/foundItem.js"]:::backend
            CommentModel["models/comment.js"]:::backend
            MessageModel["models/message.js"]:::backend
        end
        Middleware["Auth & File-Upload Middleware"]:::backend
        FileStorage["File Storage<br/>(public/uploads)"]:::datastore
    end

    %% Data Stores
    subgraph "Data Stores"
        direction TB
        MongoDB((MongoDB)):::datastore
    end

    %% Connections
    Browser -->|HTTP Requests| Server
    Browser -->|WebSocket| SocketIO
    StaticCSS --> Browser
    StaticSocketJS --> Browser

    Server -->|uses| Middleware
    Server -->|routes| UserRoutes
    Server -->|routes| ItemRoutes
    Server -->|routes| ChatRoutes
    Server -->|routes| NotificationRoutes

    UserRoutes -->|CRUD| UserModel
    ItemRoutes -->|CRUD| LostItemModel
    ItemRoutes -->|CRUD| FoundItemModel
    NotificationRoutes -->|CRUD| CommentModel
    ChatRoutes -->|persist messages| MessageModel

    UserModel -->|queries| MongoDB
    LostItemModel -->|queries| MongoDB
    FoundItemModel -->|queries| MongoDB
    CommentModel -->|queries| MongoDB
    MessageModel -->|queries| MongoDB

    SocketIO -->|real-time events| MessageModel
    SocketIO -->|real-time events| CommentModel

    Server -->|serves views| Login
    Server -->|serves views| Register
    Server -->|serves views| Profile
    Server -->|serves views| UserProfile
    Server -->|serves views| Index
    Server -->|serves views| ReportLost
    Server -->|serves views| ReportFound
    Server -->|serves views| ChatView
    Server -->|serves views| Inbox
    Server -->|serves partial| Header
    Server -->|serves partial| Footer

    Server -->|file upload save| FileStorage
    FileStorage -->|file reference| LostItemModel
    FileStorage -->|file reference| FoundItemModel

    %% Click Events
    click Server "https://github.com/23abhishek2024/foundify/blob/main/app.js"
    click UserRoutes "https://github.com/23abhishek2024/foundify/blob/main/routes/user.js"
    click ItemRoutes "https://github.com/23abhishek2024/foundify/blob/main/routes/items.js"
    click ChatRoutes "https://github.com/23abhishek2024/foundify/blob/main/routes/chat.js"
    click NotificationRoutes "https://github.com/23abhishek2024/foundify/blob/main/routes/notification.js"
    click UserModel "https://github.com/23abhishek2024/foundify/blob/main/models/user.js"
    click LostItemModel "https://github.com/23abhishek2024/foundify/blob/main/models/lostItem.js"
    click FoundItemModel "https://github.com/23abhishek2024/foundify/blob/main/models/foundItem.js"
    click CommentModel "https://github.com/23abhishek2024/foundify/blob/main/models/comment.js"
    click MessageModel "https://github.com/23abhishek2024/foundify/blob/main/models/message.js"
    click Login "https://github.com/23abhishek2024/foundify/blob/main/views/login.ejs"
    click Register "https://github.com/23abhishek2024/foundify/blob/main/views/register.ejs"
    click Profile "https://github.com/23abhishek2024/foundify/blob/main/views/profile.ejs"
    click UserProfile "https://github.com/23abhishek2024/foundify/blob/main/views/userProfile.ejs"
    click Index "https://github.com/23abhishek2024/foundify/blob/main/views/index.ejs"
    click ReportLost "https://github.com/23abhishek2024/foundify/blob/main/views/reportLost.ejs"
    click ReportFound "https://github.com/23abhishek2024/foundify/blob/main/views/reportFound.ejs"
    click ChatView "https://github.com/23abhishek2024/foundify/blob/main/views/chat.ejs"
    click Inbox "https://github.com/23abhishek2024/foundify/blob/main/views/inbox.ejs"
    click MessagesPartial "https://github.com/23abhishek2024/foundify/blob/main/views/messagesPartial.ejs"
    click Header "https://github.com/23abhishek2024/foundify/blob/main/views/partials/header.ejs"
    click Footer "https://github.com/23abhishek2024/foundify/blob/main/views/partials/footer.ejs"
    click StaticCSS "https://github.com/23abhishek2024/foundify/blob/main/public/style.css"
    click StaticSocketJS "https://github.com/23abhishek2024/foundify/blob/main/public/js/socket.js"
    click FileStorage "https://github.com/23abhishek2024/foundify/tree/main/public/uploads"

    %% Styles
    classDef frontend fill:#E0F7FA,stroke:#0277BD,color:#01579B
    classDef backend fill:#E8F5E9,stroke:#2E7D32,color:#1B5E20
    classDef datastore fill:#FFF3E0,stroke:#EF6C00,color:#E65100
```
