Skip to content

Architecture

Zuko Gutyungwa edited this page Aug 20, 2026 · 19 revisions

Architecture

Component view

flowchart TB
    subgraph Client["Client Layer"]
        FE["React Frontend"]
    end

    subgraph App["Application Layer (Spring Boot)"]
        API["REST API / Controllers"]
        AUTH["Auth Module (JWT + BCrypt)"]
        SCAN["Scan Service"]
        ENGINE["Scanner Engine (Passive Checks)"]
        SCORE["Scoring Service"]
        REPORT["Report Service (PDF)"]
    end

    subgraph Data["Data Layer"]
        DB[("PostgreSQL")]
        FLYWAY["Flyway Migrations"]
    end

    subgraph Infra["Cloud / Infra Layer"]
        DOCKER["Docker / Docker Compose"]
        CI["GitHub Actions CI/CD (build, test, SAST, SCA)"]
        TF["Terraform (IaC)"]
        K8S["Kubernetes Manifests"]
        MON["Monitoring (Prometheus/Grafana or Logs)"]
    end

    FE -->|HTTPS/JWT| API
    API --> AUTH
    API --> SCAN
    SCAN --> ENGINE
    SCAN --> SCORE
    SCAN --> REPORT
    SCAN --> DB
    FLYWAY --> DB

    DOCKER -.->|packages| App
    CI -.->|builds & scans| App
    TF -.->|provisions| K8S
    K8S -.->|runs| App
    MON -.->|observes| App
Loading

