15 KiB
Lincodex architecture
Lincodex helps employers find candidates by skills and invite them to work. Candidates control profile publication and disclose selected contacts only after accepting an invitation. This document describes the current code; limitations are listed separately.
Components
Browser -> Nginx -> Go API -> PostgreSQL
| -> Redis
| -> SeaweedFS
| -> outbox -> Kafka -> consumers
| -> scheduled jobs -> ML service
| -> practice queue -> runner VM
| Component | Responsibility |
|---|---|
frontend/ |
React, TypeScript, Vite: public pages and candidate and company workspaces |
backend/ |
Go, chi, Clean Architecture: authorization, profiles, assessment, matching, invitations and background loops |
ml/ |
Python/FastAPI: embeddings for semantic matching in a separate process |
runner/ |
Go: program judging in an isolated environment outside the core application |
labd/ |
Network lab provisioner foundation; its user flow is not connected yet |
api/ |
Shared OpenAPI contracts for core, ML, runner and labd |
deploy/, observability/ |
Compose, Nginx, releases and a separate monitoring stack |
The main deployment is one application node with Docker Compose. ML and code execution can run separately. The current implementation does not need Kubernetes or a separate vector database.
Go backend
cmd/app/main.go calls bootstrap.Run(). Bootstrap reads backend/config/, assembles dependencies, applies migrations and manages HTTP servers and workers. Wire generates dependency wiring during development; there is no runtime DI container.
Directory under backend/ |
Purpose |
|---|---|
internal/domain/ |
Types, states and business rules, with files directly in the package |
internal/usecase/ |
Application flows and transaction coordination |
internal/port/ |
Inbound and outbound interfaces |
internal/adapter/primary/http/ |
router.go, middleware, generated api/ and v1/ handlers |
internal/adapter/primary/cli/ |
Operator commands |
internal/adapter/secondary/ |
PostgreSQL, Redis, SeaweedFS, Kafka, ML, mail and Prometheus |
internal/worker/ |
Relay, consumers, scheduled jobs, mail and the practice queue |
internal/bootstrap/ |
Application composition and lifecycle |
pkg/ |
Shared technical helpers without product logic |
db/, codegen/ |
Migrations, SQL queries and generator configuration |
HTTP translates DTOs into usecase commands. Usecases depend on domain and ports; bootstrap supplies their implementations. SQL, ML and HTTP handlers do not decide who may see contacts. Workers call application flows instead of replacing them.
API and background loops share a process but use separate bounded PostgreSQL pools. Workers can become a separate process later without moving business rules.
Contracts and code generation
OpenAPI 3.2.0 specifications are split into routes/ and components/ under api/core/, api/ml/, api/runner/ and api/labd/. Bundling combines source YAML files. Compatibility checks cover the features in use, not the entire OpenAPI specification.
- ogen generates Go servers and internal clients; chi mounts the public server under
/api/v1. - Orval generates the frontend client, TanStack Query hooks, Zod schemas and MSW handlers under
frontend/src/shared/api/. - datamodel-code-generator produces the ML Pydantic models.
- sqlc generates code from SQL under
adapter/secondary/postgres/sqlc/; mockery generates selected mocks. - Generator configuration belongs to the component that consumes its output.
From the root, run make generate, then make check-generated. Change source contracts together with their consumers; never edit generated files manually. An operation in a contract is not proof of implementation: unconnected operations return 501.
Storage and background work
PostgreSQL owns business state, server sessions, consent history, policy versions, jobs and the outbox. Goose applies embedded migrations under a lock before listeners open; a failure stops startup. Startup migrations require DDL privileges for the configured database role.
Redis provides caching and technical limits, not a queue or a source of business permissions. Core Compose does not persist its data. Losing Redis must not restore revoked access; an unavailable limiter refuses the protected operation.
Product policy versions hold deadlines, quotas, assessment and matching rules. Published versions are immutable; attempts pin their versions while access always checks current permissions. Initial seeding supplies a demonstration policy, not a configured full product.
Private file storage
The SeaweedFS secondary adapter uses AWS SDK for Go v2 for S3. It can read, write and delete objects; user-facing resume import and delivery are not connected yet.
Only backend and Prometheus join the storage network. S3 keys remain on the server, and Nginx does not expose objects directly. Some internal SeaweedFS interfaces do not enforce S3 authentication, so the network remains the primary boundary. One volume provides neither HA nor an external backup.
Events, jobs and mail
- A usecase writes its state change and outbox event in one PostgreSQL transaction.
- The relay publishes to Kafka and marks acknowledged records. At-least-once delivery permits duplicates.
- Consumers apply events idempotently; retries and failures must not create a second product action.
- Scheduled jobs use leases, delayed retries and persisted state. Network calls stay outside user HTTP transactions.
Mail uses delivery records and separate sender loops. resend and disabled are connected; SMTP is not implemented. Service mail retains reserved quota, and notifications recheck recipient rights before sending. An unknown sending outcome must be accounted for instead of blindly retried. The inbox is populated separately from the invitation-delivered event.
Events carry minimal identifiers and facts without contacts or secrets; logs exclude secrets and personal data. Mail contains only data allowed for its recipient; a verification message includes the required one-time link and code. See DEPLOYMENT.md for startup and configuration.
Identity, FSP, and privacy
Login uses email/password, Argon2id and PostgreSQL sessions. Email can be verified by link or code. The __Host-lincodex_session cookie is Secure, HttpOnly and SameSite=Strict; mutations check Origin, and protected operations also check session-bound CSRF. The identity secret must remain consistent across instances and restarts.
| Consent | Purpose |
|---|---|
| C1 | Basic account data processing |
| C2 | Profile publication for organizations |
| C3 | Automated categorization |
| C4 | Selected contacts for a specific organization |
| C5 | Import of FSP results |
Consent texts and records are versioned. Built-in texts are marked demo; real data requires the actual operator's texts and processing terms. Consent records alone do not establish legal compliance.
Profiles are closed by default. Organizations receive an allowed anonymous projection only with active C2, publication and no organization hiding. Small-cohort rules generalize fields and withhold cards when an anonymous group cannot be formed. Names, contacts and private profile text are excluded.
Accepting an invitation with C4 creates a grant for selected fields and one candidate-organization pair. Every read checks current rights. Revoking C4/C2, closing publication or hiding the company stops access; publishing again does not revive an old grant.
Organization operations check membership on the server. Search, invitations and contact access currently require the owner; other roles must not be treated as connected. Companies with one founder share the E0 quota pool.
FSP ID and real FSP data are not integrated. Manual profiles and tests do not depend on them. A future integration needs an official provider contract; a manually entered ID or matching email does not prove external identity.
Company quotas
The current demo policy uses sliding limits: E0 gets 10 invitations per 7 days and 50 distinct cards per 24 hours; E1 gets 40 and 150. E2 has 100 and 400 but is disabled until company verification is connected; E3 cannot reserve quota. The database supplies the level, not the client.
Sending consumes quota; drafting does not. Repeating an invitation consumes no second slot; decline, acceptance and expiry free the pending-invitation limit but do not refund weekly quota. Repeated views of one candidate by one company within the window are free. A record exactly on the window boundary has expired.
E0 companies founded by one account share the holding pool; E1 and higher companies have their own. Two companies in one holding viewing the same candidate consume two slots. A promoted company's usage leaves the E0 pool. Holding merges and splits are not implemented.
After permission checks, companyquota reserves quota in the same transaction as the business action. Lock order is company, holding for E0, membership, invitation/visibility, then usage. A changed policy or trust snapshot requires reloading and retrying the whole transaction. Refusals record no usage; RetryAt indicates the next slot release.
Deleting an invitation does not remove its usage record; cleaning old views does not change logical window boundaries. The holding migration refuses rollback while a holding contains several companies. See TESTING.md for concurrency and retry checks.
Assessment and grade verification
The bank stores immutable family versions, rubrics, variant generators and review metadata. A version and seed reproduce the variant; answer keys stay on the server. Publishing families and opening categories are operator actions.
An attempt pins its policy, bank, items and deadlines. Answers are persisted on the server; versions and idempotency protect against duplicate writes and concurrent completion. Attempts, results and skill evidence are distinct from candidate self-assessment.
The current full mode, demo_basic, uses a synthetic bank rather than an adaptive psychometric model. Category assignment requires enabled demonstration categories and an attested opening; the API basis is synthetic_demo, without calibration. The demo_express mode assigns no grade, category or evidence.
Server and browser signals, watermarks and a manual-review band help investigate suspicious cases. They do not prove cheating, change a grade automatically or provide screen or camera recordings.
Code runner
Backend persists practice submissions and queue state, limits load and calls the runner through TLS with a separate token. The runner judges Go/Python programs in nsjail with process, memory, CPU and time limits; submitted programs have no network. The production boundary is a dedicated VM, not a privileged container on the application node.
Without CODE_RUNNER_URL, practice execution is unavailable and never treated as a successful judgment. A runner and queue do not imply a calibrated course or an open category: the relevant bank is still required. Network labs have a contract and labd foundation, but the provisioner is not connected to the backend user flow.
Matching and explanations
Go selects only visible cards, applies hard constraints and ranks within main, near and unconfirmed groups. A claimed grade does not replace a confirmed grade. Explanations use the same components that determined the order and identify unknown values.
Baseline matching works without a model. Missing suitable vectors leave a neutral semantic contribution (0.5, with ml_unavailable). Small cohorts cannot supply reliable percentiles. A scoring formula does not demonstrate matching quality on real candidates.
The semantic layer is enabled separately: background jobs encode the allowed candidate projection and current company requirements. Search reads stored vectors with matching versions and hashes; it makes no synchronous ML request. PostgreSQL stores vectors; policy versions hold ensemble and calibration parameters.
ML supports Giga-Embeddings-instruct-480M and Qwen3-Embedding-0.6B. Lockfiles pin locally loaded weights; fake is for tests. Contacts and private profile text are not sent. Public GitHub repository checks are enabled separately and use only the allowed GitHub API. Generative resume analysis is not implemented.
Frontend
FSD separates app, pages, widgets, features, entities and shared. TanStack Query holds server state, local forms hold drafts, and React Router owns navigation. Styling uses CSS Modules and CSS variables. Vite builds static assets for Nginx; production does not need a Node server.
The API wrapper sends cookies, adds CSRF and decodes contract errors. Account changes clear private caches. MSW supports tests; Playwright exercises the real backend path. Hiding a button does not replace server authorization.
Operations and validation
Nginx serves the SPA and proxies /api/v1/. Internal /readyz, /metrics and administration interfaces are not public. Client addresses are accepted only through trusted proxies; external headers are not evidence of client identity.
Grafana, Prometheus, Loki and Alloy run in a separate Compose project. Configuration collects metrics and logs; alert rules do not mean notifications are configured. ML also requires bearer authentication for /metrics; the current ML scrape still needs authentication configuration. A browser telemetry receiver does not imply an installed frontend SDK.
Run make docs-check and the component, integration and E2E targets in TESTING.md. Earlier results do not certify a new checkout. Releases record images and configuration in local manifests; restoration and checks are described in DEPLOYMENT.md.
Matching quality needs a baseline/model comparison on labeled data and a report with sample size. Synthetic test-retest repeats the same profile with different items and measures agreement; it does not establish human validity. Team deadlines and limits must not be presented as measured results or organizer requirements.
Limitations and next steps
- Adaptive assessment, subject-matter bank calibration and independent quality evaluation remain separate work.
- Resume import/analysis, standardized PDF, live FSP ID and ATS are not connected.
- Contract operations for salary increases, invitation withdrawal/cancellation and network labs return 501; full negotiation and interviews are not ready.
- Hiring-need requirement versions are retained, but persisted search-result snapshots are not implemented.
- Single-node PostgreSQL, Kafka and SeaweedFS do not provide high availability; verified backups and restoration procedures are needed.
- Access rules and scanners need current checks. A tool list is not an audit report or evidence of successful deployment.
See DEPLOYMENT.md for demo startup and the scenario, TESTING.md for acceptance, and SECURITY.md for security rules.