Skip to content

Commit d02feef

Browse files
feat: initialize Angular frontend application with routing, styles, and testing setup
1 parent b4d83dd commit d02feef

25 files changed

+9513
-29
lines changed

.github/copilot-instructions.md

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,19 @@ This BioIS monorepo is written in Rust, SQL, TypeScript and Python.
44

55
## Repository Structure
66

7-
| Path | Description |
8-
| ----------------- | -------------------------------------------------|
9-
| `README.md` | Project Documentation |
10-
| `LICENSE` | License File |
11-
| `.github/` | GitHub Configuration |
12-
| `justfile` | Justfile for task automation |
13-
| `backend/` | Rust API Code |
14-
| `frontend/` | TypeScript Angular Frontend Code |
15-
| `api-client/` | OpenAPI client code generated from the API spec |
16-
| `test-client/` | Snippet-based test client for testing the API |
7+
| Path | Description |
8+
| -------------- | ----------------------------------------------- |
9+
| `README.md` | Project Documentation |
10+
| `LICENSE` | License File |
11+
| `.github/` | GitHub Configuration |
12+
| `justfile` | Justfile for task automation |
13+
| `backend/` | Rust API Code |
14+
| `frontend/` | TypeScript Angular Frontend Code |
15+
| `api-client/` | OpenAPI client code generated from the API spec |
16+
| `test-client/` | Snippet-based test client for testing the API |
17+
18+
- Commit messages and pull request titles should be in the conventional commit format of `<type>(<scope>): <description>`, where:
19+
- `<type>` is one of `feat`, `fix`, `docs`, `style`, `refactor`, `perf`, `test`.
20+
- `<scope>` is a noun describing the section of the codebase affected (e.g., `backend`, `frontend`, `api`).
21+
- `<description>` is a short summary of the change.
22+
- Diagrams should be created using Mermaid syntax and included in the relevant Markdown files for documentation purposes.
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
---
2+
applyTo: "frontend/**"
3+
---
4+
5+
You are an expert in TypeScript, Angular, and scalable web application development. You write functional, maintainable, performant, and accessible code following Angular and TypeScript best practices.
6+
7+
## TypeScript Best Practices
8+
9+
- Use strict type checking
10+
- Prefer type inference when the type is obvious
11+
- Avoid the `any` type; use `unknown` when type is uncertain
12+
13+
## Angular Best Practices
14+
15+
- Always use standalone components over NgModules
16+
- Must NOT set `standalone: true` inside Angular decorators. It's the default in Angular v20+.
17+
- Use signals for state management
18+
- Implement lazy loading for feature routes
19+
- Do NOT use the `@HostBinding` and `@HostListener` decorators. Put host bindings inside the `host` object of the `@Component` or `@Directive` decorator instead
20+
- Use `NgOptimizedImage` for all static images.
21+
- `NgOptimizedImage` does not work for inline base64 images.
22+
23+
## Accessibility Requirements
24+
25+
- It MUST pass all AXE checks.
26+
- It MUST follow all WCAG AA minimums, including focus management, color contrast, and ARIA attributes.
27+
28+
### Components
29+
30+
- Keep components small and focused on a single responsibility
31+
- Use `input()` and `output()` functions instead of decorators
32+
- Use `computed()` for derived state
33+
- Set `changeDetection: ChangeDetectionStrategy.OnPush` in `@Component` decorator
34+
- Prefer inline templates for small components
35+
- Prefer Reactive forms instead of Template-driven ones
36+
- Do NOT use `ngClass`, use `class` bindings instead
37+
- Do NOT use `ngStyle`, use `style` bindings instead
38+
- When using external templates/styles, use paths relative to the component TS file.
39+
40+
## State Management
41+
42+
- Use signals for local component state
43+
- Use `computed()` for derived state
44+
- Keep state transformations pure and predictable
45+
- Do NOT use `mutate` on signals, use `update` or `set` instead
46+
47+
## Templates
48+
49+
- Keep templates simple and avoid complex logic
50+
- Use native control flow (`@if`, `@for`, `@switch`) instead of `*ngIf`, `*ngFor`, `*ngSwitch`
51+
- Use the async pipe to handle observables
52+
- Do not assume globals like (`new Date()`) are available.
53+
- Do not write arrow functions in templates (they are not supported).
54+
55+
## Services
56+
57+
- Design services around a single responsibility
58+
- Use the `providedIn: 'root'` option for singleton services
59+
- Use the `inject()` function instead of constructor injection

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,6 @@ target
2222

2323
.env
2424
Settings.toml
25+
26+
api-client/typescript/node_modules
27+
api-client/typescript/package-lock.json

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,28 @@ _TODO: Add link to hosted service when available._
1414

1515
BioIS consists of several key components.
1616

17+
🏗️ Architecture
18+
19+
```mermaid
20+
flowchart TB
21+
%% Definitions
22+
ui["Angular UI<br/>(TypeScript)"]
23+
bindings["TS Bindings<br/>(Generated)"]
24+
service["Rust Service<br/>(Axum/utoipa)"]
25+
26+
%% Relations
27+
ui -->|HTTP/REST| bindings
28+
bindings -->|Type-safe calls| service
29+
```
30+
1731
### [Backend](backend/README.md)
1832

1933
The core service is implemented in Rust, providing APIs and processing capabilities for biodiversity indicators.
2034

35+
### [API Client](api-client/README.md)
36+
37+
The API client is a TypeScript library generated from the OpenAPI specification of the BioIS backend service.
38+
2139
### [Frontend](frontend/README.md)
2240

2341
_TODO: Add description of frontend component._

