Skip to content

Commit dd04da2

Browse files
committed
Update overall repository
1 parent 6c40d59 commit dd04da2

7 files changed

Lines changed: 118 additions & 29 deletions

File tree

.github/copilot-instructions.md

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
2+
# GitHub Copilot Instructions for This Repository
3+
4+
Welcome to the Nais Examples repository! This document provides guidance for using GitHub Copilot effectively in this codebase. Please follow the instructions below to ensure consistency, quality, and best practices across all services and technologies in this repository.
5+
6+
---
7+
8+
## General Instructions
9+
10+
- **Code Quality:** Always generate clean, readable, and idiomatic code. Follow the conventions of the language and framework in use.
11+
- **Documentation:** Add or update comments and documentation for new code, especially for public APIs and complex logic.
12+
- **Testing:** When adding new features or fixing bugs, generate or update relevant tests.
13+
- **Security:** Avoid hardcoding secrets or credentials. Use environment variables or secret management solutions.
14+
- **Error Handling:** Implement proper error handling and logging. Avoid silent failures.
15+
- **Consistency:** Follow the existing project structure and naming conventions.
16+
- **Dependencies:** Use only necessary dependencies. Prefer official or well-maintained libraries.
17+
- **Pull Requests:** Ensure all code passes linting, formatting, and tests before submitting a PR.
18+
19+
---
20+
21+
22+
## Language & Framework Specific Instructions
23+
24+
### 1. Next.js (Frontend)
25+
- Use functional React components and hooks.
26+
- Prefer TypeScript for new files/components.
27+
- Use Tailwind CSS for UI.
28+
- Organize components in the `components/` directory and pages in the `pages/` or `app/` directory.
29+
- Use Next.js API routes for backend logic only when necessary.
30+
- Optimize for accessibility and performance.
31+
- Use environment variables for configuration (never commit secrets).
32+
33+
### 2. Kotlin + Ktor (Backend)
34+
- Use idiomatic Kotlin (prefer `val` over `var`, use data classes, etc.).
35+
- Organize code by feature (routes, services, repositories, models, etc.).
36+
- Use Ktor features for routing, dependency injection, and configuration.
37+
- Use JPA/Hibernate or Exposed for database access; prefer constructor injection.
38+
- Write integration and unit tests for routes and services.
39+
- Use configuration files (`application.conf` or `application.yaml`) for environment-specific settings.
40+
41+
### 3. Go (Load Generator)
42+
- Use idiomatic Go (short variable names, error handling, etc.).
43+
- Organize code by package (cmd, internal, etc.).
44+
- Write clear, minimal code for load generation and HTTP requests.
45+
- Add comments and documentation for exported functions.
46+
- Write unit tests for core logic if applicable.
47+
48+
### 4. PostgreSQL (Database)
49+
- Use migrations (e.g., Flyway, Liquibase, or manual SQL) for schema changes if needed.
50+
- Store connection details in environment variables or secrets.
51+
- Do not commit database dumps or sensitive data.
52+
53+
### 5. Docker & Docker Compose
54+
- Write clear, minimal Dockerfiles for each service.
55+
- Use multi-stage builds for production images when possible.
56+
- Keep `docker-compose.yaml` up to date with all services and dependencies.
57+
- Expose only necessary ports and use environment variables for configuration.
58+
59+
---
60+
61+
## Additional Notes
62+
- For more details on each service, see the README in the respective subdirectory.
63+
- If you are unsure about conventions or best practices, refer to the official documentation for the language or framework in use.
64+
- When in doubt, prefer clarity and maintainability over cleverness.

.github/workflows/quotes-backend.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,13 @@ jobs:
5454
dockerfile: ./quotes-backend/Dockerfile
5555
google_service_account: gh-examples
5656
push: ${{ github.actor != 'dependabot[bot]' }}
57-
workload_identity_provider: ${{ secrets.NAIS_IO_WORKLOAD_IDENTITY_PROVIDER }}
57+
workload_identity_provider: ${{ secrets.Nais_IO_WORKLOAD_IDENTITY_PROVIDER }}
5858
outputs:
5959
version: ${{ steps.image.outputs.version }}
6060
rollout:
6161
permissions:
6262
id-token: write
63-
name: Deploy to NAIS
63+
name: Deploy to Nais
6464
needs: ["test", "build_push_sign"]
6565
runs-on: ubuntu-latest
6666
if: github.ref == 'refs/heads/main'

.github/workflows/quotes-frontend.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,13 @@ jobs:
3636
dockerfile: ./quotes-frontend/Dockerfile
3737
google_service_account: gh-examples
3838
push: ${{ github.actor != 'dependabot[bot]' }}
39-
workload_identity_provider: ${{ secrets.NAIS_IO_WORKLOAD_IDENTITY_PROVIDER }}
39+
workload_identity_provider: ${{ secrets.Nais_IO_WORKLOAD_IDENTITY_PROVIDER }}
4040
outputs:
4141
version: ${{ steps.image.outputs.version }}
4242
rollout:
4343
permissions:
4444
id-token: write
45-
name: Deploy to NAIS
45+
name: Deploy to Nais
4646
needs: ["build_push_sign"]
4747
runs-on: ubuntu-latest
4848
if: github.ref == 'refs/heads/main'

