File size: 6,368 Bytes
9d4a3b0 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 | # LinkedIn professional network
LinkedIn is an independent, enterprise-deployable professional social network built as a local research replica of common professional-networking interaction patterns. It does not use LinkedIn branding, does not call LinkedIn APIs, and never requests LinkedIn credentials.
## Implemented scope
- Public homepage with original LinkedIn branding and neutral professional imagery
- Public Learning, Top Content, Games, and directory authwall routes from the observed public interaction matrix
- Local email/password registration with email verification and PBKDF2 password hashing
- HTTP-only database-backed sessions
- Dynamic feed, post composer, likes, comments, optimistic UI states, and API persistence
- Profile pages, experience data, profile editing API, relationship invitations, suggestions, and notifications
- Messaging inbox with conversation persistence endpoints
- Job search, detail view, API-confirmed saved jobs, application API, and recruiter job creation API with RBAC
- Company pages and company/job APIs
- Global search across people, jobs, companies, and posts
- LinkedIn Premium subscription surface backed by Stripe Checkout, Billing Portal, and signed webhooks in Test Mode
- Multi-tenant foundation through organizations, memberships, roles, tenant-scoped jobs, and audit logs
- Loading, empty, and error states across the app shell
- SQLite/D1 schema, migration SQL, deterministic demo seed data, tests, Docker, Nginx, Apache, systemd, health checks, and deployment preflight validation
## Stack
- Next.js 16 App Router + TypeScript + React 19
- Drizzle ORM + Cloudflare D1/SQLite
- Zod request validation
- Node crypto PBKDF2 password hashing
- Nodemailer transactional email adapter with a local development outbox
- Stripe server SDK for test-mode subscription checkout and webhook reconciliation
- Docker Compose with persistent SQLite, app, and Nginx reverse proxy
## Local development
```bash
npm install
export LINKEDIN_SQLITE_PATH=.data/linkedin.sqlite3
npm run db:migrate
npm run dev
```
Open `http://localhost:3000`.
The migration includes the deterministic `northstar-systems` tenant and demo Feed/Profile records. The TypeScript seeder remains available for idempotent reseeding:
```bash
LINKEDIN_SQLITE_PATH=.data/linkedin.sqlite3 npm run db:seed
```
For a local WebsiteBench-style registration check on port 3103:
```bash
LINKEDIN_SQLITE_PATH=.data/linkedin.sqlite3 \
DEFAULT_TENANT_SLUG=northstar-systems \
SESSION_SECRET=$(openssl rand -hex 32) \
SESSION_COOKIE_SECURE=false \
PUBLIC_CLONE_AUTH_MODE=local-dev \
PUBLIC_CLONE_AUTH_LOCAL_DEV_CODE=123456 \
PORT=3103 HOSTNAME=127.0.0.1 npm run start
```
Then open `http://127.0.0.1:3103/public-register` and use local verification code `123456`. Public deployment uses the authenticated `LINKEDIN_D1_PROXY_URL` bridge instead of a local database path.
Seeded test account:
```text
maya@example.com / LinkedInDemo123
```
## Validation
```bash
npm run typecheck
npm run lint
npm run build
npm test
npm run test:flow
npm run preflight -- --production
```
`npm run verify` runs the full validation sequence.
To run the database-backed registration journey after SQLite is initialized:
```bash
BASE_URL=http://localhost:3000 npm run test:e2e:registration
```
That E2E script registers a new account, consumes the local `.linkedin-mail` verification link when `EMAIL_DELIVERY_MODE=console`, creates a post, submits a job application, and checks the Premium guardrail. The main test suite also runs a real standalone production server against HTTP Redis/Resend and D1 mocks, then restarts it to verify session and post persistence.
## Docker deployment
```bash
docker compose up --build
```
Compose runs the one-shot SQLite `migrate` service against a persistent volume, then starts the app and Nginx. To rerun the migration job manually:
```bash
docker compose run --rm migrate
```
Open `http://localhost:8080` through Nginx.
## WebsiteBench public deployment
WebsiteBench public deployment is packaged separately in `sources/w2w_workflow/examples/linkedin-public`. That flow uses `/public-register`, `/api/auth/send-code`, `/api/auth/verify-code`, and the vendored `websitebench.public_clone_auth` runtime. It does not use the local SMTP/nodemailer registration path or require Stripe checkout for core validation; Stripe remains workflow-pending for public deployment until WebsiteBench provides an approved adapter.
## Environment
Required production values:
```bash
LINKEDIN_D1_PROXY_URL=http://d1.internal/linkedin-db
SESSION_SECRET=<32+ character random secret>
EMAIL_VERIFICATION_SECRET=<32+ character random secret>
SESSION_COOKIE_SECURE=true
APP_URL=https://linkedin.example.com
APP_ENV=production
DEFAULT_TENANT_SLUG=northstar-systems
EMAIL_DELIVERY_MODE=smtp
MAIL_FROM="LinkedIn <no-reply@linkedin.example.com>"
SMTP_HOST=<smtp host>
SMTP_PORT=587
SMTP_SECURE=false
SMTP_USER=<smtp user>
SMTP_PASS=<smtp password>
STRIPE_SECRET_KEY=<Stripe Test Mode secret key>
STRIPE_PREMIUM_PRICE_ID=price_...
STRIPE_WEBHOOK_SECRET=<Stripe Test Mode webhook signing secret>
```
Before promoting a release, run a strict deployment preflight with production environment values loaded:
```bash
npm run preflight -- --production
```
The preflight prints a sanitized JSON report. It checks the D1 proxy, session and email-verification secrets, HTTPS app URL, secure cookies, SMTP delivery, default tenant, and Stripe Test Mode configuration without printing secret values.
## Security boundary
- This project creates only local LinkedIn accounts.
- New local accounts must verify email before receiving a session.
- The login page explicitly states that it is not a LinkedIn sign-in.
- Billing code rejects non-test Stripe secret keys in this environment.
- No route asks for LinkedIn credentials, tokens, cookies, or profile export files.
- Mutating API routes reject cross-origin writes.
- Tenant write operations check membership role before creating recruiter-owned resources.
## Production hardening checklist
- Put D1 behind managed backup and restore drills.
- Run migrations in CI/CD before promoting a release.
- Add centralized logging and trace request IDs before accepting real user data.
- Add password reset, MFA, and rate limiting before public launch.
- Complete accessibility, privacy, and security review.
|