Skip to content

jonechelon/spider-node-docs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ•·οΈ Spider Node

A collaborative rich text editor with advanced security features, built with the MERN stack.

Overview

Spider Node is a collaborative note-taking application featuring:

  • Rich text editing powered by TipTap
  • Node-based conversations (unlimited conversations)
  • Advanced security with JWT authentication, rate limiting, and audit logging
  • Public sharing with collaboration and fork modes
  • Balance system (SNOAI) for node creation

Interface principal do Spider Node Interface principal do Spider Node: sidebar com conversas Γ  esquerda, editor TipTap ao centro e marca d'Γ‘gua no fundo

Tech Stack

Backend

  • Node.js + Express - RESTful API server
  • MongoDB + Mongoose - Database and ODM
  • JWT (jsonwebtoken) - Authentication
  • express-rate-limit - Rate limiting protection
  • dotenv - Environment variable management

Frontend

  • React + Vite - Modern frontend framework
  • TipTap - Rich text editor
  • Axios - HTTP client
  • Tailwind CSS - Utility-first CSS framework
  • Lucide Icons - Icon library

Quick Start

Prerequisites

  • Node.js 16+ installed
  • MongoDB running locally (default port 27017)
  • Git (optional)

Installation

  1. Install backend dependencies:

    cd backend
    npm install
  2. Configure environment variables:

    Create /backend/.env file:

    # JWT Security
    JWT_SECRET=your_secret_key_here
    JWT_REFRESH_SECRET=your_refresh_secret_here
    JWT_EXPIRES_IN=15m
    JWT_REFRESH_EXPIRES_IN=30d
    
    # MongoDB
    MONGODB_URI=mongodb://localhost:27017/spidernoai
    
    # Server
    PORT=5174
    NODE_ENV=development
    
    # CORS
    FRONTEND_URL=http://localhost:5173
    
    # Rate Limiting
    RATE_LIMIT_LOGIN_MAX=5
    RATE_LIMIT_LOGIN_WINDOW_MS=900000
    RATE_LIMIT_GENERAL_MAX=100
    RATE_LIMIT_GENERAL_WINDOW_MS=900000
    
    # Audit Logging
    ENABLE_AUDIT_LOGS=true
    AUDIT_LOG_FILE=./logs/audit.log

    ⚠️ Important: For production, generate strong secrets:

    node -e "console.log(require('crypto').randomBytes(64).toString('hex'))"
  3. Create logs directory:

    cd backend
    mkdir logs
  4. Install frontend dependencies:

    cd frontend
    npm install

Running the Application

Terminal 1 - Backend:

cd backend
npm run dev

Expected output:

βœ… VariΓ‘veis de ambiente carregadas
πŸ”’ JWT Secret: ****...****
πŸ’Ύ MongoDB SpiderNoAI Conectado: mongodb://localhost:27017/spidernoai
πŸš€ SpiderNoAI Backend Ativo: http://localhost:5174

Terminal 2 - Frontend:

cd frontend
npm run dev

Expected output:

VITE v4.x.x  ready in xxx ms

➜  Local:   http://localhost:5173/
➜  Network: use --host to expose

Access the application: Open your browser at: http://localhost:5173

Project Structure

SpiderNode/
β”œβ”€β”€ backend/
β”‚   β”œβ”€β”€ config/
β”‚   β”‚   └── env.config.js         # Environment configuration
β”‚   β”œβ”€β”€ controllers/
β”‚   β”‚   └── entryController.js    # Entry logic
β”‚   β”œβ”€β”€ middleware/
β”‚   β”‚   β”œβ”€β”€ authMiddleware.js     # JWT authentication
β”‚   β”‚   └── rateLimitMiddleware.js # Rate limiting
β”‚   β”œβ”€β”€ models/
β”‚   β”‚   β”œβ”€β”€ userModel.js          # User model
β”‚   β”‚   β”œβ”€β”€ conversationModel.js  # Conversation model
β”‚   β”‚   β”œβ”€β”€ entryModel.js         # Entry model
β”‚   β”‚   └── refreshTokenModel.js  # Refresh token model
β”‚   β”œβ”€β”€ routes/
β”‚   β”‚   └── entryRoutes.js        # Entry routes
β”‚   β”œβ”€β”€ utils/
β”‚   β”‚   └── auditLogger.js        # Audit logging system
β”‚   β”œβ”€β”€ logs/
β”‚   β”‚   └── audit.log             # Audit logs
β”‚   β”œβ”€β”€ .env                      # Environment variables (not in git)
β”‚   β”œβ”€β”€ package.json
β”‚   └── server.js                 # Main server file
β”‚
β”œβ”€β”€ frontend/
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ App.jsx               # Main component
β”‚   β”‚   β”œβ”€β”€ pages/
β”‚   β”‚   β”‚   └── SharePage.jsx     # Sharing page
β”‚   β”‚   └── main.jsx              # Entry point
β”‚   β”œβ”€β”€ package.json
β”‚   └── vite.config.js            # Vite configuration
β”‚
β”œβ”€β”€ docs/                         # Documentation
β”‚   β”œβ”€β”€ installation.md           # Installation guide
β”‚   β”œβ”€β”€ security-guide.md         # Security implementation
β”‚   β”œβ”€β”€ security-testing.md       # Security testing guide
β”‚   β”œβ”€β”€ environment-setup.md      # Environment setup guide
β”‚   └── screenshots/              # Application screenshots
β”‚       β”œβ”€β”€ main-interface.jpg
β”‚       β”œβ”€β”€ editor-toolbar.jpg
β”‚       β”œβ”€β”€ conversation-menu.jpg
β”‚       β”œβ”€β”€ share-config.jpg
β”‚       β”œβ”€β”€ slow-mode-selector.jpg
β”‚       └── premium-badge.jpg
β”‚
β”œβ”€β”€ README.md                     # This file
└── CHANGELOG.md                  # Version history