.github/workflows/quotes-loadgen.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,13 @@ jobs:
3636
dockerfile: ./quotes-loadgen/Dockerfile
3737
google_service_account: gh-examples
3838
push: ${{ github.actor != 'dependabot[bot]' }}
39-
workload_identity_provider: ${{ secrets.NAIS_IO_WORKLOAD_IDENTITY_PROVIDER }}
39+
workload_identity_provider: ${{ secrets.Nais_IO_WORKLOAD_IDENTITY_PROVIDER }}
4040
outputs:
4141
version: ${{ steps.image.outputs.version }}
4242
rollout:
4343
permissions:
4444
id-token: write
45-
name: Deploy to NAIS
45+
name: Deploy to Nais
4646
needs: ["build_push_sign"]
4747
runs-on: ubuntu-latest
4848
if: github.ref == 'refs/heads/main'

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2021 NAV (Arbeids- og velferdsdirektoratet) - The Norwegian Labour and Welfare Administration
3+
Copyright (c) 2021 Nav (Arbeids- og velferdsdirektoratet) - The Norwegian Labour and Welfare Administration
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 46 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,75 @@
1-
# Really NAIS examples
1+
# Really Nais Examples
22

3-
A collection of example apps demonstrating features and concepts in and around NAIS.
3+
This repository contains a collection of example applications for the Nais platform. The main example is a Quotes application, where users can view and create quotes. Each service demonstrates a specific technology stack and integration pattern commonly used in modern cloud-native applications on Nais.
44

5-
| Example | Language | Description |
6-
| ------------------------------ | -------- | -------------------------------------------------------------------- |
7-
| [shop-frontend](shop-frontend) | Next.js | A simple webshop using [NAV's design system][aksel] and Tailwind CSS |
8-
| [shop-backend](shop-backend) | Kotlin | A simple Spring Boot API with a PostgreSQL database |
9-
| [sentiment-api](sentiment-api) | Kotlin | A simple Spring Boot API with Google Cloud Sentiment Analysis |
5+
Another key purpose of these examples is to showcase the observability features available in the Nais Platform, based on OpenTelemetry. This includes:
106

11-
A high-level overview of the example apps and their dependencies:
7+
- **Logs** collected in Loki
8+
- **Metrics** collected in Prometheus
9+
- **Traces** collected in Tempo
10+
11+
All observability data is available and visualized in Grafana, making it easy to monitor, debug, and understand your applications running on Nais.
12+
13+
## Purpose
14+
15+
The purpose of this repository is to help developers understand how to:
16+
17+
- Build and deploy frontend, backend, and load generation services on Nais
18+
- Integrate with managed databases (PostgreSQL)
19+
- Use modern frameworks and best practices for cloud applications
20+
21+
## High-Level Overview
22+
23+
This repository consists of the following services:
24+
25+
| Service | Tech Stack | Purpose & Description |
26+
| ---------------------------------- | ---------------------------- | ------------------------------------------------------------------------------ |
27+
| [quotes-frontend](quotes-frontend) | Next.js, React, Tailwind CSS | The web frontend for the Quotes app, allowing users to view and submit quotes. |
28+
| [quotes-backend](quotes-backend) | Kotlin, Ktor, PostgreSQL | The backend API for the Quotes app, handling quote storage and retrieval. |
29+
| [quotes-loadgen](quotes-loadgen) | Go (Golang) | A load generator for simulating traffic and testing the Quotes application. |
30+
31+
For more details on each service, see the README in the respective subdirectory:
32+
33+
- [quotes-frontend/README.md](quotes-frontend/README.md)
34+
- [quotes-backend/README.md](quotes-backend/README.md)
35+
- [quotes-loadgen/README.md](quotes-loadgen/README.md)
36+
37+
## Architecture
38+
39+
A high-level overview of the Quotes application and its dependencies:
1240

1341
```mermaid
1442
---
1543
config:
16-
flowchart:
17-
defaultRenderer: elk
44+
flowchart:
45+
defaultRenderer: elk
1846
---
1947
graph LR
48+
2049
subgraph Browser
21-
A(React.js)
50+
A(React.js)
2251
end
2352
2453
subgraph Frontend
25-
B(Next.js)
54+
B(Next.js + Tailwind CSS)
2655
end
2756
2857
subgraph Backend
29-
C(Spring Boot)
30-
D(PostgreSQL)
58+
C(Ktor)
59+
D(PostgreSQL)
3160
end
3261
33-
subgraph Sentiment API
34-
E(Spring Boot)
35-
F(Google Cloud<br>Sentiment API)
62+
subgraph Loadgen
63+
E(Go)
3664
end
3765
3866
A --> B
3967
B --> C
4068
C --> D
41-
C --> E
42-
E --> F
69+
E --> B
4370
4471
```
4572

46-
[aksel]: https://aksel.nav.no/
47-
4873
## License
4974

5075
The code in this repository is licensed under the MIT license. See [LICENSE](LICENSE) for more information.

quotes-loadgen/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ export LOADGEN_DURATION=15
9696

9797
## Deployment
9898

99-
The application can be deployed to the NAIS platform using the provided `.nais/config.yaml` file. Ensure the Docker image is pushed to a container registry accessible by NAIS.
99+
The application can be deployed to the Nais platform using the provided `.nais/config.yaml` file. Ensure the Docker image is pushed to a container registry accessible by Nais.
100100

101101
## License
102102

0 commit comments

Comments
 (0)