|
1 | 1 | # Patchwork |
2 | 2 |
|
3 | | -AT Protocol-native mutual aid platform with a web client, query API, ingestion/indexing pipeline, and moderation worker. |
| 3 | +Patchwork is a full-stack mutual aid platform built on the AT Protocol. It serves as a portfolio project that demonstrates practical product engineering across frontend, backend, data flow, moderation, testing, and deployment. |
4 | 4 |
|
5 | | -This monorepo is designed for fast local development with deterministic fixtures, strong type contracts, and CI quality gates. |
| 5 | +## What this project demonstrates |
6 | 6 |
|
7 | | -## What’s in this repo |
| 7 | +- Building a **TypeScript monorepo** with shared contracts across multiple services |
| 8 | +- Delivering a **React + Vite + Tailwind** web experience backed by Node.js services |
| 9 | +- Designing **API, indexing, and moderation workflows** for a trust-aware platform |
| 10 | +- Using **Vitest, Playwright, and CI quality gates** to keep changes reliable |
| 11 | +- Shipping with **Docker, PostgreSQL, and production-minded deployment patterns** |
8 | 12 |
|
9 | | -- `apps/web` — Vite + React + TypeScript + Tailwind frontend |
10 | | -- `services/api` — HTTP API for query/chat/volunteer flows |
11 | | -- `services/indexer` — ingestion + indexing service |
12 | | -- `services/moderation-worker` — moderation/trust-safety worker |
13 | | -- `packages/shared` — shared contracts, config/env schemas, utilities |
14 | | -- `packages/at-lexicons` — AT lexicon schemas, fixtures, and validators |
| 13 | +## Technical strengths |
15 | 14 |
|
16 | | -## Patchwork component naming |
| 15 | +- **Frontend:** React 19, Vite, Tailwind CSS, TypeScript |
| 16 | +- **Backend:** Node.js services for API, indexing, and moderation |
| 17 | +- **Architecture:** Shared packages, typed schemas, deterministic fixtures, service boundaries |
| 18 | +- **Quality:** Unit tests, browser E2E tests, type checking, linting, automated CI |
| 19 | +- **Operations:** Dockerized builds, health checks, deployment workflow, security scanning |
17 | 20 |
|
18 | | -- **Patchwork Web** — client (`patchwork-web`) |
19 | | -- **Patchwork API** — query + auth (`patchwork-api`) |
20 | | -- **Spool** — ingestion + queueing (`patchwork-spool`) |
21 | | -- **Quilt** — indexing + search layer (network alias on `patchwork-spool`: `patchwork-quilt`) |
22 | | -- **Stitch** — chat service (network alias on `patchwork-api`: `patchwork-stitch`) |
23 | | -- **Thimble** — moderation worker (`patchwork-thimble`) |
| 21 | +## Why it matters |
24 | 22 |
|
25 | | -## Tech stack |
| 23 | +This project demonstrates building polished user-facing experiences, backing them with well-structured services, and supporting them with strong testing and operational discipline. It reflects hands-on experience with modern JavaScript tooling, systems thinking, and product-focused delivery. |
26 | 24 |
|
27 | | -- Node.js + TypeScript (monorepo workspaces) |
28 | | -- React + Vite + Tailwind (web) |
29 | | -- Vitest + Playwright (unit + browser E2E) |
30 | | -- Optional local Postgres for API datasource mode |
| 25 | +## Repository overview |
31 | 26 |
|
32 | | -## Prerequisites |
| 27 | +- `apps/web` — frontend application |
| 28 | +- `services/api` — query, chat, and volunteer flow APIs |
| 29 | +- `services/indexer` — ingestion and indexing pipeline |
| 30 | +- `services/moderation-worker` — moderation and trust-safety workflows |
| 31 | +- `packages/shared` — shared contracts, configuration, and utilities |
33 | 32 |
|
34 | | -- Node.js `>=20.19.0` |
35 | | -- npm |
36 | | -- Docker (only needed for Postgres mode) |
37 | | - |
38 | | -## Quick start |
39 | | - |
40 | | -1. Install dependencies: `npm ci` |
41 | | -2. Create local env file: copy `.env.example` → `.env` |
42 | | -3. Start the app surfaces you need: |
43 | | - - Web: `npm run dev:web` |
44 | | - - API: `npm run dev:api` |
45 | | - - Indexer: `npm run dev:indexer` |
46 | | - - Moderation worker: `npm run dev:moderation` |
47 | | - |
48 | | -Default local URLs: |
49 | | - |
50 | | -- Web: `http://localhost:5173` |
51 | | -- API health: `http://localhost:4000/health` |
52 | | -- Indexer health: `http://localhost:4100/health` |
53 | | -- Moderation health: `http://localhost:4200/health` |
54 | | - |
55 | | -## API datasource modes |
56 | | - |
57 | | -The API supports two datasource modes: |
58 | | - |
59 | | -- `fixture` (default): deterministic in-memory data for local development |
60 | | -- `postgres`: local DB-backed mode for integration testing |
61 | | - |
62 | | -### Postgres mode |
63 | | - |
64 | | -1. Start Postgres: `npm run db:up` |
65 | | -2. Set in `.env`: |
66 | | - - `API_DATA_SOURCE=postgres` |
67 | | - - `API_DATABASE_URL=postgresql://patchwork:patchwork@localhost:5432/patchwork` |
68 | | -3. Seed deterministic data: `npm run db:seed` |
69 | | -4. Start API in postgres mode: `npm run dev:api:postgres` |
70 | | - |
71 | | -### DB-backed frontend mode (Map / Feed / Resources / Posting) |
72 | | - |
73 | | -The web client now calls API routes directly for discovery + posting surfaces: |
74 | | - |
75 | | -- `GET /query/map` |
76 | | -- `GET /query/feed` |
77 | | -- `GET /query/directory` |
78 | | -- `GET /aid/post/create` |
79 | | - |
80 | | -Recommended local flow: |
81 | | - |
82 | | -1. Start Postgres: `npm run db:up` |
83 | | -2. Seed Postgres: `npm run db:seed` |
84 | | -3. Start API in postgres mode: `npm run dev:api:postgres` |
85 | | -4. Start web: `npm run dev:web` |
86 | | - |
87 | | -In the UI, route headers show a data source badge: |
88 | | - |
89 | | -- **DB-backed API** when remote query succeeds |
90 | | -- **Fallback dataset** when API is unavailable (network-safe local fallback) |
91 | | - |
92 | | -Posting behavior in DB mode: |
93 | | - |
94 | | -- `Publish request` calls `GET /aid/post/create` |
95 | | -- On success, the created post is inserted into Postgres and becomes immediately queryable via `/query/feed` and `/query/map` |
96 | | - |
97 | | -Additional seed scripts (API workspace): |
98 | | - |
99 | | -- Append mode: `npm run db:seed:append -w @patchwork/api` |
100 | | -- Phase 3 fixtures only: `npm run db:seed:phase3 -w @patchwork/api` |
101 | | - |
102 | | -Stop Postgres when done: `npm run db:down` |
103 | | - |
104 | | -## Common commands |
105 | | - |
106 | | -- Lint: `npm run lint` |
107 | | -- Typecheck: `npm run typecheck` |
108 | | -- Unit tests: `npm run test` |
109 | | -- Moderation/privacy regression suite: `npm run test:phase7` |
110 | | -- End-to-end contract flow: `npm run test:phase8-e2e` |
111 | | -- Browser E2E (web): `npm run test:e2e -w @patchwork/web` |
112 | | -- Build all workspaces: `npm run build` |
113 | | -- Combined local gate: `npm run check` |
114 | | - |
115 | | -## Docker deployment (shared `web` network) |
116 | | - |
117 | | -The production compose stack is defined in `docker-compose.yml`. |
118 | | - |
119 | | -- Caddy route host: `https://patchwork.subcult.tv` |
120 | | -- Shared Docker network: `web` (external) |
121 | | -- Internal service network: `internal` |
122 | | - |
123 | | -Services: |
124 | | - |
125 | | -- `patchwork-web` (nginx serving built Vite app) |
126 | | -- `patchwork-api` |
127 | | -- `patchwork-spool` (also aliased as `patchwork-quilt`) |
128 | | -- `patchwork-thimble` |
129 | | -- `patchwork-postgres` |
130 | | - |
131 | | -Monitoring: |
132 | | - |
133 | | -- Prometheus scrapes `/metrics` from API, Spool, and Thimble jobs via the shared network. |
134 | | - |
135 | | -## Architecture and protocol docs |
136 | | - |
137 | | -- `docs/architecture/domain-map.md` |
138 | | -- `docs/architecture/service-boundaries.md` |
139 | | -- `docs/architecture/adr/0001-v1-stack-and-domain-boundaries.md` |
140 | | -- `docs/at-protocol/README.md` |
141 | | -- `docs/at-protocol/identity-session.md` |
142 | | -- `docs/at-protocol/lexicon-versioning.md` |
143 | | -- `docs/at-protocol/tombstone-contract.md` |
144 | | -- `docs/quality-gates.md` |
145 | | - |
146 | | -## Notes for contributors |
147 | | - |
148 | | -- Keep cross-service contracts in `packages/shared`. |
149 | | -- Prefer deterministic fixtures in tests. |
150 | | -- Treat geoprivacy/moderation regressions as release blockers. |
| 33 | +For deeper architecture details, see `docs/architecture`. |
0 commit comments