# julianapeace/flora architecture

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

- Interactive diagram: https://gitdiagram.com/julianapeace/flora
- Repository: https://github.com/julianapeace/flora

## Overview

##### Main Components
- Frontend Applications:
- “askflora.earth”: This directory contains a Next.js application (with files like layout.tsx, page.tsx, next.config.ts, Tailwind configuration, etc.) that represents one web interface for interacting with Flora.
- “client”: A separate client-side application built using React with Vite (notice the App.tsx, main.tsx, router.tsx, and components under client/src) that likely serves another interface—perhaps a specialized chat or dashboard.

- Backend and Core Logic (located in “src”):
- The src folder includes modules for core functionality such as chat logic (src/chat), API clients (src/clients), configuration (src/config), and database interactions (src/database). This indicates a backend layer that processes incoming requests, integrates with the knowledge base, and maintains system state.

- Knowledge and Character Data:
- “characters” holds JSON files defining various “characters” (e.g., flora, eliza, etc.) and even contains an Excel document with a Veg Spec Database.
- “knowledge” includes multiple markdown documents (and even a PDF) serving as a knowledge base that the AI may reference when generating insights.

- Custom Actions:
- The “custom_actions” folder showing custom script (myAction.ts) which likely extends Flora’s behavior or integrates with external systems.

- Supporting Files and Configurations:
- Top-level configuration files (such as .env.example, Dockerfile, pnpm workspace files) indicate deployment and development infrastructure.
- Additional resources like ESLint, PostCSS, Tailwind configs spread across the client and askflora.earth indicate styling/quality enforcement practices.

##### Relationships and Interactions
- Web Interfaces (askflora.earth and client) will serve as entry points. They can communicate with the backend services either via RESTful APIs or through server-side rendering (in Next.js).
- The backend (src directory) mediates interactions:
- Chat modules handle the AI-conversation aspects.
- Database modules possibly persist user data or session logs.
- Client integrations and configuration modules keep the system flexible.
- The knowledge base (knowledge and characters) supplies reference data that the AI uses to provide contextually relevant responses.
- Custom actions may serve as triggers for specific behaviors or integrations (for example, specialized commands or IoT actions).

##### Architectural Patterns and Technologies
- The backend is built using a modular approach, with clear boundaries (chat, clients, database, config) aligning with either a layered architecture or even micro-modules if scaled.
- Usage of Tailwind CSS, TypeScript (e.g., .ts and .tsx files), and containerization hints at modern web and cloud-native practices.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Applications
    subgraph "Frontend Applications"
        A("askflora.earth (Next.js, Tailwind CSS)"):::frontend
        B("client (React, Vite)"):::frontend
    end

    %% Backend Services
    subgraph "Backend Services"
        C("Chat Modules"):::backend
        D("API Clients"):::backend
        E("Configuration"):::backend
        F("Database Interactions"):::database
    end

    %% Knowledge Base & Character Data
    subgraph "Knowledge Base & Character Data"
        G("Characters Data"):::knowledge
        H("Knowledge Documents"):::knowledge
    end

    %% Custom Actions
    I("Custom Actions"):::actions

    %% Deployment & Configuration Resources
    subgraph "Deployment & Configuration"
        J("Dockerfile"):::deployment
        K(".env.example"):::deployment
        L("Build Scripts (pnpm, etc.)"):::deployment
    end

    %% Connections from Frontend Applications to Backend Services
    A -->|"HTTP_API_call"| C
    A -->|"HTTP_API_call"| D
    B -->|"HTTP_API_call"| C
    B -->|"HTTP_API_call"| D

    %% Connections within Backend Services
    C -->|"Data_query"| E
    E -->|"Persist/Data"| F

    %% Backend consulting Knowledge Base
    C -.->|"Data_query"| G
    C -.->|"Data_query"| H

    %% Custom Action Trigger from Backend
    C -->|"Custom_Action_trigger"| I

    %% Deployment interactions (configuration/deployment support)
    K -->|"LoadConfig"| E
    L -->|"Build/Deploy"| A
    L -->|"Build/Deploy"| B

    %% Styles
    classDef frontend fill:#AEDFF7,stroke:#333,stroke-width:2px,rx:5,ry:5;
    classDef backend fill:#F9DCA8,stroke:#333,stroke-width:2px;
    classDef database fill:#FDCEDF,stroke:#333,stroke-width:2px;
    classDef knowledge fill:#C8E6C9,stroke:#333,stroke-width:2px;
    classDef actions fill:#FFF59D,stroke:#333,stroke-width:2px;
    classDef deployment fill:#E1BEE7,stroke:#333,stroke-width:2px;

    %% Click Events
    click A "https://github.com/julianapeace/flora/blob/master/askflora.earth"
    click B "https://github.com/julianapeace/flora/tree/master/client"
    click C "https://github.com/julianapeace/flora/tree/master/src/chat"
    click D "https://github.com/julianapeace/flora/tree/master/src/clients"
    click E "https://github.com/julianapeace/flora/tree/master/src/config"
    click F "https://github.com/julianapeace/flora/tree/master/src/database"
    click G "https://github.com/julianapeace/flora/tree/master/characters"
    click H "https://github.com/julianapeace/flora/tree/master/knowledge"
    click I "https://github.com/julianapeace/flora/tree/master/custom_actions"
```
