Skip to content

WeWriteApp/WeWrite

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

WeWrite

License Node Next.js TypeScript

A social wiki where every page you write is a fundraiser.

WeWrite transforms knowledge sharing into a collaborative economy where writers earn direct USD payments from their contributions and readers support creators with transparent monthly funding.

Table of Contents

🌐 Connect With Us

✨ What Makes WeWrite Special

  • πŸ“ Collaborative Writing - Create and edit pages together with smart versioning
  • πŸ’° Direct USD Payments - Support creators with transparent monthly funding
  • πŸ”— Smart Linking - Connect ideas across the platform with inline pill links
  • πŸŒ™ Beautiful Interface - Clean, modern design with dark mode and glassmorphism
  • πŸ”’ Secure & Private - Your data is protected and encrypted
  • ⚑ High Performance - 90% cost reduction through optimization strategies

πŸš€ Quick Start

Prerequisites

  • Node.js 20.x or higher
  • Bun (preferred package manager - faster than npm/pnpm)

Installation

# Install Bun if you don't have it
curl -fsSL https://bun.sh/install | bash

# Clone the repository
git clone https://github.com/WeWriteApp/WeWrite.git
cd WeWrite

# Install dependencies
bun install

# Set up environment variables
cp .env.example .env.local
# Edit .env.local with your configuration

# Run the development server
bun dev

Open http://localhost:3000 to see WeWrite in action!

πŸ—οΈ System Architecture

High-Level Architecture

graph TB
    subgraph "Client Layer"
        Web[Next.js Web App]
        PWA[Progressive Web App]
    end

    subgraph "API Layer"
        API[API Routes]
        Webhooks[Stripe Webhooks]
        Cron[Cron Jobs]
    end

    subgraph "Service Layer"
        Auth[Authentication Service]
        Payment[Payment Service]
        Earnings[Earnings Service]
        Email[Email Service]
        Search[Search Service]
    end

    subgraph "Data Layer"
        Firebase[(Firebase)]
        Firestore[(Firestore DB)]
        Storage[(Firebase Storage)]
    end

    subgraph "External Services"
        Stripe[Stripe Payments]
        Resend[Resend Email]
    end

    Web --> API
    PWA --> API
    API --> Service Layer
    Webhooks --> Service Layer
    Cron --> Service Layer
    Service Layer --> Data Layer
    Payment --> Stripe
    Email --> Resend
    Auth --> Firebase
Loading

Payment Flow Architecture

sequenceDiagram
    participant User
    participant Frontend
    participant API
    participant Stripe
    participant Database
    participant Cron

    User->>Frontend: Subscribe ($10, $20, $30)
    Frontend->>API: Create Subscription
    API->>Stripe: Create Checkout Session
    Stripe-->>User: Payment Page
    User->>Stripe: Complete Payment
    Stripe->>API: Webhook: subscription.created
    API->>Database: Create USD Balance

    User->>Frontend: Allocate to Creators
    Frontend->>API: Set Allocations
    API->>Database: Store Allocations

    Note over Cron,Database: End of Month
    Cron->>Database: Calculate Earnings
    Cron->>Database: Lock Allocations
    Cron->>Stripe: Process Payouts
    Stripe-->>Database: Update Payout Status
Loading

Data Flow

graph LR
    A[User Subscription] --> B[USD Balance]
    B --> C[Monthly Allocations]
    C --> D[Creator Earnings]
    D --> E[Payouts]

    F[Unallocated Funds] --> G[Platform Revenue]

    style A fill:#e1f5ff
    style B fill:#fff3e0
    style C fill:#f3e5f5
    style D fill:#e8f5e9
    style E fill:#fff9c4
    style F fill:#ffebee
    style G fill:#fce4ec
Loading

Environment Architecture

graph TD
    subgraph "Development"
        DevBranch[dev branch]
        DevCollections[DEV_* Collections]
        DevData[Test Data]
    end

    subgraph "Production"
        MainBranch[main branch]
        ProdCollections[Production Collections]
        RealData[Real User Data]
    end

    DevBranch --> DevCollections
    DevCollections --> DevData
    MainBranch --> ProdCollections
    ProdCollections --> RealData

    style DevBranch fill:#e3f2fd
    style MainBranch fill:#e8f5e9
Loading

πŸ› οΈ Technology Stack

Core Technologies

  • βš›οΈ Next.js 14 - React framework with App Router
  • πŸ”₯ Firebase - Backend-as-a-Service platform
  • 🎨 Tailwind CSS - Utility-first CSS framework
  • πŸ“ Slate.js - Customizable rich text editor framework
  • πŸ’³ Stripe - Payment processing and subscriptions
  • πŸ” TypeScript - Type-safe JavaScript development

Firebase Services

  • πŸ—„οΈ Firestore - NoSQL document database for pages, users, and versions
  • πŸ” Authentication - Email/password authentication with session management
  • ☁️ Functions - Serverless functions for webhooks and background processing
  • πŸ“ Storage - File storage for images and attachments

Development & Deployment

  • πŸ“¦ Bun - Fast, disk space efficient package manager
  • πŸš€ Vercel - Deployment platform with automatic CI/CD
  • πŸ“Š LogRocket - Session replay and error tracking

Key Features

  • πŸŒ™ Dark Mode - System-aware theme switching with OKLCH color system
  • πŸ“± Responsive Design - Mobile-first responsive interface
  • πŸ”— Smart Linking - Automatic page linking and backlinks with inline pills
  • πŸ’° USD Creator Support - Direct USD payments with transparent monthly funding
  • πŸ”’ Security - Comprehensive security measures and data protection
  • ⚑ Performance - 90% cost reduction through aggressive optimization

πŸ“š Documentation

Essential Documentation (Start Here)

Core Systems

Authentication & Security

Payment & Financial System

Content & Editor

Search & Discovery

UI & Design

Performance & Optimization

Deployment & Operations

Development Standards

Full Documentation Index

For a complete list of all documentation, see docs/README.md.

πŸ“ Project Structure

WeWrite/
β”œβ”€β”€ app/                      # Next.js App Router
β”‚   β”œβ”€β”€ api/                 # API routes and endpoints
β”‚   β”‚   β”œβ”€β”€ admin/          # Admin API endpoints
β”‚   β”‚   β”œβ”€β”€ cron/           # Scheduled job endpoints
β”‚   β”‚   └── webhooks/       # Stripe webhook handlers
β”‚   β”œβ”€β”€ admin/              # Admin dashboard pages
β”‚   β”œβ”€β”€ auth/               # Authentication pages
β”‚   β”œβ”€β”€ components/         # Reusable UI components
β”‚   β”‚   β”œβ”€β”€ admin/         # Admin-specific components
β”‚   β”‚   β”œβ”€β”€ editor/        # Rich text editor components
β”‚   β”‚   β”œβ”€β”€ landing/       # Landing page components
β”‚   β”‚   β”œβ”€β”€ layout/        # Layout components
β”‚   β”‚   β”œβ”€β”€ payments/      # Payment UI components
β”‚   β”‚   └── ui/            # Shared UI components
β”‚   β”œβ”€β”€ contexts/           # React contexts for global state
β”‚   β”œβ”€β”€ hooks/              # Custom React hooks
β”‚   β”œβ”€β”€ lib/                # Utility libraries and helpers
β”‚   β”œβ”€β”€ providers/          # Context providers
β”‚   β”œβ”€β”€ services/           # Business logic services
β”‚   β”œβ”€β”€ settings/           # User settings pages
β”‚   └── utils/              # Utility functions
β”œβ”€β”€ docs/                   # Technical documentation
β”‚   β”œβ”€β”€ architecture/       # System architecture docs
β”‚   β”œβ”€β”€ auth/              # Authentication docs
β”‚   β”œβ”€β”€ deployment/        # Deployment guides
β”‚   β”œβ”€β”€ editor/            # Editor documentation
β”‚   β”œβ”€β”€ features/          # Feature-specific docs
β”‚   β”œβ”€β”€ firebase/          # Firebase patterns
β”‚   β”œβ”€β”€ payments/          # Payment system docs
β”‚   β”œβ”€β”€ performance/       # Performance guides
β”‚   β”œβ”€β”€ search/            # Search system docs
β”‚   β”œβ”€β”€ security/          # Security documentation
β”‚   └── ui/                # UI and design docs
β”œβ”€β”€ functions/              # Firebase Cloud Functions
β”œβ”€β”€ public/                 # Static assets
β”‚   β”œβ”€β”€ icons/             # App icons and favicons
β”‚   └── images/            # Images and graphics
└── scripts/                # Build and utility scripts

Key Directories

  • app/ - Next.js 14 App Router with file-based routing
  • app/components/ - Reusable UI components organized by feature
  • app/services/ - Business logic services (payment, earnings, email, etc.)
  • app/api/ - API routes for backend functionality
  • docs/ - Comprehensive technical documentation
  • functions/ - Firebase Cloud Functions for webhooks and background tasks

πŸ”§ Development

Development Commands

# Start development server
bun dev

# Start with HTTPS (for PWA testing)
bun dev:https

# Build for production
bun build

# Run tests
bun test

# Run tests in watch mode
bun test:watch

# Run specific test suites
bun test:payments
bun test:payouts
bun test:allocation

Branch-Aware Environment

WeWrite uses branch-aware environment detection for local development:

  • Main branch (main): Uses production collections - connects to real data
  • Dev branch (dev): Uses dev collections (DEV_* prefix) - isolated test data
  • Other branches: Uses dev collections (safe default) - isolated test data

This ensures you can test against production data when needed (main branch) while keeping development work safely isolated (dev branch).

Code Quality

Before contributing, ensure you follow:

  1. TypeScript strict mode - All code must be type-safe
  2. ESLint rules - Run bun lint before committing
  3. Security guidelines - Follow USERNAME_SECURITY_GUIDELINES
  4. Performance practices - Follow PERFORMANCE_OPTIMIZATION_GUIDE

πŸš€ Deployment

Automatic Deployment

WeWrite uses Vercel for automatic deployment:

  • Production: Deploys from main branch to wewrite.app
  • Preview: Deploys from dev branch for testing
  • Environment Variables: Configured in Vercel dashboard

See Production Deployment Guide for detailed procedures.

🀝 Contributing

We welcome contributions! Here's how to get started:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Follow our coding standards (see documentation)
  4. Write tests for new functionality
  5. Commit your changes with clear messages
  6. Submit a pull request

Development Guidelines

Code of Conduct

  • Be respectful and inclusive
  • Focus on constructive feedback
  • Help create a welcoming environment for all contributors

πŸ“„ License

This project is licensed under the GNU General Public License v3.0 - see the LICENSE.md file for details.

This is free software: you are free to change and redistribute it under the terms of the GPL-3.0 license.

πŸ’¬ Support

πŸ™ Acknowledgments

Built with modern web technologies and powered by:


Made with ❀️ by the WeWrite team

⬆ Back to top

Releases

No releases published

Sponsor this project

Packages

No packages published

Contributors 8