# 00adasod/liaprojekt architecture

> Architecture diagram of the GitHub repository 00adasod/liaprojekt, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-06-18). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/00adasod/liaprojekt
- Repository: https://github.com/00adasod/liaprojekt

## Overview

1. **Repository shape**
   - This is a two-tier application: a **Spring Boot backend** in `Backend/` and a **React + TypeScript frontend** in `Frontend/`.
   - The root also contains deployment/configuration files and documentation artifacts (`.github/workflows/deploy.yml`, `staticwebapp.config.json`, `JIN24/`, `MOV24/`).

2. **Backend entry point and runtime**
   - The backend is a standalone Java application started from `se.liaprojekt.LiaProjektApplication`.
   - The presence of `pom.xml`, Maven wrapper files, and `application.properties` indicates a conventional **Spring Boot + Maven** runtime.

3. **API boundary**
   - HTTP endpoints are grouped into controllers: `UserController`, `CourseController`, `AiController`, and `HealthCheckController`.
   - `CorsConfig` shows the backend is explicitly configured to accept browser requests from the frontend origin, so the frontend-backend split is a real network boundary.

4. **Domain model boundary**
   - The backend domain is organized around a few feature areas:
     - **Course content:** `Course`, `Section`, `Material`
     - **Assessment/testing:** `TestQuestion`, `TestAnswer`, `TestResult`
     - **User and progress:** `User`, `UserProgress`, `AnsweredQuestion`
     - **AI support:** `AiCharacter`, `AiSession`
     - **Notifications:** `EmailNotification`
   - These are the core entities that likely map to persisted data and API payloads.

5. **Persistence layer**
   - Repositories such as `CourseRepository`, `UserRepository`, `SectionRepository`, `AiSessionRepository`, `AiCharacterRepository`, `UserProgressRepository`, `TestResultRepository`, and `EmailNotificationRepository` indicate the backend uses a **repository-based persistence layer**.
   - Because there is no visible `service/` package, the architecture appears **controller-centric**, with controllers likely coordinating business logic directly with repositories and entities.

6. **DTO and API contract layer**
   - `CourseRequest`, `CourseResponse`, `UserRequest`, and `UserResponse` define explicit request/response shapes.
   - This separates external API contracts from internal entity models, which is important for keeping the frontend insulated from persistence details.

7. **Error handling and robustness**
   - The backend includes a centralized exception subsystem: `GlobalExceptionHandler`, `ErrorResponse`, `BadRequestException`, `ConflictException`, and `ResourceNotFoundException`.
   - This means errors are normalized at the API boundary rather than handled ad hoc in individual controllers.

8. **AI feature subsystem**
   - `AiController`, `AiCharacter`, `AiSession`, and `AnsweredQuestion` suggest a dedicated AI-assisted learning flow.
   - Architecturally, this is a distinct feature path alongside courses/users, likely maintaining conversational or session state separate from course content and progress tracking.

9. **Frontend structure**
   - The frontend is a **Vite-powered React app** (`vite.config.ts`, `main.tsx`, `App.tsx`) written in **TypeScript**.
   - `src/services/api.ts` acts as the single client-side integration point to the backend API.
   - UI components are sparse and feature-oriented, including `HealthCheck.tsx` and `Message.tsx`, suggesting a small app surface with backend-driven data.

10. **Frontend-backend data flow**
    - The browser renders the React app, which calls backend endpoints through `src/services/api.ts`.
    - Backend controllers validate and process the request, interact with repositories/entities, and return DTO-based JSON responses.
    - The frontend likely consumes these responses directly for course/user/AI interactions.

11. **Health and connectivity**
    - `HealthCheckController` on the backend and `HealthCheck.tsx` on the frontend indicate a built-in connectivity or readiness check across the deployment boundary.
    - This is useful both for user-facing status and for deployment/runtime verification.

12. **Testing and quality boundary**
    - Backend tests exist for startup plus controller behavior: `LiaProjektApplicationTests`, `CourseControllerTest`, and `UserControllerTest`.
    - This shows the main automated verification focuses on application boot and API endpoints rather than isolated service-layer tests, which fits the visible controller-heavy structure.

13. **Deployment and hosting**
    - `.github/workflows/deploy.yml` indicates CI/CD automation.
    - `staticwebapp.config.json` strongly suggests the frontend is deployed as a static web app with route handling/configuration at the edge, while the backend is deployed separately or as a paired backend service.

