Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"yaml.schemas": {
"https://raw.githubusercontent.com/microsoft/vscode-github-actions/main/schema/github-workflow.json": ".github/workflows/*"
}
}
53 changes: 53 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Contributing to CodeTurtle

Thank you for considering contributing — we welcome and appreciate your help!

Please read these guidelines before opening issues or PRs to make the process fast and friendly for everyone.

## Code of Conduct
Read and follow `CODE_OF_CONDUCT.md`. Be respectful and constructive.

## How to Contribute
- For bugs: open an issue with a reproducible example, environment, and expected vs actual behavior.
- For feature ideas: open an issue describing the problem, the proposed solution, and any alternatives.
- For quick fixes and docs: open a PR directly against `main` from a feature branch.

## Development Workflow
1. Fork the repo and create a branch: `feature/<short-desc>` or `fix/<short-desc>`.
2. Keep changes small and focused.
3. Add tests when fixing bugs or adding features.
4. Run linting and tests locally before opening a PR:

```bash
bun install
bun run lint --if-present
bun run test --if-present
```

5. Open a PR and include:
- Summary of changes
- Testing steps
- Related issues

## Pull Request Checklist
- [ ] Branch off `main` and keep PR small
- [ ] Updated/added tests where applicable
- [ ] Linting passes locally
- [ ] Descriptive PR title and body
- [ ] Linked to an issue when appropriate

## Commit Messages
Use short, present-tense messages. Prefer conventional commits (e.g., `feat:`, `fix:`, `chore:`).

## Review & Merging
- At least one approving review required for changes to `main`.
- Maintainers may squash or rebase when merging.

## Local Environment & Secrets
Follow `.env.example` instructions in `README.md`. Do not commit credentials or tokens.

## Reporting Security Issues
If you find a security vulnerability, please report it privately via GitHub Security Advisories or by contacting the maintainer directly. Please do not open a public issue.

---
Thanks again — we look forward to your contribution!
Comment on lines +1 to +53
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Check for all referenced files
echo "=== Checking for CODE_OF_CONDUCT.md ==="
fd -t f "CODE_OF_CONDUCT.md" --max-depth 1

echo "=== Checking for README.md ==="
fd -t f "README.md" --max-depth 1

echo "=== Checking for .env.example ==="
fd -t f ".env.example" --max-depth 1

echo "=== List root directory files ==="
ls -la | head -20

Repository: Ansh-dhanani/codeturtle

Length of output: 1448


Add missing referenced files or update references.

The CONTRIBUTING.md references two files that do not exist in the repository:

  • CODE_OF_CONDUCT.md (referenced in "Read and follow CODE_OF_CONDUCT.md")
  • .env.example (referenced in "Follow .env.example instructions in README.md")

Either create these files or update the documentation to remove the references to avoid confusing contributors.

🤖 Prompt for AI Agents
In `@CONTRIBUTING.md` around lines 1 - 53, The CONTRIBUTING.md references missing
files CODE_OF_CONDUCT.md and .env.example (also mentioned via README.md); fix by
either adding those files to the repo or updating CONTRIBUTING.md/README.md to
remove or replace those references with existing resources (e.g., link to actual
code of conduct file or a different env example), ensuring the text "Read and
follow `CODE_OF_CONDUCT.md`" and "Follow `.env.example` instructions in
`README.md`" are corrected to point to real files or guidance.

106 changes: 77 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,66 +1,108 @@
# CodeTurtle
<div align="center">
<br />
<br />

A Next.js application with GitHub OAuth authentication, built with Better Auth and Prisma.
<picture>
<!-- Use explicit relative path so GitHub README renders correctly -->
<img src="./public/codeturtle-logo.svg" alt="CodeTurtle logo" width="200" />
</picture>

## Warning
<h1 align="center">🚧 Project Under Construction 🚧</h1>
<!-- Fallback for some markdown renderers: Markdown image with relative path -->
<!-- ![CodeTurtle logo](./public/codeturtle-logo.svg) -->

The site is under construction, so OAuth of GitHub might not work because it is set temperaroly for the local URL for development.
<h1 style="margin-top: 0.5rem;">CodeTurtle</h1>

## Features
<p style="margin: 0.25rem 0 0.75rem 0;"><strong>A production-ready Next.js platform with GitHub OAuth, Webhooks, and Prisma.</strong><br />
<small>Built for teams and developers shipping GitHub-integrated products with confidence.</small></p>

