Skip to content

Feat/integrate portal (WIP) #1507

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 23 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
80f6d97
feat: integrate portal directly into main repository to simplify deve…
thomageanderson Jan 25, 2025
ac0c710
docs: improve installation guides and fix portal structure
thomageanderson Jan 25, 2025
27e6eea
docs: clarify portal database initialization and seeding steps in ins…
thomageanderson Jan 26, 2025
afae8a6
docs: standardize installation guides and add architecture overview
thomageanderson Jan 26, 2025
eae1395
docs: add critical URL configurations to env.example
thomageanderson Jan 26, 2025
46cde6d
Remove submodule references and commands
thomageanderson Jan 26, 2025
c804317
docs: simplify README.md to defer to OS-specific installation guides
thomageanderson Jan 29, 2025
8608cc2
docs: add Clerk authentication setup to installation guides
thomageanderson Jan 29, 2025
2460dc6
docs: update installation guides to specify Python 3.11 and remove re…
thomageanderson Jan 29, 2025
b3f8f59
docs: remove pipx installation as it's no longer needed
thomageanderson Jan 29, 2025
2657bbe
docs: reorder installation steps to ensure proper service startup seq…
thomageanderson Jan 29, 2025
1817fcc
docs: add M1/M2 Mac platform compatibility note for Docker containers
thomageanderson Jan 29, 2025
6bec9fe
Add cross platform compatibility regex to handling of behave-graph pa…
thomageanderson Feb 8, 2025
ea4d111
docs: add nvm-windows installation instructions to Windows guide
thomageanderson Feb 8, 2025
2be0fc9
docs: add NX workspace reset troubleshooting for Windows
thomageanderson Feb 8, 2025
8ff9267
docs: add node-gyp Visual C++ requirements for Windows
thomageanderson Feb 8, 2025
5c52c7c
Preserve incoming spell ids on create, temp fix for complex spell imp…
thomageanderson Feb 13, 2025
05aa5fc
Improve complex self-referential uuid updates during import agent
thomageanderson Feb 28, 2025
99acdba
Update common-setup script with cross-env prefix
thomageanderson Mar 17, 2025
835fc24
Update docs to correct required services scripts
thomageanderson Mar 17, 2025
7e67584
Update env.example with better defauls, consolidate access to environ…
thomageanderson Mar 17, 2025
4138d39
Feature flag user service attempt in coreLLMSerivce
thomageanderson Mar 17, 2025
8d75e70
Disable user service in .env and .env.example
thomageanderson Mar 18, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
11 changes: 7 additions & 4 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ PLUGINS_DIRECTORY
# ╚═╝╚═════╝ ╚══════╝ ╚═════╝╚══════╝╚═╝╚══════╝╚═╝ ╚═══╝ ╚═╝

# The URL of the app portal
VITE_APP_PORTAL_URL
NEXT_PUBLIC_APP_URL=http://localhost:3000

# The root url of the IDE server
SERVER_ROOT_URL
Expand Down Expand Up @@ -182,12 +182,15 @@ PORTAL_SHADOW_DATABASE_URL
NEXT_PUBLIC_APP_URL

# URL of the IDE API
NEXT_PUBLIC_API_URL
NEXT_PUBLIC_API_URL=http://localhost:3030

# The root url of the IDE server
IDE_SERVER_UR
IDE_SERVER_URL=http://localhost:3030

APP_URL
APP_URL=http://localhost:3000

# URL for the API server
API_URL=http://localhost:3030

# Stripe stuff
NEXT_PUBLIC_STRIPE_PUB_KEY
Expand Down
3 changes: 0 additions & 3 deletions .gitmodules

This file was deleted.

78 changes: 8 additions & 70 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,76 +90,15 @@ Triggers tell nodes to start asynchronous tasks. Some nodes can process data wit

# ⚙️ Installation

## 📚 [Documentation / Guide](https://magick-docs.vercel.app/)
Please follow the installation guide for your operating system:

### Prerequisites
- [macOS Installation Guide](docs/installation/macos.md)
- [Linux Installation Guide](docs/installation/linux.md)
- [Windows Installation Guide](docs/installation/windows.md)

Before you start, ensure you have the following software installed on your machine:

- **git**: Version control system, required for cloning the repository.
- [Download git](https://git-scm.com/downloads)
- **node.js 18+**: JavaScript runtime, needed for running the application.
- [Download Node.js](https://nodejs.org/en/download/)
- **Docker**: Enables you to run the project within containers for easier setup and distribution.
- [Download Docker Desktop](https://www.docker.com/products/docker-desktop)

Follow the respective installation guides to set up each piece of software.

- Install **pipx**: A tool for installing and running Python applications in isolated environments.

On Unix and macOS: Open a terminal and run the following command:

```bash
python3 -m pip install --user pipx
python3 -m pipx ensurepath
```

On Windows: Open a command prompt and execute:

```bash
py -m pip install --user pipx
py -m pipx ensurepath
```

Install Poetry (Manages python packages)

```bash
pipx install poetry
```

Verify Installation

```bash
pipx --version
```

Once installed, proceed to set up Magick.

## Setup

Clone and set up Magick

```bash
git clone https://github.com/Oneirocom/Magick
cd Magick
npm install
poetry install --no-root
npm run dev
```

## Run Magick!

```bash
npm run dev
```

Note: Installation is automatic. Most Node projects require `npm install` - With Magick, dependencies will automatically be installed for you. Linux users may need to enter sudo password to install some dependencies.

#### Build

Build will take some time initially. When everything is ready, the client will be ready at [localhost:4200](http://localhost:4200/home)

_Please be aware Magick is under heavy development which may cause breaking changes._
For detailed development documentation and architecture overview, see:
- [Development Guide](docs/development/README.md)
- [Architecture Overview](docs/architecture/README.md)

## Database

Expand All @@ -182,8 +121,7 @@ The following documents should help you with setup:

Magick uses [Feathers 5](https://feathersjs.com/) for backend, which in turn uses [Knex](https://knexjs.org/) for making database queries. We will offer a better database configuration experience in the future. For now, you will need to manually configure the database connection in the [`.env` file](.env) and then run the migration script.

```
cd apps/server
```cd apps/server
npm run migrate
```

Expand Down
84 changes: 84 additions & 0 deletions docs/architecture.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# Service Architecture

## Service Hierarchy

### 1. Infrastructure Services (Required)

- **PostgreSQL Databases**
- Main DB (`localhost:5432`)
- Shadow DB (`localhost:5433`)
- Purpose: Stores spells, agents, and application data
- **Redis** (`localhost:6379`)
- Purpose: Caching and pub/sub for real-time updates
- **S3Mock** (`localhost:9000`)
- Purpose: File storage for assets and templates

### 2. Core Backend Services

- **IDE/Agent Server** (`http://localhost:3030`)
- Primary backend service
- Handles agent execution, spell management
- Provides API endpoints for agent operations
- Dependencies: PostgreSQL, Redis

### 3. Frontend Services

- **Portal** (`http://localhost:3000`)
- Main user interface
- Template gallery and management
- Project management
- Dependencies: IDE Server, Authentication

## URL Structure

### Development Environment

```
Portal Frontend: http://localhost:3000
IDE/Agent Server: http://localhost:3030
PostgreSQL Main: localhost:5432
PostgreSQL Shadow: localhost:5433
Redis: localhost:6379
S3Mock: localhost:9000
```

### Production Environment

```
Portal Frontend: https://app.magickml.com
IDE/Agent Server: https://api.magickml.com
```

## Service Dependencies

```mermaid
graph TD
A[Portal Frontend] --> B[IDE/Agent Server]
B --> C[PostgreSQL Main]
B --> D[PostgreSQL Shadow]
B --> E[Redis]
B --> F[S3Mock]
A --> G[Clerk Auth]
```

## Startup Sequence

1. Infrastructure Services: `npm run portal:up`
- Starts PostgreSQL, Redis, and S3Mock containers
2. Database Initialization:
- `npm run db:init` (Main database)
- `npm run portal:db:init` (Portal database + templates)
3. Backend Server: `npm run dev:server`
4. Frontend Portal: `npm run portal:dev`

## Environment Configuration

The system uses several URL configurations that must be consistent:

- `NEXT_PUBLIC_APP_URL`: Portal frontend URL
- `NEXT_PUBLIC_API_URL`: IDE/Agent server URL
- `IDE_SERVER_URL`: IDE server's self-reference
- `APP_URL`: Internal portal URL
- `API_URL`: Internal API URL

For local development, these all use the localhost URLs shown above. In production, they use the corresponding production URLs.
177 changes: 177 additions & 0 deletions docs/architecture/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
# Architecture Overview

## System Components

### 1. Frontend (Client)

- React-based web application
- Visual node-based programming interface
- Real-time collaboration features
- State management and data flow
- Plugin system integration

### 2. Backend (Server)

- Feathers.js framework
- RESTful API endpoints
- WebSocket support
- Authentication and authorization
- Database interactions
- Plugin management

### 3. Database

- PostgreSQL with pgvector extension
- Stores:
- User data
- Project configurations
- Spell definitions
- Agent states
- Plugin data

### 4. Plugin System

- Modular architecture
- Hot-reloadable plugins
- Standardized interfaces
- Custom node types
- Service integrations

## Data Flow

```mermaid
graph TD
A[Client] -->|HTTP/WebSocket| B[Server]
B -->|Query/Update| C[Database]
B -->|Load/Execute| D[Plugins]
D -->|Results| B
B -->|Response| A
```

## Key Concepts

### Spells

- Visual programming workflows
- Composed of nodes and connections
- JSON-serializable format
- Executable logic units

### Nodes

- Atomic processing units
- Input/output sockets
- Type system
- Custom implementations

### Agents

- Autonomous entities
- State management
- Event handling
- Multi-modal interactions

## Security Architecture

### Authentication

- JWT-based auth
- Role-based access control
- API key management
- Session handling

### Data Protection

- Input validation
- SQL injection prevention
- XSS protection
- CORS configuration

## Scalability Considerations

### Horizontal Scaling

- Stateless server design
- Load balancer ready
- Database connection pooling
- Caching strategies

### Performance

- Optimized database queries
- Efficient WebSocket usage
- Resource monitoring
- Memory management

## Development Architecture

### Local Development

- Hot reloading
- Development database
- Debug tooling
- Testing framework

### Deployment

- Docker containers
- Environment configuration
- Database migrations
- Health monitoring

## Integration Points

### External Services

- OAuth providers
- Cloud services
- AI/ML services
- Webhook handlers

### API Architecture

- RESTful endpoints
- WebSocket events
- GraphQL (planned)
- Plugin APIs

## Future Considerations

### Planned Improvements

- Enhanced caching
- Distributed processing
- Real-time collaboration
- Advanced monitoring

### Architectural Goals

- Maintainability
- Extensibility
- Performance
- Security

## Technical Specifications

### Technology Stack

- TypeScript/JavaScript
- React
- Node.js
- PostgreSQL
- Docker

### Development Tools

- npm/yarn
- Jest
- ESLint
- Prettier
- TypeScript

## Additional Resources

- [API Documentation](../api/)
- [Database Schema](../database/)
- [Plugin Development](../plugins/)
- [Security Guidelines](../security/)
Loading
Loading