Skip to content

Tonyzxch/TraceOJ

Repository files navigation

TraceOJ

Next.js TypeScript Tailwind CSS Prisma SQLite Vitest

TraceOJ is a local-first OJ knowledge base for organizing solutions, notes, relations, and review plans.

It focuses on long-term practice workflow instead of one-time note dumping.

✨ Overview

  • Multi-platform import from local folders
  • Filename-driven metadata parsing and normalization
  • Problem tagging, status tracking, and review flags
  • Relation modeling for similar/equivalent/path links
  • Dedicated review queue with review logs
  • Dashboard snapshots for practice history

πŸš€ Core Features

πŸ“š Problem Management

  • Store platform, IDs, title, source file path, rendered content, notes, tags, status, review fields, and timestamps
  • View and edit metadata from problem detail pages
  • Keep all records in a normalized relational schema

βš™οΈ Import Pipeline

  • Recursive directory scanning
  • Platform auto-detection
  • Filename parsing rules per platform
  • Incremental upsert by platform + originalId
  • Import logs with success/update/skip/failure counts

πŸ”— Relation Parsing

Current LeetCode filename rules support:

  • - for learning path / sequence
  • ~ for similar problems
  • == for equivalent problems
  • multiple parentheses in one filename
  • non-numeric IDs such as LCR131

πŸ“ Review Workflow

  • Mark any problem into review queue
  • Record review actions through review logs
  • Keep extensible fields for future spaced-repetition strategies

🧱 Tech Stack

  • Next.js 16 App Router
  • TypeScript
  • Tailwind CSS
  • Prisma
  • SQLite
  • React Markdown + highlight.js
  • Vitest

🌍 Supported Platforms

  • LeetCode
  • Luogu
  • ...

Parser architecture is extensible and ready for additional platforms.

πŸ—‚οΈ Project Structure

TraceOJ
β”œβ”€ app
β”‚  β”œβ”€ dashboard
β”‚  β”œβ”€ import
β”‚  β”œβ”€ login
β”‚  β”œβ”€ problems
β”‚  β”‚  └─ [id]
β”‚  β”œβ”€ review
β”‚  β”œβ”€ sequences
β”‚  β”œβ”€ globals.css
β”‚  β”œβ”€ icon.svg
β”‚  β”œβ”€ layout.tsx
β”‚  └─ page.tsx
β”œβ”€ components
β”œβ”€ examples
β”‚  └─ import-demo
β”œβ”€ lib
β”‚  β”œβ”€ actions
β”‚  β”œβ”€ data
β”‚  └─ parsers
β”œβ”€ prisma
β”‚  β”œβ”€ init.sql
β”‚  β”œβ”€ schema.prisma
β”‚  └─ seed.ts
β”œβ”€ scripts
β”‚  └─ import-problems.ts
β”œβ”€ tests
β”‚  └─ leetcode-parser.test.ts
β”œβ”€ .env.example
β”œβ”€ package.json
└─ README.md

πŸ›’οΈ Database Model

Main tables:

  • Problem
  • Tag
  • ProblemTag
  • ProblemRelation
  • SequenceGroup
  • SequenceItem
  • ImportLog
  • ReviewLog

Important design decisions:

  • Problem.originalId is a string, not an integer
  • Placeholder problems can be created for unresolved references
  • Relation types include similar, equivalent, and manual
  • Sequence data is stored separately from pairwise relations

πŸ› οΈ Quick Start

1. πŸ“¦ Install dependencies

npm install

2. πŸ” Create environment file

Create .env from .env.example.

Example:

DATABASE_URL="file:./dev.db"
AUTH_SECRET="change-this-secret"
ADMIN_PASSWORD="your-password"

3. 🧬 Initialize database

npm run db:generate
npm run db:init

4. 🌱 Seed example data

npm run db:seed

5. ▢️ Start development server

npm run dev

Then open:

πŸ“₯ Import Local Notes

Import from your local problem directory:

npm run import-problems -- "D:/oj-notes"

Use the sample directory:

npm run import-problems -- "examples/import-demo"

πŸ’» Development Commands

npm run dev
npm run import-problems -- "examples/import-demo"

βœ… Test And Build

npm run test
npm run lint
npm run build

🧭 Roadmap

  • More platform parsers
  • Better review scheduling
  • Richer relation graph views
  • Full-text search
  • Bulk editing for status and tags
  • Export to Markdown / JSON

🀝 Contributing

Issues and pull requests are welcome. For larger changes, open an issue first to discuss scope and design.

About

πŸ›€οΈ TraceOJ: A personal problem-solving archive for local notes, learning paths, and review queues across OJ platforms

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors