Skip to content
SHIVAMYADAV25Public

About

Offline-first developer workspace for saving, organizing, and AI-explaining code snippets with React Native and Expo.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

Β 

History

4 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 

Repository files navigation

DevSnippets AI πŸš€

Offline-First Developer Workspace

A production-ready React Native + Expo mobile app for saving, organizing, managing, and AI-explaining code snippets β€” built for the Mobile Development Cohort.

UI SS


πŸ“± App Preview

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  HOME      SNIPPETS   FILES   EXPLAIN  SETTINGS β”‚
β”‚  ────       ──────    ─────   ───────  ──────── β”‚
β”‚  Dashboard  Browse    Folders  AI Chat  Config  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

5 Tab Screens Β· 7 Stack Screens Β· 4 Modals Β· 16 Packages Β· 4,247 lines of TypeScript


⚑ Quick Start

# 1. Unzip and enter project
unzip DevSnippets.zip && cd DevSnippets

# 2. Install dependencies
npm install

# 3. Start Expo dev server
npx expo start

# 4. Scan QR code with Expo Go (iOS / Android)

No configuration needed β€” the app seeds demo snippets on first launch so you can explore immediately.


πŸ—‚οΈ Project Structure

DevSnippets/
β”œβ”€β”€ App.tsx                          # Root: navigation + init + seeding
β”œβ”€β”€ app.json                         # Expo config (plugins, bundle ID)
β”œβ”€β”€ package.json
β”‚
└── src/
    β”œβ”€β”€ constants/
    β”‚   └── theme.ts                 # Colors, spacing, fonts, language/tag lists
    β”‚
    β”œβ”€β”€ types/
    β”‚   └── index.ts                 # All TypeScript interfaces
    β”‚
    β”œβ”€β”€ database/
    β”‚   └── SQLiteService.ts         # Full CRUD + WAL mode + all DB operations
    β”‚
    β”œβ”€β”€ services/
    β”‚   β”œβ”€β”€ AIService.ts             # Gemini / OpenAI / Claude + SecureStore
    β”‚   β”œβ”€β”€ FileService.ts           # expo-file-system/legacy wrapper
    β”‚   β”œβ”€β”€ ExportService.ts         # .txt / .js / .json export + sharing
    β”‚   └── PreferencesService.ts   # AsyncStorage wrapper
    β”‚
    β”œβ”€β”€ store/
    β”‚   └── useAppStore.ts           # Zustand global state
    β”‚
    β”œβ”€β”€ components/
    β”‚   β”œβ”€β”€ ui/
    β”‚   β”‚   β”œβ”€β”€ index.tsx            # Button, SearchBar, TagChip, EmptyState…
    β”‚   β”‚   └── StatCard.tsx         # Stats dashboard row
    β”‚   └── snippet/
    β”‚       β”œβ”€β”€ SnippetCard.tsx      # List card with lang badge + tags
    β”‚       └── CodeEditor.tsx       # Dark code viewer + line-numbered editor
    β”‚
    β”œβ”€β”€ screens/
    β”‚   β”œβ”€β”€ HomeScreen.tsx           # Dashboard
    β”‚   β”œβ”€β”€ SnippetsScreen.tsx       # Browse + search + filter
    β”‚   β”œβ”€β”€ FilesScreen.tsx          # Folder grid
    β”‚   β”œβ”€β”€ ExplainScreen.tsx        # AI action picker
    β”‚   β”œβ”€β”€ SettingsScreen.tsx       # Theme + AI key + storage
    β”‚   β”œβ”€β”€ CreateSnippetScreen.tsx  # New snippet form
    β”‚   β”œβ”€β”€ SnippetDetailScreen.tsx  # Full detail + actions
    β”‚   β”œβ”€β”€ EditSnippetScreen.tsx    # Edit form
    β”‚   β”œβ”€β”€ FavoritesScreen.tsx      # Starred snippets
    β”‚   β”œβ”€β”€ FolderBrowserScreen.tsx  # File list + move/delete/share
    β”‚   └── AIResultScreen.tsx       # Tabbed AI output
    β”‚
    └── utils/
        └── seedData.ts              # Demo snippet seeder (runs once)

πŸ—οΈ Architecture

UI Layer  (React Native screens + components)
      ↓
Store Layer  (Zustand β€” selectedSnippet, searchQuery, aiResult, settings)
      ↓
Service Layer
   β”œβ”€β”€ SQLiteService    β†’  expo-sqlite (WAL mode)
   β”œβ”€β”€ FileService      β†’  expo-file-system/legacy
   β”œβ”€β”€ AIService        β†’  Gemini / OpenAI / Claude + expo-secure-store
   β”œβ”€β”€ ExportService    β†’  .txt / .js / .json + expo-sharing
   └── PreferencesService β†’ @react-native-async-storage
      ↓
