Skip to content
Merged

Dev #43

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion .githooks/pre-commit
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
# Git Pre-Commit Hook - Fast local security checks
# Git Pre-Commit Hook - Local quality checks
# Installation: git config core.hooksPath .githooks

set -e
Expand All @@ -20,6 +20,12 @@ npm run typecheck > /dev/null 2>&1 || {
}
echo "### TypeScript OK"

# 3. ESLint and Stylelint (required)
npm run lint || {
echo "### Lint checks failed"
exit 1
}
echo "### Lint checks passed"

# Note: Trivy and Semgrep scan runs in CI only
# You can do them manually before commit if needed
Expand Down
5 changes: 4 additions & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{
"recommendations": ["astro-build.astro-vscode"],
"recommendations": [
"astro-build.astro-vscode",
"dbaeumer.vscode-eslint"
],
"unwantedRecommendations": []
}
9 changes: 8 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,12 @@
"snyk.advanced.autoSelectOrganization": true,
"files.associations": {
"**/.dockerignore": "ignore"
}
},
"eslint.validate": [
"javascript",
"javascriptreact",
"typescript",
"typescriptreact",
"astro"
]
}
33 changes: 28 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,17 @@ The application presents my professional experience, education, and software pro

- **Astro 7** – application framework, routing, rendering, and content
- **TypeScript** – type-safe application development
- **Zod** – schema validation for content collections and form input
- **Node.js 24** – server runtime
- **Nodemailer** – SMTP-based email delivery
- **Pino** – structured, level-based server logging with secret redaction
- **CSS** – custom design system without a UI framework
- **GitHub Actions** – CI and automated quality checks
- **Semgrep & Trivy** – static analysis and security scanning
- **Docker** – containerized deployment
- **Vitest** – unit and type-level testing
- **ESLint & Stylelint** – code and style linting
- **GitHub Actions** – CI (tests, type checks, linting, security scans) and CD (build, scan, deploy)
- **Semgrep & Trivy** – static analysis, dependency scanning, and container image scanning
- **Docker** – containerized build, published to GitHub Container Registry
- **Coolify** – self-hosted deployment platform on my own infrastructure
- **Infomaniak** – hosting infrastructure in Switzerland

## Architecture
Expand Down Expand Up @@ -52,9 +57,10 @@ The application includes measures such as:
- Server-side rate limiting
- Separation of secrets from client-side code
- No third-party tracking or analytics
- Structured server-side logging with automatic redaction of credentials and cookies
- Automated static analysis and security scans

Semgrep and Trivy are integrated into the CI workflow to identify potential security issues, vulnerable dependencies, secrets, and configuration problems before changes are merged.
Semgrep and Trivy run in CI on every change (source code, dependencies, and configuration) and Trivy scans the built container image again in the CD workflow before it is pushed, to catch issues introduced by the base image or installed packages.

## Content & Internationalization

Expand All @@ -74,13 +80,30 @@ Dark and light themes are implemented using CSS custom properties. The interface

Changes are checked through automated CI workflows before being merged. The project uses automated testing, type checking, linting, and security analysis to detect regressions and implementation issues early.

Tests run on Vitest and cover server-side logic (validation, rate limiting, email sending, error handling), content schemas, i18n utilities, CSP headers, colour-contrast of the design tokens, and type-level checks tying Astro components to their content collection types.

- `npm run test`: run tests in watch mode.
- `npm run test:run`: run tests once (used by CI).

Linting uses ESLint with the recommended JavaScript, TypeScript, and Astro rules, plus Stylelint for CSS and Astro styles. Generated output is excluded from ESLint.

- `npm run lint`: run both linters (also used by CI).
- `npm run lint:code`: check JavaScript, TypeScript, and Astro components.
- `npm run lint:styles`: check CSS and Astro styles.
- `npm run lint:fix`: apply available automatic fixes; review the resulting diff.
- `npm run typecheck`: run Astro's separate type checks.

VS Code recommends the ESLint extension and enables linting for Astro and TypeScript files.

The application is continuously developed and serves as both my public portfolio and a practical environment for improving my knowledge of Astro, TypeScript, web security, accessibility, performance, and software architecture.

## Deployment

The application runs on Node.js and is deployed as a container on my own hosting infrastructure at Infomaniak in Switzerland.

The deployment setup keeps application configuration and secrets outside the container image and provides the server-side runtime required for features such as the contact form.
On every push to `main`, the CD workflow builds the production image, scans it with Trivy, and pushes it to the GitHub Container Registry tagged with the commit SHA. It then triggers a deployment on [Coolify](https://coolify.io) — the self-hosted platform documented in my [Coolify project](src/content/projects/en/coolify.md) — and polls the live site's `X-App-Version` response header until it matches the deployed commit, so a deployment only counts as successful once the new version is actually serving traffic. The `/system-info` page exposes the same version and the server start time for manual verification.

Application configuration and secrets stay outside the container image and are provided at runtime.

## License

Expand Down
28 changes: 25 additions & 3 deletions docs/architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,14 @@ This document describes the overall system architecture of the web portfolio, co
src/
├── actions/ # Astro Actions (Type-safe Controllers)
├── assets/ # Static & processed media assets (Images, Icons)
├── components/ # Astro UI components & UI framework islands (Vue)
├── composables/ # Reusable client-side logic & UI state
├── components/ # Astro components grouped by responsibility
│ ├── layout/ # Header, footer, navigation and their controls
│ ├── ui/ # Shared page frames, buttons and utility views
│ ├── home/ # Landing page sections
│ ├── contact/ # Contact section, form and fields
│ ├── career/ # Career page, sections and entries
│ ├── projects/ # Project listing, cards and details
│ └── legal/ # Imprint and privacy content
├── content/ # Astro Content Collections (Markdown & JSON data)
├── content.config.ts # Content Collections Schema Definitions
├── i18n/ # Internationalization dictionaries & helpers
Expand All @@ -35,13 +41,22 @@ The frontend follows official **Astro architectural patterns**, focusing on serv

- **Pages & Routing (`src/pages/`)**:
- File-based routing providing SSR HTML pages.
- Multi-language routing handling localized page endpoints.
- Multi-language routing handling localized page endpoints. Astro's `i18n` config
(`astro.config.mjs`) drives locale detection and redirects, but each route is
currently duplicated as a separate file under `src/pages/de/` and `src/pages/en/`
with identical content — the language itself is resolved at render time via
`getLangFromUrl`. Collapsing this into a single `src/pages/[lang]/` tree is a
known, not-yet-done simplification.
- `system-info.astro` renders the running build's version (`APP_VERSION`, baked
in by the Dockerfile/CD pipeline) and server start time, for verifying which
deployment is live.

- **Layouts (`src/layouts/`)**:
- Wraps pages with common HTML document scaffolding, meta tags, and global stylesheets.

- **Components (`src/components/`)**:
- **Astro Components (`.astro`)**: Server-rendered templates with small, local scripts only where native browser behavior needs enhancement.
- Components with inputs declare a local `Props` type; callers are checked by `astro check`.
- Interactive controls use native HTML elements such as `<dialog>` and `<details>` instead of a client-side UI framework.

- **Content Collections (`src/content/` & `src/content.config.ts`)**:
Expand Down Expand Up @@ -99,3 +114,10 @@ The architecture strictly enforces the **Dependency Inversion Principle (DIP)**:

4. **Configuration (`src/server/config/`) & Environment (`astro:env`)**:
- Centralized, type-safe configuration values validated through Astro's `astro:env` API.

5. **Middleware Pipeline (`src/middleware/`)**:
- `src/middleware/index.ts` sequences three middlewares on every request, in this
order: `version` (stamps the `X-App-Version` response header first, so it
survives the CSP rebuild), `originCheck` (validates the request origin against
`src/server/config/trusted-origins.ts`, replacing Astro's built-in check — see
the comment in `astro.config.mjs` for why), then `csp` (applies security headers).
2 changes: 1 addition & 1 deletion docs/mail-processing.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ sequenceDiagram
Sender-->>UseCase: { success: false, error }
UseCase->>Limiter: release(reservation)
UseCase-->>Action: Throw EmailSendError
Action-->>User: 400 BAD_REQUEST
Action-->>User: 500 INTERNAL_SERVER_ERROR
end
end
```
Expand Down
2 changes: 1 addition & 1 deletion docs/rate-limiting.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ flowchart TD
DispatchEmail -- Success --> Complete[Keep Reservation & Return 200 OK]
DispatchEmail -- Exception / Failure --> Release[rateLimiter.release reservation]
Release --> RefundCounter[Decrement counter - 1]
RefundCounter --> ReturnError[Action Error Response: 400 BAD_REQUEST]
RefundCounter --> ReturnError[Action Error Response: 500 INTERNAL_SERVER_ERROR]
```

---
Expand Down
Loading