# qawsed123144/mindflow architecture

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

- Interactive diagram: https://gitdiagram.com/qawsed123144/mindflow
- Repository: https://github.com/qawsed123144/mindflow

## Overview

##### Project Type and Purpose
- This is a full-stack web application (“Mindflow”) for visual project planning with mind-maps, collaboration, and progress tracking.
- Frontend: Next.js (App Router) using React + Tailwind + custom UI components.
- Backend: Express.js + Mongoose connecting to MongoDB Atlas.

##### File Structure
- Top-level:
- frontend/ – Next.js application
- backend/  – Express API server
- frontend/app/api – Next.js API routes for mindmaps, signin, signup
- frontend/components & frontend/hooks & frontend/context – UI modules, state hooks, context providers
- frontend/lib – utilities, types, mock data, i18n
- backend/server.js – Express entry point
- backend/package.json – server dependencies (express, mongoose, jwt, etc.)

##### README for Additional Insights
- Explicit call-out of MongoDB Atlas via Mongoose
- Environment variables for PORT, MONGO_URI, JWT_SECRET
- Deployment targets: Vercel (frontend), Render/Railway (backend)

##### Main Components & Their Interactions
a. Next.js Frontend
- Hosts React UI, layouts, pages
- API routes under /api serve as middle-tier or pass-throughs
- Fetches authentication & mindmap data over HTTP
- Uses context providers (auth, language) + custom hooks (use-mindmap, use-toast)
b. Express Backend
- RESTful API endpoints (server.js + Mongoose models)
- Handles user signup/signin, CRUD operations on mindmap collections
- Issues JWT tokens, enforces authorization
c. MongoDB Atlas (via Mongoose)
- Persistent storage of users and mindmap documents
d. External Services
- Vercel – deploy Next.js frontend & API routes
- Render/Railway – host Express API
- MongoDB Atlas – managed database

##### Architectural Patterns & Design Principles
- Clear separation of concerns: frontend (presentation + client-side logic) vs. backend (data + business logic)
- RESTful API with JWT-based authentication
- React Context for global state (auth, language)
- Component-based UI library (reusable primitives in frontend/components/ui)
- Side effects/hooks pattern for data fetching

## Diagram (Mermaid)

```mermaid
flowchart TB
    User["User Browser"]:::ext

    subgraph "Frontend (Presentation Layer)"
        NextJSApp["Next.js Frontend\n(React, Tailwind)"]:::frontend

        subgraph "React Context Providers"
            AuthContext["Auth Context"]:::frontend
            LanguageContext["Language Context"]:::frontend
        end

        subgraph "Custom Hooks"
            MindmapHook["use-mindmap"]:::frontend
            ToastHook["use-toast"]:::frontend
        end

        subgraph "UI Component Library"
            UIComponents["UI Components"]:::frontend
        end

        subgraph "Feature Components"
            AuthForm["Auth Form"]:::frontend
            Dashboard["Dashboard View"]:::frontend
            MindEditor["Mind-Map Editor"]:::frontend
            MindList["Mind-Map List"]:::frontend
            CustomNode["Custom Node"]:::frontend
            ImageModal["Image Upload Modal"]:::frontend
            TaskModal["Task Modal"]:::frontend
        end

        subgraph "Utilities & Types"
            Utils["Utilities & Types"]:::frontend
        end
    end

    subgraph "API Layer (Middle-Tier)"
        MindmapsRoute["GET/POST /api/mindmaps"]:::api
        MindmapsIdRoute["GET/PUT/DELETE /api/mindmaps/:id"]:::api
        SigninRoute["POST /api/signin"]:::api
        SignupRoute["POST /api/signup"]:::api
    end

    ExpressServer["Express Backend\n(Node.js, Mongoose, JWT)"]:::server
    MongoDB["MongoDB Atlas"]:::db

    Vercel["Vercel"]:::ext
    RenderRailway["Render/Railway"]:::ext

    User --> NextJSApp
    NextJSApp --> MindmapsRoute
    NextJSApp --> MindmapsIdRoute
    NextJSApp --> SigninRoute
    NextJSApp --> SignupRoute
    MindmapsRoute --> ExpressServer
    MindmapsIdRoute --> ExpressServer
    SigninRoute --> ExpressServer
    SignupRoute --> ExpressServer
    ExpressServer --> MongoDB
    ExpressServer -.->|"JWT Token"| NextJSApp
    NextJSApp --> Vercel
    ExpressServer --> RenderRailway

    click NextJSApp "https://github.com/qawsed123144/mindflow/tree/main/frontend/"
    click MindmapsRoute "https://github.com/qawsed123144/mindflow/blob/main/frontend/app/api/mindmaps/route.ts"
    click MindmapsIdRoute "https://github.com/qawsed123144/mindflow/blob/main/frontend/app/api/mindmaps/[id]/route.ts"
    click SigninRoute "https://github.com/qawsed123144/mindflow/blob/main/frontend/app/api/signin/route.ts"
    click SignupRoute "https://github.com/qawsed123144/mindflow/blob/main/frontend/app/api/signup/route.ts"
    click AuthContext "https://github.com/qawsed123144/mindflow/blob/main/frontend/context/auth-context.tsx"
    click LanguageContext "https://github.com/qawsed123144/mindflow/blob/main/frontend/context/language-context.tsx"
    click MindmapHook "https://github.com/qawsed123144/mindflow/blob/main/frontend/hooks/use-minmap.ts"
    click ToastHook "https://github.com/qawsed123144/mindflow/blob/main/frontend/hooks/use-toast.ts"
    click UIComponents "https://github.com/qawsed123144/mindflow/tree/main/frontend/components/ui/"
    click AuthForm "https://github.com/qawsed123144/mindflow/blob/main/frontend/components/auth/auth-form.tsx"
    click Dashboard "https://github.com/qawsed123144/mindflow/blob/main/frontend/components/dashboard/dashboard.tsx"
    click MindEditor "https://github.com/qawsed123144/mindflow/blob/main/frontend/components/mind-map/mind-map-editor.tsx"
    click MindList "https://github.com/qawsed123144/mindflow/blob/main/frontend/components/mind-map/mind-map-list.tsx"
    click CustomNode "https://github.com/qawsed123144/mindflow/blob/main/frontend/components/mind-map/custom-node.tsx"
    click ImageModal "https://github.com/qawsed123144/mindflow/blob/main/frontend/components/mind-map/image-upload-modal.tsx"
    click TaskModal "https://github.com/qawsed123144/mindflow/blob/main/frontend/components/mind-map/task-modal.tsx"
    click Utils "https://github.com/qawsed123144/mindflow/tree/main/frontend/lib/"
    click ExpressServer "https://github.com/qawsed123144/mindflow/blob/main/backend/server.js"
    click BackendPkg "https://github.com/qawsed123144/mindflow/blob/main/backend/package.json"

    classDef frontend fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef api fill:#90EE90,stroke:#333,stroke-width:1px
    classDef server fill:#32CD32,stroke:#333,stroke-width:1px
    classDef db fill:#FFA500,stroke:#333,stroke-width:1px
    classDef ext fill:#D3D3D3,stroke:#333,stroke-width:1px
```