Storage Layer
   β”œβ”€β”€ SQLite           β†’  Snippets + Attachments + Exports
   β”œβ”€β”€ SecureStore      β†’  API Keys (encrypted)
   β”œβ”€β”€ AsyncStorage     β†’  Theme + Sort preferences
   └── FileSystem       β†’  Templates / Resources / Screenshots / Exports / Projects

πŸ—„οΈ Database Design

snippets

CREATE TABLE snippets (
  id         INTEGER PRIMARY KEY AUTOINCREMENT,
  title      TEXT    NOT NULL,
  language   TEXT    NOT NULL,
  code       TEXT    NOT NULL,
  tags       TEXT    DEFAULT '',      -- comma-separated e.g. "react,hooks,storage"
  favorite   INTEGER DEFAULT 0,       -- 0 = normal | 1 = starred
  created_at TEXT    DEFAULT (datetime('now')),
  updated_at TEXT    DEFAULT (datetime('now'))
);

attachments

CREATE TABLE attachments (
  id         INTEGER PRIMARY KEY AUTOINCREMENT,
  snippet_id INTEGER NOT NULL,
  file_path  TEXT    NOT NULL,
  file_name  TEXT    NOT NULL,
  file_type  TEXT    DEFAULT 'file',
  created_at TEXT    DEFAULT (datetime('now')),
  FOREIGN KEY(snippet_id) REFERENCES snippets(id) ON DELETE CASCADE
);

exports

CREATE TABLE exports (
  id         INTEGER PRIMARY KEY AUTOINCREMENT,
  snippet_id INTEGER,
  file_path  TEXT NOT NULL,
  format     TEXT NOT NULL,           -- 'txt' | 'js' | 'json'
  created_at TEXT DEFAULT (datetime('now'))
);

Storage optimisations:

  • WAL (Write-Ahead Logging) mode enabled for concurrent reads
  • ON DELETE CASCADE on attachments so deleting a snippet cleans up files
  • All queries use parameterised statements (no SQL injection risk)

πŸ“± Screens Reference

Tab Screens (5)

Screen Route Purpose
Home / Dashboard β€” live stats, recent snippets, quick actions
Snippets /snippets Full list with search, language filter chips, FAB
Files /files 5 coloured folder cards with item counts
Explain /explain AI action picker with online/offline status
Settings /settings Theme, AI provider, masked key management, storage

Stack Screens (7)

Screen Route Purpose
Create Snippet /snippet/new Form: title, language picker, tag chips, dark code editor
Snippet Detail /snippet/:id Code viewer, copy, export, share, explain, delete
Edit Snippet /snippet/:id/edit Pre-filled edit form
Favorites /favorites Filtered view of all starred snippets
Folder Browser /files/:folder File list with long-press actions
AI Result /ai/result Tabbed output: Overview / How It Works / Improvements

Modals (4)

Modal Trigger
Tag Picker "Add Tag" in Create/Edit
Export Format "Export" in Snippet Detail
Move File Long-press file β†’ "Move"
Delete Confirmation Delete button on snippet or file

πŸ€– AI Integration

Supported Providers

Provider Model Notes
Google Gemini ⭐ gemini-1.5-flash Free tier available β€” recommended
OpenAI gpt-4o-mini Requires paid account
Anthropic Claude claude-haiku-4-5 Requires paid account

Getting an API Key

Gemini (Free):

  1. Visit aistudio.google.com
  2. Click "Get API Key" β†’ "Create API Key"
  3. Copy the key

OpenAI:

  1. Visit platform.openai.com
  2. API Keys β†’ Create new secret key

Anthropic Claude:

  1. Visit console.anthropic.com
  2. API Keys β†’ Create Key

Adding Your Key in the App

  1. Open Settings tab
  2. Under AI β†’ tap your preferred provider
  3. Tap API Key row
  4. Paste your key β†’ Save Key

Keys are stored using expo-secure-store (AES-256 encrypted on device).

AI Actions

Action What it does
Explain Line-by-line breakdown + key concepts
Summarize 3–5 sentence purpose summary
Improve Numbered suggestions with code examples

πŸ“¦ Export Formats

Format Extension Content
Text File .txt Plain text with comment header (title, language, tags, date)
JavaScript .js JSDoc-commented JS file
JSON .json Structured object with all snippet fields

All exports are saved to DevSnippets/Exports/ folder and can optionally be shared via native share sheet.


πŸ—ƒοΈ File System Layout

{DocumentDirectory}/
└── DevSnippets/
    β”œβ”€β”€ Templates/      # Reusable code templates
    β”œβ”€β”€ Resources/      # Reference material
    β”œβ”€β”€ Screenshots/    # UI screenshots / diagrams
    β”œβ”€β”€ Exports/        # Auto-saved exported snippets
    └── Projects/       # Project-specific files