14. **Documentation/analysis assets**
    - `JIN24/` contains design artifacts such as architecture, requirements analysis, ER diagrams, and class diagrams.
    - These are not runtime components, but they likely capture the intended domain model and are useful references when drawing an architecture diagram.

Main entry points: [`Frontend/src/main.tsx`](https://github.com/00adasod/liaprojekt/blob/main/Frontend/src/main.tsx) (React app), [`Backend/src/main/java/se/liaprojekt/LiaProjektApplication.java`](https://github.com/00adasod/liaprojekt/blob/main/Backend/src/main/java/se/liaprojekt/LiaProjektApplication.java) (Backend app), [`.github/workflows/deploy.yml`](https://github.com/00adasod/liaprojekt/blob/main/.github/workflows/deploy.yml) (Deploy flow), [`Backend/src/main/java/se/liaprojekt/config/CorsConfig.java`](https://github.com/00adasod/liaprojekt/blob/main/Backend/src/main/java/se/liaprojekt/config/CorsConfig.java) (CORS config)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_root["Repository"]
  node_app["Lia Projekt<br/>repo root"]
  node_deploy["Deploy flow<br/>ci/cd<br/>[deploy.yml]"]
  node_staticcfg["Static config<br/>hosting config"]
end

subgraph group_backend["Backend"]
  node_backend_app(("Backend app<br/>spring boot"))
  node_cors["CORS config<br/>http config<br/>[CorsConfig.java]"]
  node_controllers["Controllers<br/>api layer"]
  node_dto["DTOs<br/>api contract"]
  node_errors["Errors<br/>exception layer"]
  node_domain[("Domain models<br/>entity layer")]
  node_repos[("Repositories<br/>persistence")]
  node_btests["Backend tests<br/>test suite"]
end

subgraph group_frontend["Frontend"]
  node_frontend_app(("React app<br/>vite react<br/>[main.tsx]"))
  node_api_client["API client<br/>frontend service<br/>[api.ts]"]
  node_ui["UI views<br/>components"]
  node_health_ui["Health check<br/>ui component<br/>[HealthCheck.tsx]"]
end

subgraph group_docs["Docs"]
  node_docs_arch["Architecture notes<br/>design docs"]
end

node_app -->|"contains"| node_backend_app
node_app -->|"contains"| node_frontend_app
node_app -->|"ships with"| node_deploy
node_app -->|"ships with"| node_staticcfg
node_app -->|"documents"| node_docs_arch
node_backend_app -->|"boots"| node_controllers
node_backend_app -->|"configures"| node_cors
node_controllers -->|"uses"| node_dto
node_controllers -->|"orchestrates"| node_domain
node_controllers -->|"persists via"| node_repos
node_controllers -->|"raises"| node_errors
node_domain -->|"stored by"| node_repos
node_btests -->|"covers"| node_controllers
node_frontend_app -->|"imports"| node_api_client
node_frontend_app -->|"renders"| node_ui
node_ui -->|"includes"| node_health_ui
node_api_client -->|"calls"| node_controllers
node_cors -.->|"allows"| node_frontend_app
node_deploy -->|"deploys"| node_frontend_app
node_deploy -->|"deploys"| node_backend_app

click node_deploy "https://github.com/00adasod/liaprojekt/blob/main/.github/workflows/deploy.yml"
click node_staticcfg "https://github.com/00adasod/liaprojekt/blob/main/staticwebapp.config.json"
click node_backend_app "https://github.com/00adasod/liaprojekt/blob/main/Backend/src/main/java/se/liaprojekt/LiaProjektApplication.java"
click node_cors "https://github.com/00adasod/liaprojekt/blob/main/Backend/src/main/java/se/liaprojekt/config/CorsConfig.java"
click node_frontend_app "https://github.com/00adasod/liaprojekt/blob/main/Frontend/src/main.tsx"
click node_api_client "https://github.com/00adasod/liaprojekt/blob/main/Frontend/src/services/api.ts"
click node_health_ui "https://github.com/00adasod/liaprojekt/blob/main/Frontend/src/components/HealthCheck.tsx"
click node_docs_arch "https://github.com/00adasod/liaprojekt/blob/main/JIN24/Arkitekturdesign.md"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_app,node_deploy,node_staticcfg toneBlue
class node_backend_app,node_cors,node_controllers,node_dto,node_errors,node_domain,node_repos,node_btests toneAmber
class node_frontend_app,node_api_client,node_ui,node_health_ui toneMint
class node_docs_arch toneRose
```

## Components

### Repository

Top-level project and deployment assets

- **Lia Projekt**: repo root · Monorepo for backend, frontend, and deployment
- [Deploy flow](https://github.com/00adasod/liaprojekt/blob/main/.github/workflows/deploy.yml): ci/cd · GitHub Actions deployment pipeline · `.github/workflows/deploy.yml`
- [Static config](https://github.com/00adasod/liaprojekt/blob/main/staticwebapp.config.json): hosting config · Edge routing/config for static web deployment · `staticwebapp.config.json`

### Backend

Spring Boot API and persistence

- [Backend app](https://github.com/00adasod/liaprojekt/blob/main/Backend/src/main/java/se/liaprojekt/LiaProjektApplication.java): spring boot · Java API runtime entry point · `Backend/src/main/java/se/liaprojekt/LiaProjektApplication.java`
- [CORS config](https://github.com/00adasod/liaprojekt/blob/main/Backend/src/main/java/se/liaprojekt/config/CorsConfig.java): http config · Browser origin access across frontend/backend boundary · `Backend/src/main/java/se/liaprojekt/config/CorsConfig.java`
- **Controllers**: api layer · HTTP endpoints for courses, users, AI, and health
- **DTOs**: api contract · Request and response shapes exposed by the API
- **Errors**: exception layer · Centralized API error normalization and handling
- **Domain models**: entity layer · Core learning, AI, progress, and notification entities
- **Repositories**: persistence · Data access interfaces for persisted entities
- **Backend tests**: test suite · Startup and controller-level verification

### Frontend

React client and browser integration

- [React app](https://github.com/00adasod/liaprojekt/blob/main/Frontend/src/main.tsx): vite react · TypeScript SPA entry point · `Frontend/src/main.tsx`
- [API client](https://github.com/00adasod/liaprojekt/blob/main/Frontend/src/services/api.ts): frontend service · Single integration point to backend endpoints · `Frontend/src/services/api.ts`
- **UI views**: components · Small feature-oriented presentation layer
- [Health check](https://github.com/00adasod/liaprojekt/blob/main/Frontend/src/components/HealthCheck.tsx): ui component · Frontend connectivity/status view · `Frontend/src/components/HealthCheck.tsx`

### Docs

Design and analysis artifacts

- [Architecture notes](https://github.com/00adasod/liaprojekt/blob/main/JIN24/Arkitekturdesign.md): design docs · Architecture, requirements, and diagrams · `JIN24/Arkitekturdesign.md`

## Connections

- Lia Projekt → Backend app: contains · Backend runtime is part of the monorepo
- Lia Projekt → React app: contains · Frontend runtime is part of the monorepo
- Lia Projekt → Deploy flow: ships with · Repository includes CI/CD workflow
- Lia Projekt → Static config: ships with · Repository includes hosting configuration
- Lia Projekt → Architecture notes: documents · Design artifacts describe intended architecture
- Backend app → Controllers: boots · Spring Boot application hosts the API layer
- Backend app → CORS config: configures · Application enables browser access across origins
- Controllers → DTOs: uses · Endpoints exchange request/response DTOs
- Controllers → Domain models: orchestrates · Controllers coordinate domain entities directly
- Controllers → Repositories: persists via · Endpoints read and write through repositories
- Controllers → Errors: raises · API errors are normalized centrally
- Domain models → Repositories: stored by · Repositories manage the core entities
- Backend tests → Controllers: covers · Tests focus on controller behavior and startup
- React app → API client: imports · SPA uses a single backend integration module
- React app → UI views: renders · Application composes feature UI components
- UI views → Health check: includes · Health status is a visible frontend feature
- API client → Controllers: calls · Browser requests hit backend HTTP endpoints
- CORS config → React app: allows · Backend permits requests from the frontend origin
- Deploy flow → React app: deploys · Workflow builds and publishes the client app
- Deploy flow → Backend app: deploys · Workflow integrates backend delivery