Of the infra layer, DOCKER, CI, TF, and K8S are implemented so far, MON is still just the target design (see the Build Plan for when it lands). As of Day 3, infra/docker/Dockerfile (multi-stage, built with the repo's own mvnw) and infra/docker-compose.yml (Postgres 16 + the app) exist and are verified working: docker compose up --build boots both containers, and the Day 2 migration applies cleanly against the real database. This remains the only piece of infra actually run and fully verified end to end, see Infrastructure as Code below for the important distinction between this and TF/K8S.

Infrastructure as Code

As of Day 18 (PR #53): baseline, documentation-grade Terraform and Kubernetes manifests, proving IaC/orchestration understanding for the Cloud Computing elective without needing a live AWS account or cluster, stated plainly in infra/README.md rather than left implied. Unlike the Docker Compose setup above, none of this has actually been applied anywhere, that distinction matters and is called out explicitly rather than glossed over.

infra/terraform/ (main.tf, variables.tf, outputs.tf) is scoped to what this project's own architecture actually needs, not a generic template: an ECR repository for the image infra/docker/Dockerfile already builds, and an RDS PostgreSQL instance matching the postgres:16-alpine engine already used locally. db_password has no default, must be supplied via TF_VAR_db_password, the same "no secrets committed to the repo" rule application.properties already follows for sentinel.jwt.secret. Deliberately excludes a from-scratch VPC and an EKS cluster, disproportionate additional state for a documentation-grade baseline. terraform fmt, init, and validate all pass against the real AWS provider (~> 5.0), verified with a real, locally installed Terraform CLI rather than assumed correct from hand-written HCL.

infra/k8s/ (deployment.yaml, service.yaml) runs the same image on any Kubernetes cluster, not necessarily one Terraform itself provisioned. 2 replicas is a direct, deliberate consequence of ADR 0003's stateless API decision, costs nothing to be true since no shared session store exists to worry about. Readiness and liveness probes target /v3/api-docs, public and unauthenticated since Day 17, no new dependency like Spring Actuator needed just to have something to probe. Secrets are sourced from an out-of-band sentinel-secrets Secret that is not created or committed here, the concrete mitigation path for finding I-2 in the threat model (the JWT secret's dev-only fallback). The Service is ClusterIP only, no Ingress or TLS termination exists yet anywhere in this project (finding T-1 in the threat model), not solved here just to have something externally reachable.

No live cluster existed to run kubectl's own dry-run against (it needs a reachable API server even in client mode), so the manifests were parsed and structurally checked with PyYAML instead, and cross-checked by hand against the fields each resource actually needs.

Deployment, cloud architecture, and monitoring

As of Day 19 (PR #54), three documents in docs/ round out the Cloud Computing elective's paper trail, each written to stand on its own for anyone reviewing infra/ without also reading backend/-side detail:

  • docs/CLOUD_ARCHITECTURE.md: states plainly, in a table, which parts of the stack are actually live and verified (Docker Compose, this local dev setup) versus documentation grade only (the Terraform and Kubernetes work from Infrastructure as Code above). Includes a target architecture diagram with the still-missing pieces (an Ingress/TLS layer, a CI deploy stage) drawn as dotted lines rather than implied complete, and a section mapping specific threat model findings (T-1, I-2, D-1) to exactly which piece of the cloud architecture would close each one.
  • docs/DEPLOYMENT.md: concrete steps for both deployment modes, an environment variable reference table, and the results of Day 19's own full end-to-end smoke test, see below.
  • docs/MONITORING.md: a monitoring plan, not implemented monitoring, no live infrastructure exists to monitor yet. Covers what already exists (application logs, the /v3/api-docs health signal reused from API documentation, CI-level checks) versus what a real deployment still needs (Actuator-based health checks, metrics, log aggregation, alerting, an audit trail), each gap tied back to a specific threat model finding rather than restated as new information, and deliberately not implemented today, matching the same "no new dependency without a reason tied to actual work" rule this project has followed throughout.

Smoke test: the same day, the full flow was run start to finish on a genuinely clean stack (docker compose down -v, then a fresh --build), the last check of core functionality before demo prep: register, log in, add a website, trigger a scan, poll to completion, download the PDF report. Every step passed with real captured output, score 50 and risk HIGH against https://example.com, the same result this exact target has produced consistently since Day 12, confirming nothing regressed across 19 days of changes on top of the same passive check logic. No bugs found, no fixes needed. The full test suite was also re-run against the same live Postgres: pass.

CI/CD pipeline

As of Day 5, .github/workflows/ci.yml runs a build stage and a test stage on every push to main and every PR targeting it. The existing test boots the full Spring context, which needs a real database (no H2/Testcontainers in this project), so the workflow runs a postgres:16-alpine service container using the same credentials already baked into application.properties as local-dev defaults, no extra environment variables needed there.

As of Day 10, two more jobs run in parallel alongside build-and-test: CodeQL (SAST) and Dependency Vulnerability Scan (Trivy). Neither fails the build on findings, both just upload SARIF to the repo's Security tab, there's no baseline/triage done yet on this codebase's existing dependencies or code, hard-failing on day one of scanning would turn every future PR red for reasons unrelated to what it actually changed. Worth a policy decision once there's an actual finding to weigh.

CodeQL was the easy call: this repo is public, so it's completely free (a private repo would need GitHub Advanced Security), needs no new account, and reports natively to the Security tab. build-mode: manual is set explicitly since the workflow runs its own mvnw compile rather than CodeQL's autobuild.

Dependency scanning deliberately deviates from the original build plan's literal wording ("OWASP dependency-check stages"), a deviation worth writing up properly rather than substituting silently. Full reasoning, alternatives considered, and consequences are written up properly as ADR 0001, the short version: OWASP Dependency-Check needs a free NVD API key to run at a usable speed, unmetered it's severely rate-limited, and registering one is a manual, standalone step outside CI. Trivy was chosen instead: no account needed, and just as legitimate and current a DevSecOps tool. It scans the built Spring Boot fat jar rather than a bare pom.xml, so dependencies bundled transitively under BOOT-INF/lib are actually visible to the scanner, not just the ones declared directly.

Both new jobs needed a couple of real, evidence-based fixes against the actual GitHub Actions run rather than guessed version numbers: aquasecurity/trivy-action needed a v prefix on its tag (v0.36.0, not 0.24.0, confirmed via gh api against the actual repo tags rather than guessed), and codeql-action was bumped from v3 to v4 only after the run itself printed an explicit deprecation warning, not preemptively.

Two bugs surfaced while setting up Day 5's CI, worth remembering:

  • mvnw was tracked in git as mode 100644 (non-executable), not 100755. This was invisible locally and in Docker builds, Docker Desktop's Windows-to-Linux file translation is permissive about it, but failed with Permission denied on GitHub Actions' real Linux checkout. It would hit the same problem on any real Linux machine cloning the repo directly (a campus lab PC, for instance), not just CI. Fixed with git update-index --chmod=+x mvnw.
  • JwtAuthenticationFilter used org.springframework.lang.NonNull, deprecated in this Spring Framework version in favor of JSpecify's org.jspecify.annotations.NonNull (already on the classpath transitively, no new dependency).

AUTH is implemented too, as of Day 4: SecurityConfig (stateless, JWT-only, no form login or HTTP Basic), JwtService (HS256 via jjwt), JwtAuthenticationFilter, AuthService, and AuthController. /api/auth/register and /api/auth/login are open, everything else requires a valid JWT.

Worth noting for anyone else touching Spring Security config: /error must be explicitly permitted too. Spring Boot's internal error-forward re-enters the same security filter chain, so without that rule, any exception thrown by a permitted endpoint (e.g. a 409 on duplicate registration) gets masked behind a 401, since the forwarded request has no authenticated principal either. This cost a real debugging session on Day 4, caught only because the auth flow was tested against a live stack rather than assumed correct from a clean compile.

API documentation

As of Day 17 (PR #52): springdoc-openapi generates the OpenAPI 3 specification and serves Swagger UI straight from the existing controllers and DTOs at runtime (GET /v3/api-docs, /swagger-ui/index.html), no hand-maintained spec file to drift out of sync with the real API as endpoints change. OpenApiConfig supplies the metadata springdoc can't infer on its own: the API's title/description, and a JWT bearer security scheme so Swagger UI's Authorize button can attach a token and actually exercise protected endpoints from the browser. SecurityConfig permits the docs and UI paths, they only describe the API's shape, not user data, every actual endpoint documented still enforces its own auth per the rules above.

AuthController, WebsiteController, and ScanController all carry @Tag/@Operation annotations for readable descriptions in the generated spec. AuthController's two public endpoints (register, login) override the global bearer requirement with an empty @SecurityRequirements, so the generated spec accurately shows they don't need a token, matching FR-1.3 rather than showing a misleading lock icon on the two endpoints that don't need one.

Verified the generated spec directly rather than assuming the annotations worked: fetching GET /v3/api-docs with no auth confirmed register/login show security: [] and every other endpoint inherits the global bearerAuth requirement, an exact match to what SecurityConfig actually enforces. The real auth flow (register, login, a protected endpoint with and without a token) was re-verified end to end via docker compose too, to confirm the new dependency and annotations changed nothing about actual request handling.

Website management API

As of Day 6: WebsiteController and WebsiteService implement registering, listing, viewing, and deleting websites (FR-2.1 to FR-2.4), scoped to the authenticated user via WebsiteRepository.

The ownership pattern worth reusing for later endpoints (Day 12's scan orchestration, in particular): every lookup goes through findByOwnerId/findByIdAndOwnerId, never fetch-by-id-then-check. That way a user structurally cannot reach another user's row at all, there's no separate authorization check to forget. A row that exists but belongs to someone else returns 404, not 403, the same "don't confirm it exists" reasoning as the generic login error from Day 4. Verified directly: a second user could not see, fetch, or delete the first user's website through any endpoint.

Known gap, not a problem yet: scans.website_id has no ON DELETE CASCADE, so deleting a website with existing scans will hit a foreign key violation once scans can actually exist (Day 7 onward). Revisit at Day 12.

Scanner engine design

The scanner uses the Strategy pattern so new checks can be added without touching the engine itself: each check implements ScanCheck, and ScannerEngine just runs whatever checks are registered.

classDiagram
    class ScanCheck {
        <<interface>>
        +run(Website website) Finding
        +getName() String
    }
    class HttpsCheck { +run(Website website) Finding }
    class SecurityHeadersCheck { +run(Website website) Finding }
    class SslCertificateCheck { +run(Website website) Finding }
    class HstsCheck { +run(Website website) Finding }
    class CookieSecurityCheck { +run(Website website) Finding }
    class RedirectAnalysisCheck { +run(Website website) Finding }
    class ScannerEngine {
        -List~ScanCheck~ checks
        +runAll(Website website) List~Finding~
    }
    class ScoringService {
        +calculateScore(List~Finding~ findings) int
        +determineRiskRating(int score) RiskRating
    }
    class ReportService {
        +generateReport(Scan scan) Report
    }

    ScanCheck <|.. HttpsCheck
    ScanCheck <|.. SecurityHeadersCheck
    ScanCheck <|.. SslCertificateCheck
    ScanCheck <|.. HstsCheck
    ScanCheck <|.. CookieSecurityCheck
    ScanCheck <|.. RedirectAnalysisCheck
    ScannerEngine o-- ScanCheck : uses many
    ScannerEngine --> ScoringService : findings feed scoring
    ScoringService --> ReportService : score feeds report
Loading

This is the full target design, and as of Day 9 it's fully implemented: ScanCheck, ScannerEngine, and all six checks: HttpsCheck (Day 7, PR #34); SecurityHeadersCheck, SslCertificateCheck, and HstsCheck (Day 8, PR #35); and CookieSecurityCheck and RedirectAnalysisCheck (Day 9, PR #36). This completes FR-3.2's full passive check list from the Requirements page.

SecurityHeadersCheck checks the four headers FR-3.2 names explicitly, correctness for the two with a small valid-value set (X-Content-Type-Options, X-Frame-Options), presence only for the other two (Content-Security-Policy, Referrer-Policy, full policy syntax validation is out of scope for a passive check). SslCertificateCheck reads the certificate straight from the TLS session the shared HttpClient already negotiated (HttpResponse.sslSession()), no separate certificate library needed. It and HstsCheck always test the HTTPS form of the registered URL regardless of scheme, both only mean anything over HTTPS, HttpsCheck stays the one responsible for whether HTTPS is used or redirected to at all. CookieSecurityCheck flags SameSite=None set without Secure as its own distinct issue, that combination is spec-invalid and browsers reject such cookies outright, not just a "missing an attribute" case. RedirectAnalysisCheck walks the whole redirect chain (up to 10 hops) for loops and any insecure HTTP hop anywhere in it, a different concern from HttpsCheck, which only checks whether the first hop upgrades to HTTPS, a chain that starts secure but dips back to HTTP partway through, or loops, is something HttpsCheck alone would never catch.

One deliberate deviation from the diagram above: CheckResult is the real return type of ScanCheck.run(), not Finding. The Finding entity requires a Scan to attach to, and no Scan exists yet at check-execution time, that's Day 12's job (orchestration creates one and converts CheckResults into real Finding rows once it does). Checks stay simple and don't need a persistence-layer object just to report a result.

ScannerEngine also wraps each check in its own try/catch, turning a thrown exception into a CheckResult (severity MEDIUM) rather than letting it abort the whole scan (FR-3.4, NFR-6 in Requirements). That's enforced at the engine level so it protects every check added later too, not just the ones that remember to handle their own errors. Checks also share one HttpClient bean (ScannerConfig) configured to never auto-follow redirects, a check that cares about redirect behavior needs to see the 3xx response itself. The HTTP-fetching boilerplate every check needs (deriving the HTTPS form of a URL, sending a GET and discarding the body) lives in one shared ScannerSupport, pulled out on Day 8 once it started getting duplicated across the new checks, HttpsCheck was refactored to use it too.

Testing note: no REST endpoint exists yet to exercise any of this through (Day 12's job), unlike every other day so far, so tests were added alongside each check rather than waiting for Day 9's planned "add unit tests" step, there was no other reliable way to verify real HTTP-handling logic. All six checks now have real unit test coverage: HttpsCheckTest and SecurityHeadersCheckTest use a local JDK HttpServer (no TLS involved, fully automatable). HstsCheck, SslCertificateCheck, and RedirectAnalysisCheck split their pure decision logic into a package-private evaluate() method separate from the network-fetching run(), so HstsCheckTest, SslCertificateCheckTest (with a mocked X509Certificate), and RedirectAnalysisCheckTest can test the actual severity/threshold/loop logic directly with hand-built input, no self-signed-cert test server or scheme-mixing infrastructure needed. CookieSecurityCheckTest follows the same shape, mostly testing evaluate() directly. Every check's real fetch path (run()) was still checked manually against a real site before committing.

Scoring engine

As of Day 11, ScoringService is implemented, resolving the scoring open question flagged in the Requirements page since Day 1. Like ScanCheck.run(), it operates on List<CheckResult>, not Finding, scoring happens right after the scanner engine runs, before any Scan/Finding rows exist (Day 12's job).

Weighting is severity-based only, not also weighted per-check. Each check already assigns its own severity based on domain knowledge of how bad that specific outcome is, a separate per-check multiplier on top would need its own justification not yet earned:

Severity Points deducted
INFO 0
LOW 5
MEDIUM 15
HIGH 25
CRITICAL 40

Score starts at 100, floors at 0. Risk rating bands:

Score Risk rating
90-100 LOW
70-89 MEDIUM
40-69 HIGH
0-39 CRITICAL

These numbers are a first-pass calibration, not derived from an external standard, chosen so a handful of MEDIUM issues meaningfully move the score without one CRITICAL finding alone being unrecoverable. Revisit with real-world data if it turns out to grade too harshly or too gently.

Scan.riskRating switched from a plain String to the real RiskRating enum with no new Flyway migration, @Enumerated(STRING) stores the same kind of text the existing risk_rating VARCHAR(50) column already held (confirmed by the full test suite passing against a real Postgres with ddl-auto=validate), exactly as planned back on Day 2.

Known, documented limitation not fixed here: a check that couldn't complete (a "could not verify" MEDIUM fallback, see the scanner engine checks above) currently scores the same as a genuine MEDIUM misconfiguration. Distinguishing "inconclusive" from "confirmed issue" would mean adding a field to CheckResult and touching all six existing checks, more than this day's scope covered.

Scan lifecycle

sequenceDiagram
    actor User
    participant Controller as ScanController
    participant Service as ScanService
    participant Engine as ScannerEngine
    participant Check as ScanCheck (x N)
    participant Scoring as ScoringService
    participant Repo as ScanRepository
    participant Report as ReportService

    User->>Controller: POST /api/websites/{id}/scans
    Controller->>Service: startScan(websiteId)
    Service->>Repo: save(new Scan, status=IN_PROGRESS)
    Service->>Engine: runAll(website)

    loop for each registered check
        Engine->>Check: run(website)
        Check-->>Engine: Finding
    end

    Engine-->>Service: List<Finding>
    Service->>Scoring: calculateScore(findings)
    Scoring-->>Service: score, riskRating
    Service->>Repo: save(findings, score, status=COMPLETED)
    Service-->>Controller: Scan (completed)
    Controller-->>User: 201 Created (scan summary)

    User->>Controller: GET /api/scans/{id}/report
    Controller->>Report: generateReport(scanId)
    Report->>Repo: findScanWithFindings(scanId)
    Repo-->>Report: Scan + Findings
    Report-->>Controller: PDF report
    Controller-->>User: 200 OK (application/pdf)
Loading

As of Day 12 (PR #43): ScanController, ScanService, ScanRunner, ScanRepository, and FindingRepository. The report generation half (bottom two rows) is now implemented too, as of Day 13, see below.

One deliberate, significant deviation from the diagram: scan execution is asynchronous, not the fully synchronous flow shown above. This resolves the last open question in the Requirements page. FR-5.1 requires the triggering request not block indefinitely, and a worst-case six-check scan (some checks with a 5s timeout each, RedirectAnalysisCheck up to 10 hops) could take 20-30+ seconds, too long to hold an HTTP request open safely. POST /api/websites/{id}/scans returns 201 immediately once the Scan row is created with status IN_PROGRESS, empty findings; the actual scanning happens on a dedicated thread pool (AsyncConfig), and the caller polls GET /api/scans/{id} (which returns findings inline, not just a score summary, a real frontend needs this JSON; the PDF report is a different way to consume the same data, not the only way) until the status flips to COMPLETED or FAILED.

A couple of implementation details worth knowing if you touch this code:

  • ScanRunner is a separate Spring bean from ScanService, not just a method on it. @Async only works through Spring's proxy, calling an @Async method from another method in the same class (self-invocation) silently runs it synchronously instead, a well known Spring pitfall avoided structurally here rather than by remembering not to do it.
  • ScanRunner.run() takes the already-loaded Website as a parameter, rather than reading it off Scan.getWebsite() (FetchType.LAZY). Accessing a lazy association from a different thread after the original transaction closed risks a LazyInitializationException, passing the object already in hand sidesteps the problem entirely.
  • WebsiteService gained one small additive method, getEntityForOwner, returning the real Website entity (not the WebsiteResponse DTO) for ScanService's internal use. It reuses the existing private ownership-scoped lookup, same 404-not-403 pattern as every other lookup in this codebase, nothing renamed or restructured.

Fully verified against a real site: triggering a scan against https://example.com and polling to completion produced score 50, risk rating HIGH, matching ScoringService's math exactly (-25 missing HSTS, -25 missing security headers), with a real Cloudflare certificate read straight from the TLS session among the six findings. Cross-owner isolation holds on both triggering and viewing a scan, same pattern as website management.

Report generation

As of Day 13 (PR #46): PdfReportGenerator and ReportService implement GET /api/scans/{id}/report (added to the existing ScanController, no separate ReportController, matching the plan's own file list for this day).

Two deliberate deviations from the class diagram and ERD above:

  • No Report entity, no pdf_path column, no new migration. Everything a report needs, score, risk rating, findings, already lives in the database (Day 12). The PDF is generated fresh from that data on every request rather than built once and stored. A stored PDF would need a durable volume mount for file storage, which doesn't exist anywhere in this project's Docker setup, container filesystems are ephemeral, so a pdf_path column would eventually point at a file that no longer exists after a restart. Regenerating on demand sidesteps that gap entirely rather than working around it.
  • Apache PDFBox, not iText. iText 7+ (the current major version) is AGPL licensed for open source use, or requires a commercial license otherwise, a meaningfully worse fit for a student project than PDFBox's plain Apache 2.0 license. PDFBox is lower-level (no HTML/CSS templating, text and layout are placed manually), but the report's actual layout, a title block plus a list of findings, doesn't need more than that.

A scan that isn't COMPLETED returns 409 with a status-specific message (IN_PROGRESS vs FAILED) rather than generating a report from incomplete or null data. Same ownership scoping as every other endpoint, requesting another user's scan report returns 404, not 403.

Testing note: PdfReportGeneratorTest reopens the generated bytes with PDFBox and extracts the text back out (PDFTextStripper), a real round-trip check that the report actually contains the right content (website URL, risk rating, check names, descriptions), not just that it produced non-empty bytes. A second test forces multi-page output (15 findings with long descriptions) and confirms pagination genuinely works, PDFBox ties a content stream to exactly one page, so a low-level generator has to manage page breaks itself. The full endpoint was also verified manually via docker compose against a real site: a genuine 200 with the right Content-Type/Content-Disposition and valid %PDF- bytes once a scan against https://example.com completed.

History and trend

As of Day 14 (PR #47), completing FR-5.3 in the Requirements page: ScanHistoryService backs two more endpoints on the existing ScanController (again, no separate controller):

  • GET /api/websites/{id}/scans: every scan for a website, most recent first, any status. Lightweight ScanSummaryResponse per scan, no findings inline, unlike ScanResponse (Day 12), a list endpoint returning full findings for every scan would be wasteful.
  • GET /api/websites/{id}/scans/trend: only COMPLETED scans, chronological (oldest to newest, the natural order for plotting a trend line), plus a comparison between the two most recent completed scans: a scoreDelta and a TrendDirection (IMPROVED/WORSENED/UNCHANGED/INSUFFICIENT_DATA if fewer than two completed scans exist yet). There's no "noise threshold" for unchanged, only exact score equality counts as UNCHANGED, anything else would be an arbitrary judgment call with no principled basis.

Ownership is checked once, up front, by resolving the website through WebsiteService (same pattern ScanService.startScan already uses), then both queries trust that already-authorized website id rather than re-checking per scan.

Testing note: the actual comparison logic (filtering to completed, chronological sorting, delta/direction) is pure once you have the scan list, so ScanHistoryServiceTest mocks ScanRepository/WebsiteService directly, no real database needed, same approach as ScoringServiceTest. Both endpoints were also verified manually via docker compose: empty history/trend before any scan exists, two triggered scans against https://example.com showed up correctly ordered in both endpoints, with a genuinely computed UNCHANGED (delta 0, the same site scanned twice in quick succession).

Data model

erDiagram
    USER ||--o{ WEBSITE : owns
    WEBSITE ||--o{ SCAN : "is scanned in"
    SCAN ||--o{ FINDING : produces
    SCAN ||--|| REPORT : "generates"

    USER {
        bigint id PK
        varchar email UK
        varchar password_hash
        varchar role
        timestamp created_at
    }
    WEBSITE {
        bigint id PK
        bigint user_id FK
        varchar url
        timestamp added_at
    }
    SCAN {
        bigint id PK
        bigint website_id FK
        varchar status
        int overall_score
        varchar risk_rating
        timestamp started_at
        timestamp completed_at
    }
    FINDING {
        bigint id PK
        bigint scan_id FK
        varchar check_name
        varchar severity
        text description
        text recommendation
    }
    REPORT {
        bigint id PK
        bigint scan_id FK
        varchar pdf_path
        timestamp generated_at
    }
Loading

This is the full target model. As of Day 2, User, Website, Scan, and Finding are implemented as JPA entities with a matching Flyway migration (PR #25): User.java, Website.java, Scan.java, Finding.java, V1__init_schema.sql.

One difference from the diagram above, permanent as of Day 13: REPORT was never built, and now won't be, on purpose. Report generation (Day 13) deliberately generates the PDF fresh from Scan/Finding data on every request instead of persisting one, see Report generation above for why (no durable volume mount exists in this project's Docker setup for a stored pdf_path to survive a restart). Scan.risk_rating is no longer a placeholder string, as of Day 11 it's the real RiskRating enum, see the Scoring engine section above for the bands that define its values. As of Day 12, Scan and Finding rows are no longer just defined, they're actually created and populated by real scan orchestration, see Scan lifecycle above.

See the Requirements page for the SRS section this schema implements.

Threat model

As of Day 15 (PR #48): docs/THREAT_MODEL.md walks all six STRIDE categories (Spoofing, Tampering, Repudiation, Information Disclosure, Denial of Service, Elevation of Privilege) against the real, as-built architecture described on this page, not a generic template, citing actual classes (WebsiteService.validateUrl, SecurityConfig, AsyncConfig, ScannerSupport, application.properties) rather than hypothetical ones. Severity reuses the same Severity scale already used for scan findings, applied here to the threat itself.

It formalizes the domain ownership accepted risk already flagged on the Requirements page's Out of Scope list, and surfaces one finding not previously written down anywhere: the scanner engine has no protection against being pointed at private or internal network targets (rated HIGH), since website management's URL validation only checks scheme, not destination. It also documents several other real, currently unmitigated gaps plainly rather than glossing over them: no TLS termination on the API in the current Docker Compose setup, the dev-only JWT secret fallback visible in a public repo, no rate limiting on the auth endpoints, and no audit trail. None of these are fixed as part of Day 15, each is tracked as its own future recommendation in the document's section 7, a documentation day formalizes and prioritizes gaps, it doesn't fix them all on the spot.

Architecture Decision Records

As of Day 16 (PR #51), three more ADRs join 0001 in docs/adr/, each formalizing a decision already made and shipped earlier, not a hypothetical one:

  • 0002: PostgreSQL as the primary data store, over MySQL/MariaDB and H2, decided Day 1.
  • 0003: JWT over server-side sessions, over Spring Session with a shared store and third-party OAuth2/OIDC, decided Day 4. Its Consequences section links forward to the threat model's finding on the JWT secret's dev-only fallback, tying Day 15 and Day 16 together rather than duplicating the reasoning.
  • 0004: the Strategy pattern used by the scanner engine, over a monolithic method, Chain of Responsibility, and Visitor, decided Day 7.