πŸ” Storage Technology Map

Technology Used For Why
expo-sqlite All snippet data (snippets, attachments, exports tables) Relational, offline, fast queries
expo-secure-store AI API keys AES-256 encrypted, hardware-backed on device
@react-native-async-storage Theme preference, sort order Lightweight key-value for non-sensitive prefs
expo-file-system All file operations across 5 folders Native FS access, no server needed

🌐 Offline Strategy

Works 100% Offline βœ…

  • Create, Read, Update, Delete snippets
  • Search and filter snippets
  • View favorites
  • File browsing and management
  • Export to local files

Requires Internet ⚑

  • AI explanation (Gemini / OpenAI / Claude API calls)

Offline Fallback

When no internet is detected:

  • Orange Offline badge appears on Explain screen
  • Generate button is disabled with clear visual feedback
  • Banner explains internet is required

🎨 Design System

Token Value Usage
primary #F97316 Buttons, active states, FAB
primaryBg #FFF7ED Tag chips, soft backgrounds
bg #FFFFFF Screen background
bgSecondary #F9FAFB Settings, input fields
textPrimary #111827 Headings, body
textSecondary #6B7280 Labels, subtitles
danger #EF4444 Delete actions, errors
success #22C55E Online badge, export success

Language badge colours are semantic per-language: TypeScript=blue, JavaScript=amber, Python=purple, Node.js=green, HTML=red, CSS=violet, etc.

Code editor uses VS Code Dark theme: #1E1E2E background, #E2E8F0 text.


πŸ“‹ Tech Stack

{
  "expo": "~56.0.8",
  "react-native": "0.85.3",
  "typescript": "~5.8.3",
  "@react-navigation/native": "^7.x",
  "@react-navigation/bottom-tabs": "^7.x",
  "@react-navigation/native-stack": "^7.x",
  "expo-sqlite": "~56.0.x",
  "expo-file-system": "~18.x",
  "expo-secure-store": "~14.x",
  "@react-native-async-storage/async-storage": "^2.x",
  "expo-sharing": "~12.x",
  "expo-clipboard": "~7.x",
  "zustand": "^5.x",
  "@expo/vector-icons": "^14.x",
  "@react-native-community/netinfo": "^11.x",
  "react-native-safe-area-context": "^5.x",
  "react-native-screens": "^4.x"
}

βœ… Evaluation Checklist

Core Features

  • Snippet CRUD β€” Create, Read, Update, Delete with full validation
  • Search β€” Full-text search across title, code, tags
  • Filter β€” Filter by programming language
  • Favorites β€” Star/unstar, dedicated favorites screen
  • Tags β€” Multi-select tag picker with chip display

Storage

  • SQLite β€” 3-table relational DB with WAL mode, parameterised queries
  • SecureStore β€” Encrypted API key storage
  • AsyncStorage β€” Theme + sort preferences
  • FileSystem β€” 5-folder structure, full file operations

File Management

  • Browse files across 5 folders
  • Move files between folders
  • Delete files with confirmation
  • Share files via native share sheet

AI

  • 3 AI providers (Gemini, OpenAI, Claude)
  • 3 actions (Explain, Summarize, Improve)
  • Offline detection + graceful fallback
  • Results in tabbed Overview / How It Works / Improvements layout
  • Copy / Save / Export AI results

Export & Sharing

  • Export as .txt
  • Export as .js
  • Export as .json
  • Native share sheet via expo-sharing
  • All exports saved to Exports folder

UI/UX

  • Orange primary theme matching design spec
  • Dark code editor with line numbers
  • Language badges with semantic colours
  • Smooth modal animations
  • FAB for quick snippet creation
  • Empty states with call-to-action
  • Pull-to-refresh on Home
  • Delete confirmation dialogs

Code Quality

  • TypeScript strict mode β€” 0 errors
  • No unused imports anywhere
  • All navigation targets registered
  • Zustand for clean global state
  • Reusable component library
  • Service layer cleanly separated from UI
  • Demo data seeded on first launch

πŸ› Known Limitations

  • Dark mode toggle in Settings is stored but doesn't yet switch the full app theme (light mode only in this version β€” foundation is in place via settings.theme)
  • File attachment to snippets stores paths in DB; the actual file picker (expo-document-picker) can be wired in as a bonus feature
  • AI result parsing into 3 sections (Overview / How It Works / Improvements) is heuristic-based and works best with well-structured AI responses

πŸŽ“ Submitted For

Mobile Development Cohort

  • Eval Period: May 31 – June 3, 2026
  • Tech: Expo Β· React Native Β· TypeScript

Built with ❀️ using Expo SDK 56 + React Native 0.85

About

Offline-first developer workspace for saving, organizing, and AI-explaining code snippets with React Native and Expo.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages