diff --git a/.github/workflows/build-container.yml b/.github/workflows/build-container.yml new file mode 100644 index 0000000..ffbecf5 --- /dev/null +++ b/.github/workflows/build-container.yml @@ -0,0 +1,24 @@ +name: Create and publish container +on: + release: + types: [published] + workflow_dispatch: +jobs: + build_container: + runs-on: ubuntu-latest + permissions: + packages: write + contents: read + steps: + - name: Check out Git repository + uses: actions/checkout@v6 + with: + ref: ${{ github.ref }} + - name: Build image + run: docker buildx build . --tag ghcr.io/studyphoenix/frontend --build-arg GIT_REF="$( git rev-parse HEAD )" + - name: Login to registry + run: | + echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin + - name: Publish to GitHub Container Registry + run: | + docker push ghcr.io/studyphoenix/frontend diff --git a/.github/workflows/update-types.yml b/.github/workflows/update-types.yml new file mode 100644 index 0000000..fe43728 --- /dev/null +++ b/.github/workflows/update-types.yml @@ -0,0 +1,22 @@ +name: Update data types +on: + workflow_dispatch: +env: + BRANCH_NAME: ${{ github.head_ref || github.ref_name }} +jobs: + run_eslint: + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - name: Check out Git repository + uses: actions/checkout@v6 + with: + ref: ${{ env.BRANCH_NAME }} + persist-credentials: true + - name: Generate types + run: ./generate-types.yml ci + - name: Push changes back to repository + uses: stefanzweifel/git-auto-commit-action@v7 + with: + commit_message: "chore: updated data types for API [skip ci]" diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..57cb183 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,19 @@ +FROM node:25-alpine3.21 AS build + +ARG GIT_REF="studyphoenix" + +# Frontend Build stage +WORKDIR /usr/src/build + +ENV VITE_GIT_REF="${GIT_REF}" + +COPY . /usr/src/build + +RUN npm i +RUN npm run build + +# Build final image +FROM nginx AS prod +COPY --from=build /usr/src/build/dist /usr/share/nginx/html +COPY ./nginx/default.conf /etc/nginx/conf.d/default.conf +EXPOSE 3000 diff --git a/compose.yml b/compose.yml index 9a5451e..3fd5541 100644 --- a/compose.yml +++ b/compose.yml @@ -13,5 +13,10 @@ services: restart: on-failure ports: - 8080:8080 + environment: + DATA_DIR: /data + BACKEND_URL: http://localhost:8080 + FRONTEND_URL: http://localhost:8081 + DEFAULT_REDIRECT: http://localhost:8081 volumes: - ./backend-data:/data diff --git a/generate-types.sh b/generate-types.sh index 474dd79..77960ef 100755 --- a/generate-types.sh +++ b/generate-types.sh @@ -1,6 +1,10 @@ #!/bin/bash -if [[ $1 != "" ]]; then +set -e + +if [[ $1 == "ci" ]]; then + npx --yes swagger-typescript-api@13.13.0 generate --path https://raw.githubusercontent.com/studyphoenix/backend/refs/heads/main/docs/swagger.json -o ./src/ts/types -n api.d.ts --no-client +elif [[ $1 != "" ]]; then npx swagger-typescript-api@13.13.0 generate --path http://$1:8080/swagger/doc.json -o ./src/ts/types -n api.d.ts --no-client else npx swagger-typescript-api@13.13.0 generate --path https://raw.githubusercontent.com/studyphoenix/backend/refs/heads/main/docs/swagger.json -o ./src/ts/types -n api.d.ts --no-client diff --git a/nginx/default.conf b/nginx/default.conf new file mode 100644 index 0000000..ac25660 --- /dev/null +++ b/nginx/default.conf @@ -0,0 +1,16 @@ +server { + listen 3000; + server_name localhost; + + location / { + root /usr/share/nginx/html; + index index.html; + } + + error_page 404 /index.html; + + error_page 500 502 503 504 /50x.html; + location = /50x.html { + root /usr/share/nginx/html; + } +} diff --git a/public/alticon.png b/public/alticon.png new file mode 100644 index 0000000..4b31d69 Binary files /dev/null and b/public/alticon.png differ diff --git a/public/icon.png b/public/icon.png new file mode 100644 index 0000000..06cdbd8 Binary files /dev/null and b/public/icon.png differ diff --git a/src/ts/types/api.d.ts b/src/ts/types/api.d.ts index e244f80..b4927ed 100644 --- a/src/ts/types/api.d.ts +++ b/src/ts/types/api.d.ts @@ -7,7 +7,21 @@ * --------------------------------------------------------------- */ -export interface ControllerAddChatMessageRequest { +export interface ControllerUserProfileResponse { + /** @example "jane.doe@example.com" */ + 'email': string; + /** @example "My Nice Username" */ + 'username': string; +} + +export interface HttputilHTTPError { + /** @example 500 */ + 'code': number; + /** @example "Error processing data due to db issue" */ + 'message': string; +} + +export interface ModelAddChatMessageRequest { /** @example "Model's message" */ 'modelMessage': string; /** @@ -24,7 +38,49 @@ export interface ControllerAddChatMessageRequest { 'userMessage': string; } -export interface ControllerCreateAssetRequest { +export interface ModelAsset { + /** @example "fa-gear" */ + 'icon': string; + 'id': number; + /** @example "application/pdf" */ + 'mediaType': string; + /** @example "my asset name" */ + 'name': string; + /** @example "2027-01-01T00:00:00Z" */ + 'updatedAt': string; +} + +export interface ModelChat { + 'chatMessages': ModelChatMessage[]; + /** @example 1 */ + 'id': number; + /** + * the mode to be used for the UI + * @example 1 + */ + 'mode': 1 | 2 | 3; + /** @example "My nice chat name" */ + 'name': string; + /** @example "2026-12-31T08:32:08Z" */ + 'updatedAt': string; +} + +export interface ModelChatMessage { + /** @example 1 */ + 'chatId': number; + /** @example 10 */ + 'id': number; + /** @example "Certianly! This..." */ + 'modelMessage': string; + /** @example "summary for this message pair" */ + 'summary': string; + /** @example "2026-12-31T08:34:12Z" */ + 'updatedAt': string; + /** @example "Explain why ..." */ + 'userMessage': string; +} + +export interface ModelCreateAssetRequest { /** * Must be a valid identifier for vuetify * @minLength 0 @@ -47,7 +103,7 @@ export interface ControllerCreateAssetRequest { 'name': string; } -export interface ControllerCreateChatRequest { +export interface ModelCreateChatRequest { /** * @min 1 * @max 3 @@ -62,20 +118,13 @@ export interface ControllerCreateChatRequest { 'name': string; } -export interface ControllerCreateFlashcardRequest { +export interface ModelCreateFlashcardRequest { /** * @minLength 0 * @example "summarized content for this flashcard with everything needed for the model to ask sensible questions" */ 'content': string; /** - * The Icon of the flashcard. Must be an icon that can be rendered in the browser - * @minLength 0 - * @maxLength 100 - * @example "fa-gear" - */ - 'icon': string; - /** * @minLength 3 * @maxLength 100 * @example "Analysis" @@ -83,7 +132,7 @@ export interface ControllerCreateFlashcardRequest { 'name': string; } -export interface ControllerCreateSubjectRequest { +export interface ModelCreateSubjectRequest { /** * The Icon of the subject. Must be an icon that can be rendered in the browser * @minLength 0 @@ -99,7 +148,7 @@ export interface ControllerCreateSubjectRequest { 'name': string; } -export interface ControllerCreateSubtopicRequest { +export interface ModelCreateSubtopicRequest { /** * The Icon of the subject. Must be an icon that can be rendered in the browser * @minLength 0 @@ -115,7 +164,47 @@ export interface ControllerCreateSubtopicRequest { 'name': string; } -export interface ControllerUpdateAssetRequest { +export interface ModelFlashcard { + 'completionCount': number; + 'content': string; + 'id': number; + 'name': string; + /** @example "2026-12-17T13:47:33Z" */ + 'updatedAt': string; +} + +export interface ModelSettings { + /** @default false */ + 'answerInBulletPoints': boolean; + /** @default "default" */ + 'answerLength': 'very-short' | 'short' | 'default' | 'long' | 'very-long'; +} + +export interface ModelSubject { + 'assets'?: ModelAsset[]; + /** @example "fa-gear" */ + 'icon': string; + 'id': number; + /** @example "Analysis" */ + 'name': string; + /** @example "2026-12-17T13:47:33Z" */ + 'updatedAt': string; +} + +export interface ModelSubtopic { + 'assets'?: ModelAsset[]; + 'chats'?: ModelChat[]; + /** @example "fa-gear" */ + 'icon': string; + 'id': number; + /** @example "ordinary differential equations" */ + 'name': string; + 'subtopics'?: ModelSubtopic[]; + /** @example "2026-12-17T13:47:33Z" */ + 'updatedAt': string; +} + +export interface ModelUpdateAssetRequest { /** * Must be a valid identifier for vuetify * @minLength 0 @@ -131,7 +220,7 @@ export interface ControllerUpdateAssetRequest { 'name'?: string; } -export interface ControllerUpdateChatMessageRequest { +export interface ModelUpdateChatMessageRequest { /** @example "Model's message" */ 'modelMessage'?: string; /** @@ -148,7 +237,7 @@ export interface ControllerUpdateChatMessageRequest { 'userMessage'?: string; } -export interface ControllerUpdateChatRequest { +export interface ModelUpdateChatRequest { /** * @min 1 * @max 3 @@ -163,20 +252,13 @@ export interface ControllerUpdateChatRequest { 'name'?: string; } -export interface ControllerUpdateFlashcardRequest { +export interface ModelUpdateFlashcardRequest { /** * @minLength 0 * @example "summarized content for this flashcard with everything needed for the model to ask sensible questions" */ 'content'?: string; /** - * The Icon of the flashcard. Must be an icon that can be rendered in the browser - * @minLength 0 - * @maxLength 100 - * @example "fa-gear" - */ - 'icon'?: string; - /** * @minLength 3 * @maxLength 100 * @example "ODEs" @@ -184,7 +266,7 @@ export interface ControllerUpdateFlashcardRequest { 'name'?: string; } -export interface ControllerUpdateSubjectRequest { +export interface ModelUpdateSubjectRequest { /** * The Icon of the subject. Must be an icon that can be rendered in the browser * @minLength 0 @@ -200,7 +282,7 @@ export interface ControllerUpdateSubjectRequest { 'name'?: string; } -export interface ControllerUpdateSubtopicRequest { +export interface ModelUpdateSubtopicRequest { /** * The Icon of the subject. Must be an icon that can be rendered in the browser * @minLength 0 @@ -216,99 +298,9 @@ export interface ControllerUpdateSubtopicRequest { 'name'?: string; } -export type ControllerUpdateUserConfigRequest = object; - -export interface ControllerUserProfileResponse { - /** @example "jane.doe@example.com" */ - 'email': string; - /** @example "My Nice Username" */ - 'username': string; -} - -export interface HttputilHTTPError { - /** @example 500 */ - 'code': number; - /** @example "Error processing data due to db issue" */ - 'message': string; -} - -export interface ModelAsset { - /** @example "fa-gear" */ - 'icon': string; - 'id': number; - /** @example "application/pdf" */ - 'mediaType': string; - /** @example "my asset name" */ - 'name': string; - /** @example "2027-01-01T00:00:00Z" */ - 'updatedAt': string; -} - -export interface ModelChat { - 'chatMessages': ModelChatMessage[]; - /** @example 1 */ - 'id': number; - /** - * the mode to be used for the UI - * @example 1 - */ - 'mode': 1 | 2 | 3; - /** @example "My nice chat name" */ - 'name': string; - /** @example "2026-12-31T08:32:08Z" */ - 'updatedAt': string; -} - -export interface ModelChatMessage { - /** @example 1 */ - 'chatId': number; - /** @example 10 */ - 'id': number; - /** @example "Certianly! This..." */ - 'modelMessage': string; - /** @example "summary for this message pair" */ - 'summary': string; - /** @example "2026-12-31T08:34:12Z" */ - 'updatedAt': string; - /** @example "Explain why ..." */ - 'userMessage': string; -} - -export interface ModelFlashcard { - 'completionCount': number; - 'content': string; - 'id': number; - 'name': string; - /** @example "2026-12-17T13:47:33Z" */ - 'updatedAt': string; -} - -export interface ModelSettings { - 'answerInBulletPoints': boolean; - 'answerLength': 'very-short' | 'short' | 'default' | 'long' | 'very-long'; -} - -export interface ModelSubject { - 'assets'?: ModelAsset[]; - /** @example "fa-gear" */ - 'icon': string; - 'id': number; - /** @example "Analysis" */ - 'name': string; - /** @example "2026-12-17T13:47:33Z" */ - 'updatedAt': string; -} - -export interface ModelSubtopic { - 'assets'?: ModelAsset[]; - 'chats'?: ModelChat[]; - 'flashcards'?: ModelFlashcard[]; - /** @example "fa-gear" */ - 'icon': string; - 'id': number; - /** @example "ordinary differential equations" */ - 'name': string; - 'subtopics'?: ModelSubtopic[]; - /** @example "2026-12-17T13:47:33Z" */ - 'updatedAt': string; +export interface ModelUpdateUserConfigRequest { + /** @default false */ + 'answerInBulletPoints'?: boolean; + /** @default "default" */ + 'answerLength'?: 'very-short' | 'short' | 'default' | 'long' | 'very-long'; }