- 🔐 GitHub OAuth authentication (GitHub-only)
- 📊 PostgreSQL database with Prisma ORM
- 🎨 Modern UI with Tailwind CSS and Shadcn UI
- ⚡ Built with Next.js 15 and React 19
- 🔄 State management with React Query and Zustand
<p>
<a href="https://github.com/Ansh-dhanani/codeturtle/stargazers"><img src="https://img.shields.io/github/stars/Ansh-dhanani/codeturtle?style=flat-square" alt="GitHub stars" /></a>
<a href="https://github.com/Ansh-dhanani/codeturtle/actions/workflows/checks.yml"><img src="https://github.com/Ansh-dhanani/codeturtle/actions/workflows/checks.yml/badge.svg" alt="Checks status" /></a>
<a href="./LICENSE"><img src="https://img.shields.io/badge/license-MIT-blue?style=flat-square" alt="License" /></a>
<a href="https://github.com/Ansh-dhanani/codeturtle/issues"><img src="https://img.shields.io/github/issues/Ansh-dhanani/codeturtle?style=flat-square" alt="Open issues" /></a>
</p>

## Prerequisites
<p style="margin-top: 0.5rem;">
<a href="./docs/README.md">Documentation</a> · <a href="#installation">Quick Start</a> · <a href="./CONTRIBUTING.md">Contributing</a>
</p>
</div>

- Node.js 18+ or Bun
- PostgreSQL database
- GitHub OAuth App credentials

## Environment Setup

1. Create a `.env` file in the root directory:

<br />

---

## Why CodeTurtle?

A concise, production-ready Next.js starter with GitHub OAuth, webhook handling, and a Prisma-backed database. Designed for developers and teams building GitHub-integrated products.

For detailed architecture, tech stack, project structure, and integration details, see `./docs/README.md`.

---

## Features (short)

* GitHub OAuth authentication
* Secure GitHub webhook handling
* PostgreSQL + Prisma
* Next.js App Router, Tailwind CSS

---

## Getting Started

### Prerequisites

* Node.js 18+ or Bun
* PostgreSQL 12+
* GitHub OAuth App

---

### Environment Variables

Create a `.env` file in the project root:

```env
DATABASE_URL="postgresql://user:password@host:port/database"
BETTER_AUTH_SECRET="your-secret-key"

BETTER_AUTH_SECRET="your-better-auth-secret"
BETTER_AUTH_URL="http://localhost:3000"

NEXT_PUBLIC_APP_URL="http://localhost:3000"

GITHUB_CLIENT_ID="your-github-client-id"
GITHUB_CLIENT_SECRET="your-github-client-secret"

GITHUB_WEBHOOK_SECRET="optional-fallback-secret"
```

2. Create a GitHub OAuth App:
- Go to GitHub Settings → Developer settings → OAuth Apps
- Create a new OAuth App
- Set Authorization callback URL to: `http://localhost:3000/api/auth/callback/github`
- Copy Client ID and Client Secret to your `.env` file
---

## Getting Started
## Installation

1. Install dependencies:
Install dependencies:

```bash
bun install
```

2. Generate Prisma client and run migrations:
Generate Prisma client and run migrations:

```bash
npx prisma generate
npx prisma migrate dev
npx prisma migrate dev --name init
```

3. Seed the database with test data (optional):
Optional seed:

```bash
bun run db:seed
```

4. Run the development server:
Start the development server:

