README.md and Wiki are under construction π·π§ποΈ
Table of contents
- Origin story
- App feature outline
- Notable project features
- The stack
- Environment variables
- Development
- Deployment
Hey there, welcome to the code-snippet-sharing project! It started as an attempt to create a full-stack setup based on the SvelteKit framework by creating a simple CRUD app. But I've enjoyed working with this stack so much, that the project quickly transformed into a kitchen sink regarding to the usage of supporting libraries and services. I still actively use it to experiment with SvelteKit and learn/test new tools (e.g. web analytics, error tracking, logging, monitoring, alerting).
When I was a less experienced dev, I always yearned for encountering a real-world example of a full-stack app with a complete support tooling setups (e.g. for unit tests, E2E tests, linting, CI/CD). CodebaseShow β RealWorld Example Apps initiative is very useful for taking inspiration regarding meeting common functional requirements, but it does not meet my requirements regarding the support tooling. I guess, in the end, I've created what I wanted myself :)
This project is a total overkill as an example of a simple CRUD app... But I think its individual parts/features or how they come together may prove useful to others (e.g. how to unit test SvelteKit app, how to create a Playwright E2E setup), so I've decided to publish it and document some stuff regarding it on a Wiki. Dig in and explore the codebase or Wiki at your pleasure (and risk)!
Authentication
- Sign in / Sign up via Google Sign in (anyone can create an account)
- Sign out
View all existing code snippets
- Available to all users (signed-in or signed-out)
- Filtering (current user)
- Sorting (creation date)
- Pagination
View code snippet's details
- Available to all users (signed-in or signed-out)
Create code snippet
- Available only to signed-in users
Edit code snippet
- Available only to code snippet's author
Delete code snippet
- Available only to code snippet's author
- Soft delete
π E2E testing via Playwright for main happy paths
π API testing via Playwright API testing for main happy paths
π§ͺ Unit tests via Vitest and Svelte testing library
π CI/CD using GitHub Actions and Northflank Pipelines
π§Ή Comprehensive linting setup
π Deployment via Northflank
π³ Ability to easily run the whole stack locally with different Dockerization levels
π Centralized app config
π¨ Centralized design token management
βοΈ Client works even without enabled JavaScript (with some exceptions)
π οΈ Maintenance mode enabled during deployments
π Smart redirects for signed-in/sign-out states
π’ Standardized user notifications
π« Comprehensive global error handling
π Configured graceful server shutdown
π©Ί Includes healthcheck API endpoint
π Responsive app UI
π¨βπ» Useful VSCode settings and extensions
π¬ A lot of helpful comments in the codebase
See Notable features Wiki page for more details.
See The stack Wiki page for more details.
See .env.template.
Development only
Used by Vite and Docker Compose.
Development and production
Build only
VITE_SENTRY_ORG- Sentry org slug
- Can be found in "Organization Settings" in the Sentry app
- Used to upload source maps for both server and client builds to Sentry via a Vite plugin
- Optional
VITE_SENTRY_PROJECT- Sentry project slug
- Used to upload source maps for both server and client builds to Sentry via a Vite plugin
- Optional
VITE_SENTRY_AUTH_TOKEN- Sentry auth token
- Can be found in "Auth tokens" in the Sentry app
- Used to upload source maps for both server and client builds to Sentry via a Vite plugin
- Optional
Backend only
ORIGIN- Node servers β’ Docs β’ SvelteKit
- Must be defined
MAINTENANCE_MODE- Enables maintenance mode (redirects all routes to
/maintenance) trueto enable, anything else to disable
- Enables maintenance mode (redirects all routes to
DATABASE_URL- Database connection string used by Prisma
- Must be defined
GOOGLE_OAUTH_APP_CLIENT_ID- Used for authentication with Google OAuth 2
- Must be defined
GOOGLE_OAUTH_APP_CLIENT_SECRET- Used for authentication with Google OAuth 2
- Must be defined
GOOGLE_OAUTH_APP_REDIRECT_URI- Where to redirect user after successful Google OAuth 2 authentication
- Must be defined
ROARR_LOG- Whether to show Roarr logs
- roarr/README.md at main Β· gajus/roarr
- Optional
- Values:
trueto enable, anything else to disable - Default: empty
ROARR_MIN_LOG_LEVEL- Minimal log level to display
- Optional
- Values:
trace,debug,info,warn,error,fatal - Default:
info
ROARR_SHOW_DEBUG_CONTEXT- Whether to show debug context information in logs
- Optional
- Values:
trueto enable, anything else to disable - Default: empty
ROARR_ACCESS_LOG- Whether to output HTTP access logs
- Optional
- Values:
trueto enable, anything else to disable - Default: empty
Backend and Frontend
PUBLIC_POSTHOG_PROJECT_API_KEY- Used for authenticating Posthog event requests
- Optional
- Find value in the related Posthog project
PUBLIC_POSTHOG_API_HOST- URL where to send Posthog events
- Optional
- E.g.
https://eu.posthog.comfor EU region
PUBLIC_SENTRY_ENVIRONMENT- Environment associated with sent Sentry requests
- Environments
- Optional
- Possible values
localhostfor local developmentstagingfor staging environmentproductionfor production environment
PUBLIC_SENTRY_DSN- URL where to send Sentry requests
- Basic Options
- Optional
PUBLIC_SENTRY_ORGANIZATION- Sentry organization slug (not name)
- Optional
PUBLIC_SENTRY_PROJECT_ID- Sentry project ID (number, not name)
- Optional
Software
- Node.js (see
package.jsonfor the minimum recommended version) - Docker
- Docker Compose
Setup
- Create and fill out values in
.env.localand.env.playwrightfiles- See Environment variables section and
.env.templatefile - NOTE:
.env.*.secretfiles serve the repository author's needs only π
- See Environment variables section and
npm cinpm run playwright:install:browsersnpm run playwright:install:dependencies
See Development β Setup and processes Wiki page for more details.
General development commands
npm run dev- Runs PostgreSQL via Docker Compose and app outside of it via
vite dev - Database is automatically migrated
- Seeds are not applied
- Runs PostgreSQL via Docker Compose and app outside of it via
scripts/stack/local/infra/stack-only/migrate.jsfor migrating already running PostgreSQL container./scripts/stack/local/infra/stack-only/seed.jsfor applying seeds- Apply seeds
Run unit tests
npm run test:unit:nodefor server testsnpm run test:unit:domfor client tests- Add
:coveragesuffix for generating coverage report
Run API/E2E tests
./scripts/stack/local/infra-app/playwright/api/ui.jsfor running API tests in UI mode./scripts/stack/local/infra-app/playwright/e2e/ui.jsfor running E2E tests in UI mode
Linting
npm run lint:fixfor running all linters and fixing auto-fixable linting errors
See Deployment β Setup and processes Wiki page for more details.