Skip to content

My graduation project: A modern code snippet sharing platform with VS Code-like editor, AI assistance, and advanced UI/UX

License

Notifications You must be signed in to change notification settings

Mobiwuhu/CodeSnip

Repository files navigation

Design and Implementation of a web-based Code Snippet Sharing Platform

An advanced code snippet management platform with VS Code-like experience, AI assistance, enhanced UI/UX, and multilingual search capabilities.

📹 Watch the demonstration video

Project Overview

This platform is engineered to fundamentally improve how developers create, manage, share, and discover code snippets. It addresses common shortcomings of existing snippet management tools—such as inefficient organization, basic editors, and limited collaboration—by providing a comprehensive solution that emphasizes frontend excellence as a core differentiator.

The platform seamlessly blends advanced functionalities including:

  • Authentic VS Code-like editing experience via Monaco Editor
  • Real-time, client-side language detection using guesslang.js
  • AI-powered metadata generation with DeepSeek Chat API
  • Robust social interaction features
  • Outstanding, responsive, and feature-rich user interface

Key Innovations & Differentiators

1. Advanced and Responsive UI/UX

  • Dual View Modes:
    • Rich, high-performance Grid View with masonry layout, virtual and infinite scrolling
    • Compact, functional List View with pagination and expandable code
  • Seamless Responsiveness: Desktop-first approach with full adaptation for all screen sizes
  • Theme Customization: User-selectable Light and Dark modes

2. Superior & Customizable Editing Experience

  • Monaco Editor Integration: VS Code-like coding environment in the browser
  • Multiple Editor Themes: VS Dark, VS Light, HC Black, HC Light, GitHub Dark, GitHub Light, Monokai, Dracula, etc.
  • Broad Language Support: Syntax highlighting and editing for 56 programming languages

3. Intelligent Features

  • Automatic Language Detection: Client-side guesslang.js identifies programming languages as users type
  • AI-Assisted Metadata: DeepSeek Chat API automates titles, descriptions, and tags by analyzing code
  • Enhanced Multilingual Search: Full-text search with excellent word segmentation for both Chinese and English

Comprehensive Feature Set

User Authentication & Management

  • Secure JWT-based registration and login
  • Profile management (display name, avatar, email, bio)
  • Route protection with automatic redirection

Code Snippet Management

  • Create, read, update, and delete snippets with Monaco Editor
  • Manual and AI-suggested tagging
  • Privacy controls (public/private snippets)

Advanced Discovery & Browsing

  • Unified Interface across main Feed, personal snippets, and bookmarks
  • Filtering: Tag-based filtering with autocomplete suggestions
  • Full-Text Search: Across snippet content, titles, descriptions, and tags
  • Intelligent Text Handling: Custom TextEllipsis component for clean layouts

Social Interaction System

  • Likes, comments, and bookmarks
  • Shareable links for easy sharing

Tech Stack

Frontend

Backend

  • API Framework: Hono.js - Lightweight, fast web framework
  • Database: PostgreSQL with enhanced Chinese/English Full-Text Search
  • ORM: Prisma - Type-safe database ORM
  • Authentication: JWT (jsonwebtoken) + Bcrypt password encryption
  • API Validation: Zod - Type validation library
  • AI Integration: DeepSeek Chat API for intelligent metadata generation

Tools and Build

  • Package Manager: pnpm - Efficient package manager
  • TypeScript: Provides type-safe code development
  • PostCSS: CSS preprocessing
  • ESLint/TypeScript: Code quality checking tools
  • Date Handling: date-fns - Modern JavaScript date utility library

Data Models

The platform uses Prisma ORM with PostgreSQL database, including the following main data models:

  • Users (users): User account information
  • Code Snippets (code_snippets): Stores code snippets and metadata with enhanced search capabilities
  • Bookmarks (bookmarks): User-bookmarked code snippets
  • Likes (likes): User likes on code snippets
  • Comments (comments): User comments on code snippets

Project Structure

CodeSnip/
├── app/                  # Next.js pages and routes
├── components/           # React components
│   ├── ui/               # UI base components
│   ├── business/         # Business components
│   ├── auth/             # Authentication-related components
│   └── layout/           # Layout components
├── server/               # Hono API service
│   ├── routes/           # API route definitions
│   ├── middleware/       # API middleware
│   └── db/               # Database connections and operations
├── prisma/               # Prisma models and migrations
├── public/               # Static assets
├── styles/               # Global styles
├── lib/                  # Libraries
├── utils/                # Utility functions
└── hooks/                # React Hooks

Environment Configuration

The project requires the following environment variables (in .env file):

DATABASE_URL=postgresql://user:password@localhost:5432/dbname
JWT_SECRET=your-secret-key
OPENAI_API_KEY=your-openai-api-key (optional, for AI features)
DEEPSEEK_API_KEY=your-deepseek-api-key (for AI metadata generation)

Getting Started

# Install dependencies
pnpm install

# Initialize database (first run)
pnpm prisma migrate dev

# Start development mode
pnpm dev

# Build project
pnpm build

# Start production mode
pnpm start

Target Audience

This platform is designed for developers, students, and teams who value:

  • Efficiency and streamlined workflows
  • Collaboration and knowledge sharing
  • VS Code-like experience with extensive customization
  • AI assistance for routine tasks
  • Polished, responsive (desktop-first), and performant UI

Contribution Guidelines

Contributions, issues, and feature requests are welcome. Please fork the project, create a branch, submit your changes, and open a Pull Request.

License

This project is licensed under the MIT License.

About

My graduation project: A modern code snippet sharing platform with VS Code-like editor, AI assistance, and advanced UI/UX

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •