# neurprojects/neur-app architecture

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

- Interactive diagram: https://gitdiagram.com/neurprojects/neur-app
- Repository: https://github.com/neurprojects/neur-app

## Overview

##### Main Components

a. Frontend:
- Represented primarily by the "src/app" directory (with subdirectories for various user interfaces such as chat, home, account, etc.).
- UI components are contained in "src/components" – these include reusable widgets, dashboards, message components, and UI elements built with Tailwind CSS.
- State management hooks and utilities under "src/hooks" and "src/lib/utils".

b. Backend/API:
- API routes and server actions can be seen in "src/app/api" and "src/server". These files manage HTTP endpoints, real-time communication, and the orchestration of blockchain operations.
- Business logic for actions (like "action.ts", "ai.ts", "telegram.ts") in the "/src/server/actions" folder are crucial pieces to model.

c. Database Layer:
- The "prisma" directory is responsible for database migrations and schema definitions (schema.prisma). Also, helper methods for database access exist in "src/lib/prisma" and "src/server/db".

d. External Integrations:
- Several blockchain integrations (Solana features) are implemented under "src/ai/solana" and “src/lib/solana” as well as providers like Jupiter, Magic Eden, Dexscreener, pump.fun, etc.
- External services (DeFi protocols, NFT suites, wallet operations) should be depicted as separate but connected blocks that interact with the backend.

e. Development & Deployment Infrastructure:
- Configuration and deployment files such as Dockerfile.local, docker-compose.yml, vercel.json, and CI/CD GitHub configuration directives (in .github) indicate containerized/local development and validation pipelines.
- A separate section for deployment and environment configuration components.

##### Relationships and Interactions

- From the client (Frontend UI) to the API endpoints (src/app/api) when users interact with the application (chat messages, wallet operations, etc.).
- From these endpoints to the server actions (src/server/actions) where request processing and orchestration occur.
- From server actions to the database (through Prisma) for operations like chat persistence or user model updates.
- From server actions to external blockchain services (through solana integrations) for executing on-chain transactions, querying market data, or updating wallet portfolios.

- Asynchronous or scheduled operations (e.g., the cron jobs under "/src/app/api/cron") that manage recurring tasks like subscriptions or minute-based operations.

##### Architectural Patterns/Design Principles

- Full-Stack Separation: Clearly delineate the frontend (React/Next.js-based pages and components) from the backend API (server actions and endpoints).
- Modularized Architecture: Note the division of logic between UI components, hook-based state management, API layers, and server-side business logic.
- Integration Layer: A dedicated layer for blockchain interactions—illustrate connectors for each external integration (i.e., Solana's DeFi, NFTs, and wallet management).
- Database Abstraction: Use of Prisma migrations and ORM indicates an abstraction layer for interacting with the underlying database.
- CI/CD & Local Development: Mark the configuration aspects (e.g., Docker, .env.example) as part of the infrastructure facilitating consistent environments.

##### Detail Level

- Don’t hesitate to include smaller modules (specialized components in “src/ai”, “src/lib/solana”, or even hooks) if they play an important role in integrations or UI behavior.
- Where helpful, note underlying technologies (TypeScript, Tailwind CSS, Next.js, Prisma) alongside the respective components.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Users
    User["User (Browser)"]:::user

    %% Frontend Layer
    subgraph "Frontend Layer"
        F1["Next.js pages & routing"]:::frontend
        F2["Reusable UI components"]:::frontend
        F3["State management hooks"]:::frontend
        F4["Utilities"]:::frontend
    end

    %% Backend & API Layer
    subgraph "Backend & API Layer"
        B1["API Endpoints"]:::backend
        B2["Server Actions"]:::backend
        B3["Cron Jobs"]:::backend
    end

    %% Database Layer
    subgraph "Database Layer"
        D1["Prisma Database"]:::database
        D2["DB Helpers (Prisma)"]:::database
        D3["DB Helpers (Server)"]:::database
    end

    %% External Integrations
    subgraph "External Integrations"
        E1["Solana Integration"]:::external
        E2["Solana Library"]:::external
        E3["Generic AI Integration"]:::external
        E4["Provider Integration"]:::external
    end

    %% Development & Deployment Infrastructure
    subgraph "Infrastructure"
        I1["Dockerfile"]:::infrastructure
        I2["Docker Compose"]:::infrastructure
        I3["GitHub Actions"]:::infrastructure
        I4["Deployment Config"]:::infrastructure
    end

    %% Data flows
    User -->|"triggers"| F1
    F1 -->|"calls"| B1
    F2 --- F1
    F3 --- F1
    F4 --- F1

    B1 -->|"invokes"| B2
    B2 -->|"runs scheduled tasks"| B3
    B2 -->|"reads/writes"| D1
    B2 -->|"uses"| D2
    B2 -->|"uses"| D3
    B2 -->|"integrates with"| E1
    B2 -->|"integrates with"| E2
    B2 -->|"integrates with"| E3
    B2 -->|"integrates with"| E4

    %% Infrastructure supports overall deployment (not direct data flow)
    I1 --- I2
    I1 --- I3
    I1 --- I4

    %% Click Events
    click F1 "https://github.com/neurprojects/neur-app/tree/main/src/app"
    click F2 "https://github.com/neurprojects/neur-app/tree/main/src/components"
    click F3 "https://github.com/neurprojects/neur-app/tree/main/src/hooks"
    click F4 "https://github.com/neurprojects/neur-app/tree/main/src/lib/utils"
    click B1 "https://github.com/neurprojects/neur-app/tree/main/src/app/api"
    click B2 "https://github.com/neurprojects/neur-app/tree/main/src/server"
    click D1 "https://github.com/neurprojects/neur-app/tree/main/prisma"
    click D1 "https://github.com/neurprojects/neur-app/blob/main/prisma/schema.prisma"
    click D2 "https://github.com/neurprojects/neur-app/tree/main/src/lib/prisma"
    click D3 "https://github.com/neurprojects/neur-app/tree/main/src/server/db"
    click E1 "https://github.com/neurprojects/neur-app/tree/main/src/ai/solana"
    click E2 "https://github.com/neurprojects/neur-app/tree/main/src/lib/solana"
    click E3 "https://github.com/neurprojects/neur-app/tree/main/src/ai/generic"
    click E4 "https://github.com/neurprojects/neur-app/blob/main/src/ai/providers.tsx"
    click I1 "https://github.com/neurprojects/neur-app/blob/main/Dockerfile.local"
    click I2 "https://github.com/neurprojects/neur-app/blob/main/docker-compose.yml"
    click I3 "https://github.com/neurprojects/neur-app/blob/main/.github"
    click I4 "https://github.com/neurprojects/neur-app/blob/main/vercel.json"

    %% Styles
    classDef frontend fill:#cce5ff,stroke:#004085,stroke-width:2px;
    classDef backend fill:#d4edda,stroke:#155724,stroke-width:2px;
    classDef database fill:#e2e3e5,stroke:#6c757d,stroke-width:2px;
    classDef external fill:#fff3cd,stroke:#856404,stroke-width:2px;
    classDef infrastructure fill:#f8d7da,stroke:#721c24,stroke-width:2px;
    classDef user fill:#d1ecf1,stroke:#0c5460,stroke-width:2px;
```
