SNApp is a lightweight note-taking web application designed to replace a legacy AngularJS-based notes app.
Front-End:
- Next.js 16
- React 19
- TypeScript 5
- Chakra UI v3
- CodeMirror 6
- CSS Modules
- clsx
- nuqs
Back-End:
- Next.js (API routes and Server Actions)
- Prisma ORM with MySQL/MariaDB
- Better Auth for secure authentication
Testing & CI/CD:
- Vitest and React Testing Library for component testing
- Playwright for end-to-end testing
- GitHub Actions and Vercel for continuous integration and deployment
-
Clone the repository:
git clone https://github.com/SNApp-notes/web.git snapp cd snapp -
Install dependencies:
npm install
-
Configure environment variables:
Copy the example environment file and update with your values:
cp .env.example .env
Edit
.envand configure the following variables:Database Configuration (Required):
DATABASE_URL: MySQL/MariaDB connection stringDATABASE_URL="mysql://username:password@localhost:3306/snapp"
Better Auth Configuration (Required):
BETTER_AUTH_SECRET: Secret key for session encryption (generate withopenssl rand -base64 32)BETTER_AUTH_URL: Backend authentication URL (e.g.,http://localhost:3000)NEXT_PUBLIC_BETTER_AUTH_URL: Public-facing authentication URL (e.g.,http://localhost:3000)
GitHub OAuth (Required):
Create a GitHub OAuth app at https://github.com/settings/developers
- Set Authorization callback URL to:
http://localhost:3000/api/auth/callback/github - Configure the following variables:
GITHUB_CLIENT_ID: Your GitHub OAuth app client IDGITHUB_CLIENT_SECRET: Your GitHub OAuth app client secret
SMTP Configuration (Optional, for email verification):
SMTP_FROM_EMAIL: Sender email address (e.g.,[email protected])SMTP_HOST: SMTP server hostname (e.g.,smtp.gmail.com)SMTP_PORT: SMTP server port (e.g.,587for TLS)SMTP_USERNAME: SMTP authentication usernameSMTP_PASSWORD: SMTP authentication password
-
Set up the database:
Run Prisma migrations to create the database schema:
npx prisma migrate dev --schema ./prisma-main/schema.prisma
-
Run the development server:
npm run dev
Open http://localhost:3000 in your browser to view the application.
This project uses a comprehensive testing strategy with separate database configurations for different environments.
Two-Database Approach:
- Production/Development: MySQL/MariaDB (configured via
prisma-main/schema.prisma) - Testing: SQLite (configured via
prisma-e2e/schema.prisma)
The application automatically switches between databases based on NODE_ENV:
CI=test→ Uses SQLite (test.db)- Otherwise → Uses MySQL/MariaDB from
DATABASE_URL
Framework: Vitest + React Testing Library
Unit and integration tests use SQLite for fast, isolated testing without requiring MySQL setup.
Run tests:
# Run tests in watch mode
npm test
# Run tests once (CI mode)
npm run test:run
# Run tests with coverage report
npm run test:coverage
# Run tests with UI (requires @vitest/ui)
npm run test:uiKey Features:
- Automatic SQLite database setup and cleanup
- No manual database configuration required
- Fast test execution with in-memory operations
- Tests located next to source files (e.g.,
Component.test.tsx)
Framework: Playwright
E2E tests verify complete user workflows including authentication, note management, and UI interactions.
Local E2E Testing (Linux/macOS/Windows):
# Run E2E tests locally
npm run test:e2e
# Run E2E tests with Playwright UI for debugging
npm run test:e2e:uiRequirements:
- Playwright browsers installed (
npx playwright install) - Supported operating systems (Linux, macOS, Windows)
For Unsupported Systems (e.g., Fedora):
On systems where Playwright binaries are not available, use Docker for E2E testing with an isolated environment.
Setup:
-
Install Docker and Docker Compose on your system
-
Download Playwright Image (only once, even when modifiing docker config files)
npm run test:e2e:docker:setup
-
Build the Docker image (first time only, or after modifying Docker files):
npm run test:e2e:docker:build
This builds the Docker image with:
- Node.js runtime
- Playwright browsers (Chromium, Firefox, WebKit)
- All project dependencies
- Isolated SQLite test database
-
Run E2E tests in Docker:
npm run test:e2e:docker
Docker Architecture:
- Image: Ubuntu-based with Playwright dependencies pre-installed
- Database: Isolated SQLite database (
test.db) - Network: Isolated Docker network for secure testing
- Cleanup: Automatic container and volume cleanup after tests complete
When to Rebuild Docker Image:
# After modifying e2e/Dockerfile or e2e/docker-compose.yml
npm run test:e2e:docker:build
# After updating dependencies
npm run test:e2e:docker:buildDocker Configuration Files:
e2e/Dockerfile- Docker image definitione2e/docker-compose.yml- Container orchestratione2e/playwright.config.ts- Playwright configuration
In the project directory, you can run:
-
npm run devRuns the app in development mode. -
npm run buildBuilds the app for production using turbopack. -
npm run startRuns the built app in production mode. -
npm run lintLints the project using ESLint. -
npm run prettierFormats the code with Prettier. -
npm testRuns unit tests in watch mode using Vitest. -
npm run test:runRuns unit tests once (suitable for CI environments). -
npm run test:coverageRuns unit tests and generates a coverage report. -
npm run test:uiRuns unit tests with Vitest UI (requires @vitest/ui). -
npm run test:e2eRuns E2E tests locally with Playwright (not supported on Fedora). -
npm run test:e2e:uiRuns E2E tests with Playwright UI for debugging. -
npm run test:e2e:dockerRuns E2E tests in Docker (required for Fedora and other unsupported systems). -
npm run test:e2e:docker:buildRebuilds Docker image for E2E tests (run after modifying Docker files).
Copyright (C) 2025 Jakub T. Jankiewicz
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