Features

Rich Text Editor

Editor TipTap com toolbar completa Editor TipTap completo com toolbar de formataΓ§Γ£o: cabeΓ§alhos (H1, H2, H3), listas, tabelas, imagens e mais

  • Text formatting (bold, italic, underline)
  • Headings (H1, H2, H3)
  • Lists (bullet, numbered, task lists)
  • Tables
  • Images
  • Links
  • Blockquotes and code blocks

Node System (Conversations)

Menu de aΓ§Γ΅es de conversa Menu contextual: Compartilhar conversa, fixar no topo, renomear (premium) e deletar

  • Create unlimited conversations
  • Rename conversations (Premium feature)
  • Pin important conversations
  • Delete conversations
  • Public sharing

Sharing System

ConfiguraΓ§Γ£o de compartilhamento Modal de configuraΓ§Γ£o: escolha entre ColaboraΓ§Γ£o Total (atΓ© 60 pessoas) ou Apenas Fork (cΓ³pias privadas)

  • Unique sharing links
  • Collaboration mode (COLLAB_ONLY): up to 60 users with configurable slow mode
  • Fork mode (FORK_ONLY): users can only create private copies
  • Configurable slow mode intervals

Seletor de slow mode Seletor de slow mode: 1h (rΓ‘pido), 6h (moderado), 12h (devagar) ou 24h (muito devagar) entre mensagens

Balance System

Badge Premium com saldo SNOAI Badge premium exibindo saldo SNOAI disponΓ­vel para criaΓ§Γ£o de nΓ³s

  • SNOAI balance for creating nodes
  • Free users: 10 initial SNOAI
  • Premium users: 9999 SNOAI
  • Protection against manipulation

Security Features

v2.0 (Base)

  • βœ… JWT Authentication
  • βœ… Row-Level Security
  • βœ… Ownership Validation
  • βœ… snoaiBalance Protection

v2.1 (Enhanced)

  • βœ… Refresh Tokens (automatic renewal)
  • βœ… Rate Limiting (anti-brute force)
  • βœ… Audit Logging System (complete logs)
  • βœ… Environment Variables (.env)

API Endpoints

Authentication

  • POST /api/login - User login (returns accessToken + refreshToken)
  • POST /api/refresh-token - Refresh access token
  • POST /api/logout - Logout and revoke refresh token

Conversations

  • GET /api/conversations/:userId - List user conversations (protected)
  • GET /api/conversation/:id - Get conversation details (protected)
  • PUT /api/conversations/:id/pin - Pin/unpin conversation (protected)

Entries

  • POST /api/entries - Create new entry/node (protected)
  • GET /api/entries/conversation/:id - Get entries for conversation (protected)
  • PUT /api/entries/conversation/:id - Rename conversation (protected)
  • DELETE /api/entries/conversation/:id - Delete conversation (protected)

Sharing

  • GET /api/entries/share/:token - Access shared content (public, optional auth)

Security

Rate Limiting

Route Limit Window Exception
/api/login 5 attempts 15 min None
/api/refresh-token 10 attempts 5 min None
/api/* (general) 100 requests 15 min Premium users

Audit Logging

The system logs the following security events:

  • Access denied (403)
  • Authentication failed (401)
  • Rate limit reached (429)
  • Login/Logout
  • Refresh token usage
  • Manipulation attempts

View logs:

tail -f backend/logs/audit.log

Testing

Quick Functionality Test

# 1. Login
curl -X POST http://localhost:5174/api/login \
  -H "Content-Type: application/json" \
  -d '{"userId": "testuser"}'

# 2. Check audit logs
cat backend/logs/audit.log

# 3. Test rate limiting (6 attempts)
for i in {1..6}; do
  curl -X POST http://localhost:5174/api/login \
    -H "Content-Type: application/json" \
    -d '{"userId": "test"}';
done

For comprehensive security testing, see docs/security-testing.md.

Troubleshooting

MongoDB Connection Error

Error: MongoServerError: connect ECONNREFUSED

Solution: Start MongoDB:

# macOS (Homebrew)
brew services start mongodb-community

# Linux
sudo systemctl start mongod

# Windows
net start MongoDB

Port Already in Use

Error: Port 5174 is already in use

Solution: Change port in .env:

PORT=5175

CORS Policy Error

Error: CORS policy: No 'Access-Control-Allow-Origin' header

Solution: Verify FRONTEND_URL in .env:

FRONTEND_URL=http://localhost:5173

Missing Dependencies

Error: Cannot find module 'dotenv'

Solution:

cd backend
npm install

Documentation

Contributing

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/new-feature
  3. Commit your changes: git commit -m 'Add new feature'
  4. Push to the branch: git push origin feature/new-feature
  5. Open a Pull Request

Guidelines

  • Follow security best practices documented in docs/security-guide.md
  • Keep snoaiBalance as the variable name for user balance
  • Add tests for new features
  • Update documentation

License

This project is proprietary. All rights reserved.

Version

Current Version: 2.1.0
Last Updated: February 13, 2026
Status: βœ… Production Ready


πŸ•·οΈ Spider Node - Weave your ideas with security

About

Spider Node Docs

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published