# WYSIWYG Markdown Editor

A markdown editor with live preview, file management, and theme switching.

## Features

- **Markdown Editor**: Write markdown with live GitHub Flavored Markdown preview
- **File Management**: Create, open, save, and delete markdown files
- **Theme System**: Dark, Light, and System themes
- **Responsive Design**: Works on desktop and mobile devices

## Running the Application

### Prerequisites

- Node.js (v18+)
- Go (v1.21+)
- npm or yarn

### Backend

```bash
# Build the backend
cd backend
make build

# Run the backend
./bin/markdown-editor

# Or with custom flags
./bin/markdown-editor --data-dir ./my-data --port 3000 --host 0.0.0.0
```

### Frontend

```bash
# Install dependencies
cd frontend
npm install

# Build the frontend
npm run build

# Run in development mode
npm run dev
```

### Running Both

1. Build the frontend:
   ```bash
   cd frontend
   npm run build
   ```

2. Run the backend (it will serve the built frontend):
   ```bash
   cd backend
   ./bin/markdown-editor
   ```

3. Open your browser to `http://localhost:8080`

## Development

### Running Tests

```bash
# Backend tests
cd backend
make test

# Frontend tests
cd frontend
npm test
```

### Project Structure

```
backend/
  cmd/
    backend/
      main.go
  internal/
    api/
      api.go
    logger/
      logger.go
    server/
      server.go
  tests/
    api_test.go
  go.mod
  go.sum
  Makefile

frontend/
  src/
    App.tsx
    main.tsx
    index.css
    setupTests.ts
    App.test.tsx
  package.json
  vite.config.ts
  tailwind.config.js
  postcss.config.js
  tsconfig.json
  index.html

Makefile
README.md
SPEC.md
```

## API Endpoints

- `GET /api/{filename}.md` - Get markdown file content
- `POST /api/{filename}.md` - Create a new markdown file
- `PUT /api/{filename}.md` - Update an existing markdown file
- `DELETE /api/{filename}.md` - Delete a markdown file

## License

MIT