api-client/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# API Client
2+
3+
The API client is a TypeScript library generated from the OpenAPI specification of the BioIS backend service.
4+
It provides type-safe bindings for all API endpoints, allowing frontend and other TypeScript-based applications to interact with the BioIS service seamlessly.

frontend/.editorconfig

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Editor configuration, see https://editorconfig.org
2+
root = true
3+
4+
[*]
5+
charset = utf-8
6+
indent_style = space
7+
indent_size = 2
8+
insert_final_newline = true
9+
trim_trailing_whitespace = true
10+
11+
[*.ts]
12+
quote_type = single
13+
ij_typescript_use_double_quotes = false
14+
15+
[*.md]
16+
max_line_length = off
17+
trim_trailing_whitespace = false

frontend/.gitignore

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# See https://docs.github.com/get-started/getting-started-with-git/ignoring-files for more about ignoring files.
2+
3+
# Compiled output
4+
/dist
5+
/tmp
6+
/out-tsc
7+
/bazel-out
8+
9+
# Node
10+
/node_modules
11+
npm-debug.log
12+
yarn-error.log
13+
14+
# IDEs and editors
15+
.idea/
16+
.project
17+
.classpath
18+
.c9/
19+
*.launch
20+
.settings/
21+
*.sublime-workspace
22+
23+
# Visual Studio Code
24+
.vscode/*
25+
!.vscode/settings.json
26+
!.vscode/tasks.json
27+
!.vscode/launch.json
28+
!.vscode/extensions.json
29+
!.vscode/mcp.json
30+
.history/*
31+
32+
# Miscellaneous
33+
/.angular/cache
34+
.sass-cache/
35+
/connect.lock
36+
/coverage
37+
/libpeerconnection.log
38+
testem.log
39+
/typings
40+
__screenshots__/
41+
42+
# System files
43+
.DS_Store
44+
Thumbs.db

frontend/README.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# BioIS Frontend
2+
3+
The frontend is an Angular application that provides an interactive web interface for users to visualize and interact with biodiversity indicators computed by the BioIS backend service.
4+
5+
## Development server
6+
7+
To start a local development server, run:
8+
9+
```bash
10+
ng serve
11+
```
12+
13+
Once the server is running, open your browser and navigate to `http://localhost:4200/`. The application will automatically reload whenever you modify any of the source files.
14+
15+
## Code scaffolding
16+
17+
Angular CLI includes powerful code scaffolding tools. To generate a new component, run:
18+
19+
```bash
20+
ng generate component component-name
21+
```
22+
23+
For a complete list of available schematics (such as `components`, `directives`, or `pipes`), run:
24+
25+
```bash
26+
ng generate --help
27+
```
28+
29+
## Building
30+
31+
To build the project run:
32+
33+
```bash
34+
ng build
35+
```
36+
37+
This will compile your project and store the build artifacts in the `dist/` directory. By default, the production build optimizes your application for performance and speed.
38+
39+
## Running unit tests
40+
41+
To execute unit tests with the [Vitest](https://vitest.dev/) test runner, use the following command:
42+
43+
```bash
44+
ng test
45+
```
46+
47+
## Running end-to-end tests
48+
49+
For end-to-end (e2e) testing, run:
50+
51+
```bash
52+
ng e2e
53+
```
54+
55+
Angular CLI does not come with an end-to-end testing framework by default. You can choose one that suits your needs.
56+
57+
## Additional Resources
58+
59+
For more information on using the Angular CLI, including detailed command references, visit the [Angular CLI Overview and Command Reference](https://angular.dev/tools/cli) page.

frontend/angular.json

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
{
2+
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
3+
"version": 1,
4+
"cli": {
5+
"packageManager": "npm"
6+
},
7+
"newProjectRoot": "projects",
8+
"projects": {
9+
"BioIS": {
10+
"projectType": "application",
11+
"schematics": {
12+
"@schematics/angular:component": {
13+
"style": "scss"
14+
}
15+
},
16+
"root": "",
17+
"sourceRoot": "src",
18+
"prefix": "app",
19+
"architect": {
20+
"build": {
21+
"builder": "@angular/build:application",
22+
"options": {
23+
"browser": "src/main.ts",
24+
"tsConfig": "tsconfig.app.json",
25+
"inlineStyleLanguage": "scss",
26+
"assets": [
27+
{
28+
"glob": "**/*",
29+
"input": "public"
30+
}
31+
],
32+
"styles": ["src/styles.scss"]
33+
},
34+
"configurations": {
35+
"production": {
36+
"budgets": [
37+
{
38+
"type": "initial",
39+
"maximumWarning": "500kB",
40+
"maximumError": "1MB"
41+
},
42+
{
43+
"type": "anyComponentStyle",
44+
"maximumWarning": "4kB",
45+
"maximumError": "8kB"
46+
}
47+
],
48+
"outputHashing": "all"
49+
},
50+
"development": {
51+
"optimization": false,
52+
"extractLicenses": false,
53+
"sourceMap": true
54+
}
55+
},
56+
"defaultConfiguration": "production"
57+
},
58+
"serve": {
59+
"builder": "@angular/build:dev-server",
60+
"configurations": {
61+
"production": {
62+
"buildTarget": "BioIS:build:production"
63+
},
64+
"development": {
65+
"buildTarget": "BioIS:build:development"
66+
}
67+
},
68+
"defaultConfiguration": "development"
69+
},
70+
"test": {
71+
"builder": "@angular/build:unit-test"
72+
}
73+
}
74+
}
75+
}
76+
}

0 commit comments

Comments
 (0)