Skip to content

nikcladis/code-hub

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

10 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Code Hub (SaaS) ๐Ÿš€๐Ÿ’ป

Code snippet manager. This project demonstrates user's ability to share, execute, and comment on code snippets in various programming languages.


Tech Stack ๐Ÿ› ๏ธ

  • Frontend: Next.js 15 โš›๏ธ
  • Authentication: Clerk ๐Ÿ”‘ (Google ๐ŸŒ and GitHub ๐Ÿ™ authentication)
  • Database: Convex ๐Ÿ“ฆ

Key Features โœจ

  • Authentication:
    ๐Ÿ”‘ Secure login via Google ๐ŸŒ and GitHub ๐Ÿ™ using Clerk.
  • Code Snippet Management:
    ๐Ÿ“„ Create, share, and manage code snippets.
    ๐Ÿ’ฌ Add comments on snippets.
    โญ Star favorite snippets for quick access.
  • Code Execution Logs:
    ๐Ÿ–ฅ๏ธ Store and view details of executed code.
  • User Management:
    ๐ŸŒŸ Pro user support with LemonSqueezy integration for subscriptions.

Convex Database Schema ๐Ÿ—„๏ธ

The database is structured using Convex for real-time interactions. Below is the schema definition:

import { defineSchema, defineTable } from "convex/server";
import { v } from "convex/values";

export default defineSchema({
  codeExecutions: defineTable({
    code: v.string(),
    error: v.optional(v.string()),
    language: v.string(),
    output: v.optional(v.string()),
    userId: v.string(),
  }).index("by_user_id", ["userId"]),
  snippetComments: defineTable({
    content: v.string(),
    snippetId: v.id("snippets"),
    userId: v.string(),
    userName: v.string(),
  }).index("by_snippet_id", ["snippetId"]),
  snippets: defineTable({
    code: v.string(),
    language: v.string(),
    title: v.string(),
    userId: v.string(),
    userName: v.string(),
  }).index("by_user_id", ["userId"]),
  stars: defineTable({
    snippetId: v.id("snippets"),
    userId: v.string(),
  })
    .index("by_snippet_id", ["snippetId"])
    .index("by_user_id", ["userId"])
    .index("by_user_id_and_snippet_id", [
      "userId",
      "snippetId",
    ]),
  users: defineTable({
    email: v.string(),
    isPro: v.boolean(),
    lemonSqueezyId: v.optional(v.string()),
    lemonSqueezyOrderId: v.optional(v.string()),
    name: v.string(),
    proSince: v.optional(v.float64()),
    userId: v.string(),
  }).index("by_user_id", ["userId"]),
});

Getting Started ๐Ÿ

Prerequisites โœ…

  • Node.js (v16 or higher) ๐ŸŸข
  • npm or yarn ๐Ÿ“ฆ
  • Convex CLI ๐Ÿ”ง
  • Clerk API keys ๐Ÿ”‘

Installation ๐Ÿ“ฅ

  1. Clone the repository:

    git clone https://github.com/yourusername/code-hub-saas.git
  2. Navigate to the project directory:

    cd code-hub-saas
  3. Install dependencies:

    npm install
  4. Setup โš™๏ธ

    Create a .env file and add your Clerk and Convex credentials:

    NEXT_PUBLIC_CLERK_FRONTEND_API=<your-clerk-api>
    CONVEX_URL=<your-convex-url>
  5. Run the Convex schema:

    npx convex dev
  6. Start the development server:

    npm run dev
  7. Access the application at:

    http://localhost:3000
    

Usage ๐Ÿ“˜

  • Sign In: Log in using your Google ๐ŸŒ or GitHub ๐Ÿ™ account.
  • Create Snippets: Add code snippets with a title, language, and optional description.
  • Collaborate: Add comments ๐Ÿ’ฌ and discuss snippets with other users.
  • Pro Features: Unlock advanced features ๐ŸŒŸ by upgrading to Pro via LemonSqueezy.

About

๐ŸŸ  Code.Hub is a platform that allows users to share, execute and comment their own coding snippets built with Next-15

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors