Skip to content

feat: create project folder structure #23

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 5, 2025
Merged
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
32 changes: 32 additions & 0 deletions app/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# App Directory

This directory contains the Next.js 15 App Router pages and routes.

## Structure

```
app/
├── layout.tsx # Root layout with providers
├── page.tsx # Home page (/)
├── globals.css # Global styles and Tailwind imports
├── create/
│ └── page.tsx # Create new gist page (/create)
├── g/
│ └── [id]/
│ └── page.tsx # View gist page (/g/[id])
└── api/ # API routes (will be added in Phase 5)
```

## Conventions

- All pages use `export default` for the page component
- Dynamic route parameters use `params: Promise<{ paramName: string }>` in Next.js 15
- All routes are configured for edge runtime compatibility
- Use async components where needed for data fetching
- Follow the colocation pattern for route-specific components

## Route Overview

- `/` - Landing page with create gist form
- `/create` - Dedicated page for creating new gists (alternative to home)
- `/g/[id]` - View a specific gist by ID (requires decryption key in URL fragment)
10 changes: 10 additions & 0 deletions app/create/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export default function CreateGistPage() {
return (
<div className="container mx-auto py-8">
<h1 className="mb-4 text-2xl font-bold">Create New Gist</h1>
<p className="text-muted-foreground">
This page will contain the form for creating encrypted gists.
</p>
</div>
);
}
17 changes: 17 additions & 0 deletions app/g/[id]/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
export default async function ViewGistPage({
params,
}: {
params: Promise<{ id: string }>;
}) {
const { id } = await params;

return (
<div className="container mx-auto py-8">
<h1 className="mb-4 text-2xl font-bold">View Gist</h1>
<p className="text-muted-foreground">
This page will display the gist viewer for viewing encrypted gists.
</p>
<p className="text-muted-foreground mt-2 text-sm">Gist ID: {id}</p>
</div>
);
}
52 changes: 52 additions & 0 deletions components/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Components Directory

This directory contains all React components used throughout the application.

## Structure

```
components/
├── ui/ # shadcn/ui components (auto-generated)
├── theme-provider.tsx
├── theme-toggle.tsx
└── [future components will be added here]
```

## Conventions

- All components are written in TypeScript with proper type definitions
- Components use the `.tsx` extension
- Follow the single responsibility principle - each component has one clear purpose
- Use `"use client"` directive only when necessary (client-side interactivity)
- Prefer composition over inheritance
- Export components as named exports (except for pages)

## Component Categories (to be implemented)

### Layout Components

- Header - Main navigation
- Footer - Site information
- Container - Consistent spacing wrapper

### Form Components

- FileTab - Multi-file support
- CodeEditor - CodeMirror wrapper
- ExpirySelector - Expiration time picker
- PINInput - Secure PIN entry
- ShareDialog - Share link with copy

### Display Components

- GistViewer - Display encrypted gists
- FileList - List of files in a gist
- LoadingStates - Loading indicators
- ErrorBoundary - Error handling

## Styling

- Use Tailwind CSS classes via `cn()` utility
- Follow shadcn/ui patterns for consistency
- Support both light and dark themes
- Ensure responsive design
4 changes: 2 additions & 2 deletions docs/TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ This document tracks the implementation progress of GhostPaste. Check off tasks

### Project Structure

- [ ] Create folder structure (`app/`, `components/`, `lib/`, `types/`) - [#11](https://github.com/nullcoder/ghostpaste/issues/11)
- [ ] Set up app router pages structure - [#11](https://github.com/nullcoder/ghostpaste/issues/11)
- [x] Create folder structure (`app/`, `components/`, `lib/`, `types/`) - [#11](https://github.com/nullcoder/ghostpaste/issues/11)
- [x] Set up app router pages structure - [#11](https://github.com/nullcoder/ghostpaste/issues/11)
- [x] Create base layout with theme provider - [#8](https://github.com/nullcoder/ghostpaste/issues/8)
- [x] Set up global styles and CSS variables - [#8](https://github.com/nullcoder/ghostpaste/issues/8)
- [ ] Verify Cloudflare R2 setup - [#12](https://github.com/nullcoder/ghostpaste/issues/12)
Expand Down
46 changes: 46 additions & 0 deletions lib/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Lib Directory

This directory contains utility functions, business logic, and service modules.

## Structure

```
lib/
├── utils.ts # General utility functions (cn, etc.)
└── [future modules will be added here]
```

## Planned Modules (to be implemented)

### Core Modules

- `crypto.ts` - Encryption/decryption utilities using Web Crypto API
- `storage.ts` - Cloudflare R2 storage client wrapper
- `binary.ts` - Binary format encoding/decoding for file storage
- `auth.ts` - PIN hashing and validation

### Utilities

- `logger.ts` - Structured logging utility
- `errors.ts` - Custom error classes and handling
- `validation.ts` - Input validation helpers
- `constants.ts` - Application constants and limits

## Conventions

- All modules must be edge runtime compatible (no Node.js APIs)
- Use Web Crypto API for cryptographic operations
- Export functions and constants as named exports
- Write pure functions where possible
- Include comprehensive error handling
- Add JSDoc comments for public APIs

## Edge Runtime Compatibility

All code in this directory must work in Cloudflare Workers:

- No `fs`, `path`, or other Node.js modules
- Use Web APIs (fetch, crypto, etc.)
- Keep bundle sizes small
- Consider CPU time limits (50ms)
- Handle streaming for large data
46 changes: 46 additions & 0 deletions types/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Types Directory

This directory contains TypeScript type definitions and interfaces used throughout the application.

## Structure

```
types/
├── index.ts # Main export file for all types
└── [type files will be added here]
```

## Planned Type Definitions (to be implemented)

### Data Models

- `GistMetadata` - Metadata stored in R2 (unencrypted)
- `EncryptedData` - Structure of encrypted blob data
- `UserMetadata` - User-related metadata

### API Types

- `APIResponse` - Standardized API response format
- `APIError` - Error response structure
- Request/Response types for each endpoint

### Application Types

- `File` - Individual file in a gist
- `GistOptions` - Creation options (expiry, PIN, etc.)
- `BinaryFormat` - Binary encoding format structure

## Conventions

- Use `interface` for object shapes
- Use `type` for unions, aliases, and complex types
- Export all types from `index.ts` for easy imports
- Prefix enum values with the enum name
- Document complex types with JSDoc comments
- Avoid using `any` - use `unknown` if type is truly unknown

## Example Import

```typescript
import { GistMetadata, APIResponse } from "@/types";
```