```bash
bun dev
Expand Down Expand Up @@ -99,3 +141,9 @@ You can check out [the Next.js GitHub repository](https://github.com/vercel/next
The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.

Check out our [Next.js deployment documentation](https://nextjs.org/docs/app/building-your-application/deploying) for more details.

## Contributors

<a href="https://github.com/Ansh-dhanani/codeturtle/graphs/contributors">
<img src="https://contrib.rocks/image?repo=Ansh-dhanani/codeturtle" alt="CodeTurtle contributors" />
</a>
72 changes: 72 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# Documentation — CodeTurtle

This document consolidates the project's key documentation into a single reference.

## Quick Links
- Getting started: see the main `README.md`
- Contributing: `CONTRIBUTING.md`

---

## Architecture
CodeTurtle is a full-stack Next.js app (App Router) with authentication, webhook ingestion, and a Prisma-backed database. Major components:

- Client: Next.js (React) with App Router and server components
- Authentication & API: Better Auth for GitHub OAuth + API routes
- Integrations: GitHub (OAuth, webhooks), Vercel (deployment)
- Persistence: Prisma → PostgreSQL

Notes:
- Webhook ingestion endpoint: `POST /api/webhooks/github` (signature verification enforced)
- Keep `NEXT_PUBLIC_APP_URL` configured and normalized (no trailing slash)

---

## Tech Stack
- Framework: Next.js (App Router)
- Runtime: Bun (dev/CI); Node-compatible
- Auth: Better Auth (GitHub OAuth)
- DB: PostgreSQL with Prisma
- Styles: Tailwind CSS + Shadcn UI

---

## GitHub Integration
- OAuth scopes: `repo`, `admin:repo_hook` (as needed)
- Webhooks: supported events — `ping`, `pull_request` (extendable)
- Secrets: webhook secrets are stored per repository and used to validate signatures
- Local testing: use `ngrok` and set `NEXT_PUBLIC_APP_URL` to your tunnel URL

---

## Project Structure
```text
src/
├── app/ # Next.js App Router
├── api/ # API routes (auth, webhooks)
├── lib/ # Auth, prisma client, utilities
├── components/ # Shared UI components
├── prisma/ # Prisma schema and migrations
└── styles/ # Global styles
```
Comment on lines +42 to +51
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Project structure appears inconsistent with Next.js App Router conventions.

The structure shows api/ as a sibling directory to app/, but based on Next.js App Router conventions and the files in this PR (e.g., src/app/api/user/github-account/route.ts), API routes are located inside src/app/api/.

Suggested fix
 src/
 ├── app/                # Next.js App Router
-├── api/                # API routes (auth, webhooks)
+│   └── api/            # API routes (auth, webhooks)
 ├── lib/                # Auth, prisma client, utilities
 ├── components/         # Shared UI components
-├── prisma/             # Prisma schema and migrations
 └── styles/             # Global styles
+prisma/                 # Prisma schema and migrations (at root)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
## Project Structure
```text
src/
├── app/ # Next.js App Router
├── api/ # API routes (auth, webhooks)
├── lib/ # Auth, prisma client, utilities
├── components/ # Shared UI components
├── prisma/ # Prisma schema and migrations
└── styles/ # Global styles
```
src/
├── app/ # Next.js App Router
│ └── api/ # API routes (auth, webhooks)
├── lib/ # Auth, prisma client, utilities
├── components/ # Shared UI components
└── styles/ # Global styles
prisma/ # Prisma schema and migrations (at root)
🤖 Prompt for AI Agents
In `@docs/README.md` around lines 42 - 51, The README's Project Structure
incorrectly lists "api/" as a top-level sibling to "app/"; update the section so
API routes are shown under the App Router (e.g., reflect "src/app/api/" rather
than "src/api/") and ensure the example tree matches actual routes used in the
repo (for example, the existing route file
src/app/api/user/github-account/route.ts); modify the bullet for api to indicate
it's within app (or remove the standalone api/ entry) and keep other folder
names unchanged.


---

## Development
- Install: `bun install`
- Generate Prisma client: `npx prisma generate`
- Apply migrations: `npx prisma migrate dev`
- Dev server: `bun dev`
- Tests: `bun run test --if-present`

---

## CI / Deployment
- Checks workflow: `.github/workflows/checks.yml` (lint, test, build)
- Deploy workflow: `.github/workflows/deploy.yml` (push to `main`, requires `VERCEL_TOKEN`)

---

## Troubleshooting
- Redirects/308: ensure webhook URL is exactly `NEXT_PUBLIC_APP_URL` + `/api/webhooks/github` (no double slashes)
- Signature failures: ensure you compute HMAC over the raw payload and compare with `X-Hub-Signature-256`
11 changes: 11 additions & 0 deletions next.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
import type { NextConfig } from "next";

const nextConfig: NextConfig = {
cacheComponents: true,
// Suppress source map warnings in production builds
productionBrowserSourceMaps: false,
// Reduce build output verbosity
logging: {
fetches: {
fullUrl: false,
},
},
// Configure Turbopack (empty config to acknowledge Turbopack usage)
turbopack: {},
images: {
remotePatterns: [
{
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"dev": "next dev",
"build": "prisma generate && next build",
"start": "next start",
"lint": "eslint",
"lint": "eslint . --max-warnings 0",
"postinstall": "prisma generate",
"db:seed": "tsx prisma/seed.ts",
"db:clear": "tsx prisma/clear-db.ts",
Expand Down
Loading