diff --git a/README.md b/README.md index 6bf00309..b6f8699c 100644 --- a/README.md +++ b/README.md @@ -12,11 +12,11 @@ A minimal full-stack web application using Docker, Gradle, FastAPI and Angular. ## Build System: Gradle (Root) -| File | Purpose | -|------|---------| -| build.gradle | Root config defining Docker image name (`inse`), prefix, and version (`1.0.0`) | -| settings.gradle | Declares the three submodules: `:service`, `:webapp`, `:app` | -| libs.versions.toml | Centralized dependency version catalog | +| File | Purpose | +| ------------------ | ------------------------------------------------------------------------------ | +| build.gradle | Root config defining Docker image name (`inse`), prefix, and version (`1.0.0`) | +| settings.gradle | Declares the three submodules: `:service`, `:webapp`, `:app` | +| libs.versions.toml | Centralized dependency version catalog | Gradle orchestrates the entire build, including Docker image creation and the Angular frontend. @@ -26,36 +26,38 @@ Gradle orchestrates the entire build, including Docker image creation and the An A REST API running in Docker, exposing **three mounted FastAPI sub-applications**: -| Mount path | Description | -|---|---| -| `/inse-service` | Main resource API (items CRUD) | -| `/inse-webapp` | Serves the static Angular SPA | +| Mount path | Description | +| --------------- | ------------------------------------- | +| `/inse-service` | Main resource API (items CRUD) | +| `/inse-webapp` | Serves the static Angular SPA | | `/inse-account` | Authentication service (login/tokens) | ### Key source files in inse: -| File | Role | -|---|---| -| main.py | FastAPI app bootstrap, mounts the three sub-apps | -| service.py | CRUD REST endpoints for `Item` resources (GET, POST, PUT, DELETE), protected by JWT roles | -| model.py | Pydantic response models: `Item`, `ItemCreate`, `ItemPage` (generic pagination) | -| schema.py | SQLAlchemy ORM table definitions — `Item` table in SQLite | -| logic.py | Business logic layer (called by the service) | -| database.py | SQLAlchemy engine/session setup, reads from `config` | -| security.py | JWT decoding, `Principal` / `Account` models, role-based access via `roles_allowed()` | -| config.py | App settings via env vars prefixed `inse_` (DB URL, auth secret, feature flags) | -| webapp.py | Mounts the static Angular build as a `StaticFiles` app | -| util.py | Utility helpers (e.g. `raise_not_found_if_none`) | +| File | Role | +| ----------- | ----------------------------------------------------------------------------------------- | +| main.py | FastAPI app bootstrap, mounts the three sub-apps | +| service.py | CRUD REST endpoints for `Item` resources (GET, POST, PUT, DELETE), protected by JWT roles | +| model.py | Pydantic response models: `Item`, `ItemCreate`, `ItemPage` (generic pagination) | +| schema.py | SQLAlchemy ORM table definitions — `Item` table in SQLite | +| logic.py | Business logic layer (called by the service) | +| database.py | SQLAlchemy engine/session setup, reads from `config` | +| security.py | JWT decoding, `Principal` / `Account` models, role-based access via `roles_allowed()` | +| config.py | App settings via env vars prefixed `inse_` (DB URL, auth secret, feature flags) | +| webapp.py | Mounts the static Angular build as a `StaticFiles` app | +| util.py | Utility helpers (e.g. `raise_not_found_if_none`) | ### `account/` sub-package (account): Handles authentication independently: + - account/service.py — `POST /auth/id` (username+password → identity token) and `POST /auth/access` (ID token → access token) - account/logic.py — validates users from users.json - account/model.py — Pydantic models for `IdentityGrant`, `AccessGrant` - account/security.py — JWT signing ### Data & Config: + - users.json — Hardcoded user accounts (superadmin/user) - log-config.yaml — Logging configuration - entrypoint.sh — Docker entrypoint script @@ -69,20 +71,20 @@ An **Angular 18 SPA** using Angular Material, built with Node.js + Gradle. ### App structure in app: -| Directory/File | Role | -|---|---| -| app.routes.ts | Routes: `/login` → `AppLoginComponent`, `/items` → `ListItemComponent` (guarded), `**` → redirect to login | -| app.config.ts | Angular app bootstrap config (providers, interceptors) | -| `app-login/` | Login form component | -| `app-layout/` | Shell/layout wrapper component | -| `app-menu/` | Navigation menu component | -| `list-item/` | The main feature page — lists `Item` resources with pagination | -| `confirmation-dialog/` | Reusable dialog for destructive actions | -| `guards/` | Route guards: `user.guard.ts` (authenticated), `admin.guard.ts` (admin role) | -| `interceptors/` | authentication.interceptor.ts — attaches JWT Bearer token to all requests except auth endpoints | -| `services/` | api.service.ts (CRUD calls to `/inse-service`), `credential.service.ts` (token management), `pagination.service.ts` | -| `pipes/` | `truncate.pipe.ts` — truncates long strings in templates | -| `utils/` | Utility helpers | +| Directory/File | Role | +| ---------------------- | ------------------------------------------------------------------------------------------------------------------- | +| app.routes.ts | Routes: `/login` → `AppLoginComponent`, `/items` → `ListItemComponent` (guarded), `**` → redirect to login | +| app.config.ts | Angular app bootstrap config (providers, interceptors) | +| `app-login/` | Login form component | +| `app-layout/` | Shell/layout wrapper component | +| `app-menu/` | Navigation menu component | +| `list-item/` | The main feature page — lists `Item` resources with pagination | +| `confirmation-dialog/` | Reusable dialog for destructive actions | +| `guards/` | Route guards: `user.guard.ts` (authenticated), `admin.guard.ts` (admin role) | +| `interceptors/` | authentication.interceptor.ts — attaches JWT Bearer token to all requests except auth endpoints | +| `services/` | api.service.ts (CRUD calls to `/inse-service`), `credential.service.ts` (token management), `pagination.service.ts` | +| `pipes/` | `truncate.pipe.ts` — truncates long strings in templates | +| `utils/` | Utility helpers | --- @@ -111,7 +113,6 @@ Browser **Auth flow**: The Angular interceptor calls `/inse-account/auth/id` with credentials → receives an ID token → exchanges it for an access JWT via `/inse-account/auth/access` → attaches the access token as `Authorization: Bearer` on all subsequent requests. The backend's security.py decodes and validates this JWT to enforce role-based access control (`SUPER_ADMIN`, `UNI_ADMIN`). - ## Prerequisites - Docker @@ -155,7 +156,7 @@ The app will be available at `http://localhost:8080/inse-webapp/`. Defined in `service/src/data/users.json`: -| Username | Password | Role | -|-------------|-------------|-------------| -| superadmin | superadmin | SUPER_ADMIN | -| user | user | UNI_ADMIN | \ No newline at end of file +| Username | Password | Role | +| ---------- | ---------- | ----------- | +| superadmin | superadmin | SUPER_ADMIN | +| user | user | UNI_ADMIN | diff --git a/service/README.md b/service/README.md index da2cffce..ca09165c 100644 --- a/service/README.md +++ b/service/README.md @@ -10,8 +10,8 @@ To build the container: `./gradlew :service:build` To launch the service with hot-reload: `./gradlew :service:serve` -This mounts the source directory into the container and enables uvicorn hot-reloading. Press *ENTER* to stop. +This mounts the source directory into the container and enables uvicorn hot-reloading. Press _ENTER_ to stop. ## Testing -Run tests: `./gradlew :service:test` \ No newline at end of file +Run tests: `./gradlew :service:test` diff --git a/service/src/data/topic_hierarchy_cache.json b/service/src/data/topic_hierarchy_cache.json index 01664b6b..6e6c2acc 100644 --- a/service/src/data/topic_hierarchy_cache.json +++ b/service/src/data/topic_hierarchy_cache.json @@ -27095,4 +27095,4 @@ "field": "Medicine", "domain": "Health Sciences" } -} \ No newline at end of file +} diff --git a/service/src/data/users.json b/service/src/data/users.json index 2ff26e5a..6d5b0836 100644 --- a/service/src/data/users.json +++ b/service/src/data/users.json @@ -1,18 +1,18 @@ { - "users": [ - { - "account": 0, - "organization": 0, - "username": "superadmin", - "password": "superadmin", - "superadmin": true - }, - { - "account": 1, - "organization": 1, - "username": "user", - "password": "user", - "superadmin": false - } - ] -} \ No newline at end of file + "users": [ + { + "account": 0, + "organization": 0, + "username": "superadmin", + "password": "superadmin", + "superadmin": true + }, + { + "account": 1, + "organization": 1, + "username": "user", + "password": "user", + "superadmin": false + } + ] +} diff --git a/service/src/main/log-config.yaml b/service/src/main/log-config.yaml index 6f53e485..921c7398 100644 --- a/service/src/main/log-config.yaml +++ b/service/src/main/log-config.yaml @@ -31,9 +31,9 @@ loggers: level: INFO handlers: - default - propagate: no + propagate: no root: level: DEBUG handlers: - default - propagate: no \ No newline at end of file + propagate: no diff --git a/service/src/main/webapp/index.html b/service/src/main/webapp/index.html index 0e5e5ce1..5b918545 100644 --- a/service/src/main/webapp/index.html +++ b/service/src/main/webapp/index.html @@ -1,9 +1,9 @@ -
-This page is a stub for the webapp that will be replaced.
- - \ No newline at end of file + +This page is a stub for the webapp that will be replaced.
+ +