# anthozb3x/planifyai architecture

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

- Interactive diagram: https://gitdiagram.com/anthozb3x/planifyai
- Repository: https://github.com/anthozb3x/planifyai

## Overview

##### Project type and purpose
- This is a full-stack, monorepo JavaScript/TypeScript application called PlanifyAI.
- Purpose: provide a modern calendar UI plus an AI-driven conversational interface for creating, editing, deleting, and listing events in natural language.

##### File structure
- Top-level
- agent.ts, index.ts: backend entry points and orchestration
- package.json, tsconfig.json: root configuration
- frontend directory
- package.json, vite.config.ts: React + Vite app
- src/: UI code (components, context, assets)
- public/: static assets (index.html, favicon, etc.)
- No explicit database folder—events likely held in memory or in an external store (could be added later)
- Configuration files (.env, .gitignore, ESLint, tsconfigs) suggest standard Node/React setup

##### README insights
- Frontend: React, TypeScript, Material-UI, Vite
- Backend: Node.js, Express, LangChain, Langraphs, OpenAI GPT-4
- Two services run in dev:
- Frontend on port 5173
- Backend on port 3000

##### Main components & relationships
a. Components
1. Frontend UI
– React + Vite
– Calendar view (Calendar.tsx)
– Chat view (Chat.tsx)
– Shared state via CalendarContext
2. Backend API
– Express server (index.ts)
– Agent module (agent.ts) orchestrating LangChain workflows
3. External AI Service
– OpenAI GPT-4 endpoint (via LangChain + Langraphs)
4. (Optional) Persistence layer
b. Data flows / interactions
- UI → HTTP REST or WebSocket → Express API
- Express → LangChain agent → OpenAI GPT-4 (requests & responses)
- Express → persistence (CRUD events) → Express → UI
c. Architectural patterns & principles
- Separation of concerns: UI vs. API vs. external AI
- Context/Provider pattern in frontend for shared state
- Pipeline pattern in backend (LangChain chains)
d. Key technologies to annotate
- React, TypeScript, Vite, MUI
- Node.js, Express, LangChain, Langraphs
- OpenAI GPT-4 (external service)
- Ports: 5173 (frontend), 3000 (backend)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Frontend Layer
    subgraph "Client-side (React, Vite)" 
        direction TB
        FE_Main["main.tsx"]:::frontend
        FE_App["App.tsx"]:::frontend
        FE_Navbar["Navbar.tsx"]:::frontend
        FE_Calendar["Calendar.tsx"]:::frontend
        FE_Chat["Chat.tsx"]:::frontend
        FE_Context["CalendarContext.tsx"]:::frontend
        FE_Vite["vite.config.ts"]:::frontend
        FE_Main -->|"imports"| FE_App
        FE_App -->|"renders"| FE_Navbar
        FE_App -->|"renders"| FE_Calendar
        FE_App -->|"renders"| FE_Chat
        FE_Calendar -->|"uses context"| FE_Context
        FE_Chat -->|"uses context"| FE_Context
    end

    %% Backend Layer
    subgraph "Server-side (Node.js, Express)" 
        direction TB
        BE_Router["Express Router\n(index.ts)"]:::backend
        BE_Agent["Agent Module\n(agent.ts)"]:::backend
        BE_LangChain["LangChain Graph"]:::backend
        BE_DB["Event Store\n(Database)"]:::backend
        BE_Router -->|"calls workflows"| BE_Agent
        BE_Agent -->|"executes chains"| BE_LangChain
        BE_LangChain -->|"requests/receives"| AI_OpenAI
        BE_Router -->|"CRUD events"| BE_DB
        BE_DB -->|"returns data"| BE_Router
    end

    %% External AI Service
    AI_OpenAI["OpenAI GPT-4"]:::ai

    %% Client-Server Communication
    FE_Calendar -->|"HTTP REST"| BE_Router
    FE_Chat -->|"HTTP REST"| BE_Router

    %% Root Config
    ROOT_PKG["package.json\n(tsconfig.json)"]:::config

    %% Click Events
    click FE_Main "https://github.com/anthozb3x/planifyai/blob/master/frontend/src/main.tsx"
    click FE_App "https://github.com/anthozb3x/planifyai/blob/master/frontend/src/App.tsx"
    click FE_Navbar "https://github.com/anthozb3x/planifyai/blob/master/frontend/src/components/Navbar.tsx"
    click FE_Calendar "https://github.com/anthozb3x/planifyai/blob/master/frontend/src/components/Calendar.tsx"
    click FE_Chat "https://github.com/anthozb3x/planifyai/blob/master/frontend/src/components/Chat.tsx"
    click FE_Context "https://github.com/anthozb3x/planifyai/blob/master/frontend/src/context/CalendarContext.tsx"
    click FE_Vite "https://github.com/anthozb3x/planifyai/blob/master/frontend/vite.config.ts"
    click BE_Router "https://github.com/anthozb3x/planifyai/blob/master/index.ts"
    click BE_Agent "https://github.com/anthozb3x/planifyai/blob/master/agent.ts"
    click ROOT_PKG "https://github.com/anthozb3x/planifyai/blob/master/package.json"
    click ROOT_PKG "https://github.com/anthozb3x/planifyai/blob/master/tsconfig.json"

    %% Styles
    classDef frontend fill:#ADD8E6,stroke:#000,stroke-width:1px
    classDef backend fill:#90EE90,stroke:#000,stroke-width:1px
    classDef ai fill:#D8BFD8,stroke:#000,stroke-width:1px
    classDef config fill:#FFE4B5,stroke:#000,stroke-width:1px
```
