SnippetSphere is a bilingual (English/Vietnamese) code-sharing platform for developers. Share reusable snippets, tag them by language/topic, and get quick time–complexity estimates before publishing.
- CRUD flows for public and private code snippets with automatic slug generation
- Tagging by language & topic, trending and recent listing, user profile pages
- Heuristic complexity analysis with explanation + detected signals
- Email/password authentication backed by PostgreSQL sessions
- Responsive UI built with TailwindCSS + shadcn/ui (Violet theme)
- Internationalization via next-intl with locale-aware routing (en/vi)
- Next.js 15 (App Router + Turbopack)
- React 19 + TypeScript
- Prisma ORM with PostgreSQL
- TailwindCSS 3.4 + shadcn/ui
- next-intl for localization
- React Hook Form + Zod for validation
- react-syntax-highlighter for prism-based code previews
- Node.js 18 or later
- A PostgreSQL instance (local Docker container or remote database)
npm install
Copy the example file and set DATABASE_URL
(plus any optional URLs such as NEXT_PUBLIC_APP_URL
).
cp .env.example .env
# then edit .env with your connection string
Generate the Prisma client, run initial migrations, and seed sample data (optional but recommended to preview the UI).
npm run prisma:generate
npm run prisma:migrate -- --name init
npm run prisma:seed
The seed populates languages, topics, demo users, and a few featured snippets.
npm run dev
Visit http://localhost:3000
– language switcher is in the header.
npm run build
npm run start
src/
├─ app/ # App Router pages & layouts (localized under [locale])
├─ components/ # UI + domain components (shadcn primitives in components/ui)
├─ data/ # Prisma-backed data access helpers & domain types
├─ i18n/ # next-intl config + message bundles
├─ lib/ # Utilities (prisma client, slug/complexity helpers, etc.)
└─ styles/ # Global Tailwind styles (see src/app/globals.css)
- Tailwind config lives in
tailwind.config.ts
; Violet is the base theme. - shadcn/ui components can be added via
npx shadcn@latest add <component>
(aliases are configured incomponents.json
). - The main layout uses Geist fonts with CSS variables exposed for Tailwind.
- Supported locales:
en
,vi
- Locale switcher updates the URL segment and persists across routes.
- Translation files:
src/i18n/messages/en.json
&vi.json
Command | Description |
---|---|
npm run dev |
Start dev server (Turbopack) |
npm run build |
Production build |
npm run start |
Run the production server |
npm run prisma:generate |
Regenerate Prisma client |
npm run prisma:migrate |
Apply migrations (prompts for name) |
npm run prisma:seed |
Seed the database |
- Full-text search across snippets
- OAuth providers or magic-link auth
- Collaborative reviews & comments
- Exportable snippet collections for teams
Happy hacking! 🎉