Skip to content

A modern code snippet sharing platform built with Go and Vue.js. Features include user authentication, syntax highlighting, and a responsive UI.

License

Notifications You must be signed in to change notification settings

mitsimi/code-share

Repository files navigation

Code Share

A modern web application for sharing and managing code snippets, built with Go and Vue.js.

Project Structure

.
├── frontend/          # Vue.js frontend application
│   ├── src/          # Source files
│   │   ├── components/  # Vue components
│   │   ├── stores/     # Pinia stores
│   │   ├── views/      # Page components
│   │   └── ...
│   ├── dist/         # Built frontend files
│   └── ...
├── internal/         # Backend application
│   ├── api/         # HTTP handlers
│   ├── models/      # Data models
│   ├── server/      # Server setup and routing
│   └── storage/     # Storage interfaces and implementations
├── data/            # Database migrations and seeds
├── yaak/           # Yaak configuration files
└── main.go         # Application entry point

Features

  • User authentication and authorization
  • Share code snippets with others
  • Like and unlike snippets with real-time updates
  • Modern, responsive UI with loading states
  • RESTful API with proper error handling
  • Client-side caching with TanStack Query
  • Secure API responses that protect user data
  • Form validation with Zod and VeeValidate
  • Toast notifications with Vue Sonner
  • Database integration with SQLC

API Endpoints

Authentication

  • POST /api/auth/login - User login
  • POST /api/auth/signup - User registration
  • POST /api/auth/logout - User logout
  • POST /api/auth/refresh - Refresh access token
  • GET /api/auth/me - Get current user

Snippets

  • GET /api/snippets - Get all snippets
  • GET /api/snippets/{id} - Get a specific snippet
  • POST /api/snippets - Create a new snippet
  • PUT /api/snippets/{id} - Update a snippet
  • DELETE /api/snippets/{id} - Delete a snippet
  • PATCH /api/snippets/{id}/like?action=like|unlike - Like or unlike a snippet

Prerequisites

  • Go 1.24 or later
  • Node.js 22.x or later
  • pnpm (recommended) or npm
  • Docker and Docker Compose (optional)

Development

Backend Setup

  1. Install Go dependencies:

    go mod download
  2. Run the server:

    # Using Air for hot reload
    air
    # Or directly
    go run main.go

Frontend Setup

  1. Install dependencies:

    cd frontend
    pnpm install
  2. Start development server:

    pnpm dev
  3. Build for production:

    pnpm build

Project Architecture

Backend

The backend follows a clean architecture pattern:

  • Models: Data structures and validation
  • Storage: Data persistence interface and implementations
  • API: HTTP handlers and request/response handling
  • Server: Routing and middleware setup
  • Database: PostgreSQL with SQLC for type-safe queries

Frontend

The frontend is built with Vue.js and uses:

  • Vue 3 with Composition API
  • TypeScript for type safety
  • Vite for build tooling
  • Tailwind CSS for styling
  • Pinia for state management
  • TanStack Query for data fetching
  • VeeValidate with Zod for form validation

Technologies Used

Backend

  • Go
  • SQLite
  • SQLC
  • Air (for live reload)
  • Docker

Frontend

  • Vue 3
  • TypeScript
  • Vite
  • Tailwind CSS
  • Pinia
  • TanStack Query
  • Zod

Future Improvements

  • Add database integration
  • Add user authentication
  • Add syntax highlighting
  • Possibility to bookmark snippets
  • Add user profiles

Optional:

  • Add snippet categories/tags
  • Add search functionality
  • Add comments on snippets

License

This project is licensed under the MIT License - see the LICENSE file for details.

About

A modern code snippet sharing platform built with Go and Vue.js. Features include user authentication, syntax highlighting, and a responsive UI.

Resources

License

Stars

Watchers

Forks

Packages