A modern Anki-inspired flashcard application built with Next.js 15, featuring spaced repetition learning, multi-tenant organizations, and modern tooling.
- Spaced Repetition: Optimized learning intervals based on memory science
- Card Management: Create, edit, and organize flashcards in decks
- Study Sessions: Interactive learning with progress tracking
- Multi-format Cards: Support for text, images, and rich content
- Authentication: GitHub OAuth + Email/Password with NextAuth.js
- Multi-tenant: Organization-based deck sharing and collaboration
- Modern UI: Responsive design with shadcn/ui components
- Type Safety: End-to-end TypeScript with tRPC APIs
- Real-time Sync: Instant updates across devices
- Frontend: Next.js 15, React 19, TypeScript, Tailwind CSS
- Backend: tRPC, NextAuth.js, Prisma
- Database: PostgreSQL
- UI Components: shadcn/ui, Radix UI
- Email: Resend
- Dev Tools: ESLint, Prettier, TypeScript
- Node.js 20+ and pnpm
- Docker (for PostgreSQL)
- Git
git clone <your-repo-url>
cd anki
pnpm installCopy the example environment file:
cp .env.example .envRequired environment variables:
# Database
DATABASE_URL="postgresql://user:password@localhost:5432/myapp"
# NextAuth
AUTH_SECRET="your-secret-key"
NEXTAUTH_URL="http://localhost:3000"
# GitHub OAuth (optional)
AUTH_GITHUB_ID="your-github-client-id"
AUTH_GITHUB_SECRET="your-github-client-secret"
# Email (optional)
RESEND_API_KEY="your-resend-api-key"
EMAIL_FROM="noreply@yourdomain.com"Start PostgreSQL using Docker:
./start-database.shRun database migrations:
pnpm run db:generatepnpm run devOpen http://localhost:3000 in your browser.
./start-database.sh- Start PostgreSQL with Dockerpnpm run db:generate- Run Prisma migrations in developmentpnpm run db:migrate- Deploy Prisma migrations to productionpnpm run db:push- Push schema changes to databasepnpm run db:studio- Open Prisma Studio
pnpm run dev- Start development serverpnpm run build- Build for productionpnpm run start- Start production serverpnpm run preview- Build and start production server
pnpm run lint- Run ESLintpnpm run lint:fix- Run ESLint with auto-fixpnpm run typecheck- Run TypeScript type checkingpnpm run check- Run both linting and type checkingpnpm run format:check- Check code formattingpnpm run format:write- Format code with Prettier
pnpm run ui:add- Add new shadcn/ui components
src/
├── app/ # Next.js App Router
│ ├── (public)/ # Public routes (login, signup)
│ ├── (protected)/ # Protected routes (dashboard, account)
│ ├── api/ # API routes
│ └── layout.tsx # Root layout
├── components/ # React components
│ ├── ui/ # shadcn/ui components
│ └── ... # Custom components
├── lib/ # Utility functions
├── server/ # Server-side code
│ ├── api/ # tRPC routers
│ ├── auth/ # NextAuth configuration
│ └── db.ts # Database client
└── styles/ # Global styles
The application includes schemas for flashcard learning and multi-tenant organizations:
- User: User accounts with email/password and OAuth support
- Account: OAuth account connections (NextAuth)
- Session: User sessions (NextAuth)
- VerificationToken: Email verification tokens (NextAuth)
- Organization: Multi-tenant containers for shared decks and collaboration
- OrganizationMember: Organization membership with role management
- Deck: Collections of flashcards organized by topic
- Card: Individual flashcards with front/back content
- Study Session: Learning sessions with progress tracking
- Card Reviews: Spaced repetition algorithm data and performance metrics
- Sign up with email and password
- Password reset via email (using Resend)
- Account management
- Configure GitHub OAuth app
- Add credentials to
.env - One-click sign-in/sign-up
- Study Modes: Extend study sessions with new learning algorithms
- Card Types: Add support for cloze deletion, multiple choice, etc.
- Analytics: Implement learning progress and performance tracking
- Import/Export: Add Anki deck compatibility or CSV support
- Modify
prisma/schema.prismato add new entities - Run
pnpm run db:generateto apply changes - Create corresponding tRPC routers in
src/server/api/routers/
pnpm run ui:add button
pnpm run ui:add form
pnpm run ui:add card- Modify spaced repetition intervals in learning logic
- Implement different SRS algorithms (SM-2, SM-17, etc.)
- Add difficulty adjustments based on user performance
Ensure all production environment variables are set:
DATABASE_URL- Production PostgreSQL connectionAUTH_SECRET- Strong random secretNEXTAUTH_URL- Your production domain- OAuth credentials (if using)
RESEND_API_KEYandEMAIL_FROM(for emails)
pnpm run db:migratepnpm run build
pnpm run start- Fork the repository
- Create a feature branch
- Make your changes
- Run
pnpm run checkto ensure code quality - Submit a pull request

