mirror of
https://github.com/dat515-2025/Group-8.git
synced 2026-03-22 06:57:47 +01:00
Compare commits
1 Commits
test_arm_b
...
f3eb1f8cdd
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f3eb1f8cdd |
4
.github/workflows/build-image.yaml
vendored
4
.github/workflows/build-image.yaml
vendored
@@ -15,7 +15,7 @@ on:
|
||||
context:
|
||||
description: "Docker build context path"
|
||||
required: false
|
||||
default: "7project/src/backend"
|
||||
default: "7project/backend"
|
||||
type: string
|
||||
pr_number:
|
||||
description: "PR number (required when mode=pr)"
|
||||
@@ -94,7 +94,7 @@ jobs:
|
||||
tags: |
|
||||
${{ env.IMAGE_REPO }}:${{ env.TAG1 }}
|
||||
${{ env.IMAGE_REPO }}:${{ env.TAG2 }}
|
||||
platforms: linux/arm64,linux/amd64
|
||||
platforms: linux/amd64
|
||||
|
||||
- name: Set outputs
|
||||
id: set
|
||||
|
||||
21
.github/workflows/deploy-pr.yaml
vendored
21
.github/workflows/deploy-pr.yaml
vendored
@@ -9,11 +9,6 @@ permissions:
|
||||
pull-requests: write
|
||||
|
||||
jobs:
|
||||
test:
|
||||
name: Run Python Tests
|
||||
if: github.event.action != 'closed'
|
||||
uses: ./.github/workflows/run-tests.yml
|
||||
|
||||
build:
|
||||
if: github.event.action != 'closed'
|
||||
name: Build and push image (reusable)
|
||||
@@ -21,7 +16,7 @@ jobs:
|
||||
with:
|
||||
mode: pr
|
||||
image_repo: lukastrkan/cc-app-demo
|
||||
context: 7project/src/backend
|
||||
context: 7project/backend
|
||||
pr_number: ${{ github.event.pull_request.number }}
|
||||
secrets: inherit
|
||||
|
||||
@@ -33,7 +28,7 @@ jobs:
|
||||
runner: vhs
|
||||
mode: pr
|
||||
pr_number: ${{ github.event.pull_request.number }}
|
||||
base_domain: ${{ vars.PROD_DOMAIN }}
|
||||
base_domain: ${{ vars.DEV_BASE_DOMAIN }}
|
||||
secrets: inherit
|
||||
|
||||
frontend:
|
||||
@@ -77,7 +72,7 @@ jobs:
|
||||
|
||||
- name: Helm upgrade/install PR preview
|
||||
env:
|
||||
DEV_BASE_DOMAIN: ${{ vars.BASE_DOMAIN }}
|
||||
DEV_BASE_DOMAIN: ${{ secrets.BASE_DOMAIN }}
|
||||
RABBITMQ_PASSWORD: ${{ secrets.PROD_RABBITMQ_PASSWORD }}
|
||||
DB_PASSWORD: ${{ secrets.PROD_DB_PASSWORD }}
|
||||
DIGEST: ${{ needs.build.outputs.digest }}
|
||||
@@ -85,14 +80,13 @@ jobs:
|
||||
DOMAIN_SCHEME: "${{ needs.get_urls.outputs.backend_url_scheme }}"
|
||||
FRONTEND_DOMAIN: "${{ needs.get_urls.outputs.frontend_url }}"
|
||||
FRONTEND_DOMAIN_SCHEME: "${{ needs.get_urls.outputs.frontend_url_scheme }}"
|
||||
UNIRATE_API_KEY: ${{ secrets.UNIRATE_API_KEY }}
|
||||
run: |
|
||||
PR=${{ github.event.pull_request.number }}
|
||||
RELEASE=myapp-pr-$PR
|
||||
NAMESPACE=pr-$PR
|
||||
helm upgrade --install "$RELEASE" ./7project/src/charts/myapp-chart \
|
||||
helm upgrade --install "$RELEASE" ./7project/charts/myapp-chart \
|
||||
-n "$NAMESPACE" --create-namespace \
|
||||
-f 7project/src/charts/myapp-chart/values-dev.yaml \
|
||||
-f 7project/charts/myapp-chart/values-dev.yaml \
|
||||
--set prNumber="$PR" \
|
||||
--set deployment="pr-$PR" \
|
||||
--set domain="$DOMAIN" \
|
||||
@@ -101,10 +95,7 @@ jobs:
|
||||
--set frontend_domain_scheme="$FRONTEND_DOMAIN_SCHEME" \
|
||||
--set image.digest="$DIGEST" \
|
||||
--set-string rabbitmq.password="$RABBITMQ_PASSWORD" \
|
||||
--set-string database.password="$DB_PASSWORD" \
|
||||
--set-string database.encryptionSecret="$PR" \
|
||||
--set-string app.name="finance-tracker-pr-$PR" \
|
||||
--set-string unirate.key="$UNIRATE_API_KEY"
|
||||
--set-string database.password="$DB_PASSWORD"
|
||||
|
||||
- name: Post preview URLs as PR comment
|
||||
uses: actions/github-script@v7
|
||||
|
||||
44
.github/workflows/deploy-prod.yaml
vendored
44
.github/workflows/deploy-prod.yaml
vendored
@@ -4,9 +4,9 @@ on:
|
||||
push:
|
||||
branches: [ "main" ]
|
||||
paths:
|
||||
- ../../7project/src/backend/**
|
||||
- ../../7project/src/frontend/**
|
||||
- ../../7project/src/charts/myapp-chart/**
|
||||
- 7project/backend/**
|
||||
- 7project/frontend/**
|
||||
- 7project/charts/myapp-chart/**
|
||||
- .github/workflows/deploy-prod.yaml
|
||||
- .github/workflows/build-image.yaml
|
||||
- .github/workflows/frontend-pages.yml
|
||||
@@ -21,23 +21,17 @@ concurrency:
|
||||
cancel-in-progress: false
|
||||
|
||||
jobs:
|
||||
test:
|
||||
name: Run Python Tests
|
||||
uses: ./.github/workflows/run-tests.yml
|
||||
|
||||
build:
|
||||
name: Build and push image (reusable)
|
||||
needs: [test]
|
||||
uses: ./.github/workflows/build-image.yaml
|
||||
with:
|
||||
mode: prod
|
||||
image_repo: lukastrkan/cc-app-demo
|
||||
context: 7project/src/backend
|
||||
context: 7project/backend
|
||||
secrets: inherit
|
||||
|
||||
get_urls:
|
||||
name: Generate Production URLs
|
||||
needs: [test]
|
||||
uses: ./.github/workflows/url_generator.yml
|
||||
with:
|
||||
mode: prod
|
||||
@@ -91,21 +85,11 @@ jobs:
|
||||
BANKID_CLIENT_SECRET: ${{ secrets.BANKID_CLIENT_SECRET }}
|
||||
MOJEID_CLIENT_ID: ${{ secrets.MOJEID_CLIENT_ID }}
|
||||
MOJEID_CLIENT_SECRET: ${{ secrets.MOJEID_CLIENT_SECRET }}
|
||||
CSAS_CLIENT_ID: ${{ secrets.CSAS_CLIENT_ID }}
|
||||
CSAS_CLIENT_SECRET: ${{ secrets.CSAS_CLIENT_SECRET }}
|
||||
SENTRY_DSN: ${{ secrets.SENTRY_DSN }}
|
||||
SMTP_HOST: ${{ secrets.SMTP_HOST }}
|
||||
SMTP_PORT: ${{ secrets.SMTP_PORT }}
|
||||
SMTP_USERNAME: ${{ secrets.SMTP_USERNAME }}
|
||||
SMTP_PASSWORD: ${{ secrets.SMTP_PASSWORD }}
|
||||
SMTP_USE_TLS: ${{ secrets.SMTP_USE_TLS }}
|
||||
SMTP_USE_SSL: ${{ secrets.SMTP_USE_SSL }}
|
||||
SMTP_FROM: ${{ secrets.SMTP_FROM }}
|
||||
UNIRATE_API_KEY: ${{ secrets.UNIRATE_API_KEY }}
|
||||
|
||||
run: |
|
||||
helm upgrade --install myapp ./7project/src/charts/myapp-chart \
|
||||
helm upgrade --install myapp ./7project/charts/myapp-chart \
|
||||
-n prod --create-namespace \
|
||||
-f 7project/src/charts/myapp-chart/values-prod.yaml \
|
||||
-f 7project/charts/myapp-chart/values-prod.yaml \
|
||||
--set deployment="prod" \
|
||||
--set domain="$DOMAIN" \
|
||||
--set domain_scheme="$DOMAIN_SCHEME" \
|
||||
@@ -117,16 +101,4 @@ jobs:
|
||||
--set-string oauth.bankid.clientId="$BANKID_CLIENT_ID" \
|
||||
--set-string oauth.bankid.clientSecret="$BANKID_CLIENT_SECRET" \
|
||||
--set-string oauth.mojeid.clientId="$MOJEID_CLIENT_ID" \
|
||||
--set-string oauth.mojeid.clientSecret="$MOJEID_CLIENT_SECRET" \
|
||||
--set-string oauth.csas.clientId="$CSAS_CLIENT_ID" \
|
||||
--set-string oauth.csas.clientSecret="$CSAS_CLIENT_SECRET" \
|
||||
--set-string sentry_dsn="$SENTRY_DSN" \
|
||||
--set-string database.encryptionSecret="${{ secrets.PROD_DB_ENCRYPTION_KEY }}" \
|
||||
--set-string smtp.host="$SMTP_HOST" \
|
||||
--set smtp.port="$SMTP_PORT" \
|
||||
--set-string smtp.username="$SMTP_USERNAME" \
|
||||
--set-string smtp.password="$SMTP_PASSWORD" \
|
||||
--set-string smtp.tls="$SMTP_USE_TLS" \
|
||||
--set-string smtp.ssl="$SMTP_USE_SSL" \
|
||||
--set-string smtp.from="$SMTP_FROM" \
|
||||
--set-string unirate.key="$UNIRATE_API_KEY"
|
||||
--set-string oauth.mojeid.clientSecret="$MOJEID_CLIENT_SECRET"
|
||||
6
.github/workflows/frontend-pages.yml
vendored
6
.github/workflows/frontend-pages.yml
vendored
@@ -35,7 +35,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
defaults:
|
||||
run:
|
||||
working-directory: 7project/src/frontend
|
||||
working-directory: 7project/frontend
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
@@ -45,7 +45,7 @@ jobs:
|
||||
with:
|
||||
node-version: '20'
|
||||
cache: 'npm'
|
||||
cache-dependency-path: 7project/src/frontend/package-lock.json
|
||||
cache-dependency-path: 7project/frontend/package-lock.json
|
||||
|
||||
- name: Install dependencies
|
||||
run: npm ci
|
||||
@@ -61,7 +61,7 @@ jobs:
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: frontend-dist
|
||||
path: 7project/src/frontend/dist
|
||||
path: 7project/frontend/dist
|
||||
|
||||
deploy:
|
||||
name: Deploy to Cloudflare Pages
|
||||
|
||||
66
.github/workflows/run-tests.yml
vendored
66
.github/workflows/run-tests.yml
vendored
@@ -1,66 +0,0 @@
|
||||
name: Run Python Tests
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
|
||||
jobs:
|
||||
build-and-test:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
services:
|
||||
mariadb:
|
||||
image: mariadb:11.4
|
||||
env:
|
||||
MARIADB_ROOT_PASSWORD: rootpw
|
||||
MARIADB_DATABASE: group_project
|
||||
MARIADB_USER: appuser
|
||||
MARIADB_PASSWORD: apppass
|
||||
ports:
|
||||
- 3306:3306
|
||||
options: >-
|
||||
--health-cmd="mariadb-admin ping -h 127.0.0.1 -u root -prootpw --silent"
|
||||
--health-interval=5s
|
||||
--health-timeout=2s
|
||||
--health-retries=20
|
||||
|
||||
env:
|
||||
MARIADB_HOST: 127.0.0.1
|
||||
MARIADB_PORT: "3306"
|
||||
MARIADB_DB: group_project
|
||||
MARIADB_USER: appuser
|
||||
MARIADB_PASSWORD: apppass
|
||||
# Ensure the application uses MariaDB (async) during tests
|
||||
DATABASE_URL: mysql+asyncmy://appuser:apppass@127.0.0.1:3306/group_project
|
||||
DISABLE_METRICS: "1"
|
||||
|
||||
steps:
|
||||
- name: Check out repository code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Python 3.11
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: '3.11'
|
||||
|
||||
- name: Add test dependencies to requirements
|
||||
run: |
|
||||
echo "pytest==8.4.2" >> ./7project/src/backend/requirements.txt
|
||||
echo "pytest-asyncio==1.2.0" >> ./7project/src/backend/requirements.txt
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
pip install -r ./7project/src/backend/requirements.txt
|
||||
|
||||
- name: Run Alembic migrations
|
||||
run: |
|
||||
alembic upgrade head
|
||||
working-directory: ./7project/src/backend
|
||||
|
||||
- name: Run tests with pytest
|
||||
env:
|
||||
PYTEST_RUN_CONFIG: "True"
|
||||
run: pytest
|
||||
working-directory: ./7project/src/backend
|
||||
8
.idea/.gitignore
generated
vendored
8
.idea/.gitignore
generated
vendored
@@ -1,8 +0,0 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# Editor-based HTTP Client requests
|
||||
/httpRequests/
|
||||
# Datasource local storage ignored files
|
||||
/dataSources/
|
||||
/dataSources.local.xml
|
||||
16
7project/.gitignore
vendored
16
7project/.gitignore
vendored
@@ -1,8 +1,8 @@
|
||||
/src/tofu/controlplane.yaml
|
||||
/src/tofu/kubeconfig
|
||||
/src/tofu/talosconfig
|
||||
/src/tofu/terraform.tfstate
|
||||
/src/tofu/terraform.tfstate.backup
|
||||
/src/tofu/worker.yaml
|
||||
/src/tofu/.terraform.lock.hcl
|
||||
/src/tofu/.terraform/
|
||||
/tofu/controlplane.yaml
|
||||
/tofu/kubeconfig
|
||||
/tofu/talosconfig
|
||||
/tofu/terraform.tfstate
|
||||
/tofu/terraform.tfstate.backup
|
||||
/tofu/worker.yaml
|
||||
/tofu/.terraform.lock.hcl
|
||||
/tofu/.terraform/
|
||||
|
||||
8
7project/.idea/.gitignore
generated
vendored
8
7project/.idea/.gitignore
generated
vendored
@@ -1,8 +0,0 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# Editor-based HTTP Client requests
|
||||
/httpRequests/
|
||||
# Datasource local storage ignored files
|
||||
/dataSources/
|
||||
/dataSources.local.xml
|
||||
@@ -1,6 +1,43 @@
|
||||
# Personal Finance Tracker
|
||||
## Folder Structure
|
||||
- meetings: Contains note from meetings
|
||||
- scr: Source code for the project
|
||||
- checklist: Project checklist and self assessment tracking
|
||||
- report.md: Detailed report of the project
|
||||
# Lab 6: Design Document for Course Project
|
||||
|
||||
| Lab 6: | Design Document for Course Project |
|
||||
| ----------- | ---------------------------------- |
|
||||
| Subject: | DAT515 Cloud Computing |
|
||||
| Deadline: | **September 19, 2025 23:59** |
|
||||
| Grading: | No Grade |
|
||||
| Submission: | Group |
|
||||
|
||||
## Table of Contents
|
||||
|
||||
- [Table of Contents](#table-of-contents)
|
||||
- [1. Design Document (design.md)](#1-design-document-designmd)
|
||||
|
||||
The design document is the first deliverable for your project.
|
||||
We separated this out as a separate deliverable, with its own deadline, to ensure that you have a clear plan before you start coding.
|
||||
This part only needs a cursory review by the teaching staff to ensure it is sufficiently comprehensive, while still realistic.
|
||||
The teaching staff will assign you to a project mentor who will provide guidance and support throughout the development process.
|
||||
|
||||
## 1. Design Document (design.md)
|
||||
|
||||
You are required to prepare a design document for your application.
|
||||
The design doc should be brief, well-organized and easy to understand.
|
||||
The design doc should be prepared in markdown format and named `design.md` and submitted in the project group's repository.
|
||||
Remember that you can use [mermaid diagrams](https://github.com/mermaid-js/mermaid#readme) in markdown files.
|
||||
|
||||
The design doc **should include** the following sections:
|
||||
|
||||
- **Overview**: A brief description of the application and its purpose.
|
||||
- **Architecture**: The high-level architecture of the application, including components, interactions, and data flow.
|
||||
- **Technologies**: The cloud computing technologies or services used in the application.
|
||||
- **Deployment**: The deployment strategy for the application, including any infrastructure requirements.
|
||||
|
||||
The design document should be updated throughout the development process and reflect the final implementation of your project.
|
||||
|
||||
Optional sections may include:
|
||||
|
||||
- Security: The security measures implemented in the application to protect data and resources.
|
||||
- Scalability: The scalability considerations for the application, including load balancing and auto-scaling.
|
||||
- Monitoring: The monitoring and logging strategy for the application to track performance and detect issues.
|
||||
- Disaster Recovery: The disaster recovery plan for the application to ensure business continuity in case of failures.
|
||||
- Cost Analysis: The cost analysis of running the application on the cloud, including pricing models and cost-saving strategies.
|
||||
- References: Any external sources or references used in the design document.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
FROM python:3.11-trixie
|
||||
FROM python:3.11-slim
|
||||
|
||||
WORKDIR /app
|
||||
COPY requirements.txt .
|
||||
@@ -25,8 +25,7 @@ if not DATABASE_URL:
|
||||
|
||||
SYNC_DATABASE_URL = DATABASE_URL.replace("+asyncmy", "+pymysql")
|
||||
|
||||
host_env = os.getenv("MARIADB_HOST", "localhost")
|
||||
ssl_enabled = host_env not in {"localhost", "127.0.0.1"}
|
||||
ssl_enabled = os.getenv("MARIADB_HOST", "localhost") != "localhost"
|
||||
connect_args = {"ssl": {"ssl": True}} if ssl_enabled else {}
|
||||
|
||||
def run_migrations_offline() -> None:
|
||||
@@ -24,23 +24,6 @@ async def delete_me(
|
||||
await user_manager.delete(user)
|
||||
|
||||
# Keep existing paths as-is under /auth/* and /users/*
|
||||
from fastapi import Request, Response
|
||||
from app.core.security import revoke_token, extract_bearer_token
|
||||
|
||||
|
||||
@router.post(
|
||||
"/auth/jwt/logout",
|
||||
status_code=status.HTTP_204_NO_CONTENT,
|
||||
tags=["auth"],
|
||||
summary="Log out and revoke current token",
|
||||
)
|
||||
async def custom_logout(request: Request) -> Response:
|
||||
"""Revoke the current bearer token so it cannot be used anymore."""
|
||||
token = extract_bearer_token(request)
|
||||
if token:
|
||||
revoke_token(token)
|
||||
return Response(status_code=status.HTTP_204_NO_CONTENT)
|
||||
|
||||
router.include_router(
|
||||
fastapi_users.get_auth_router(auth_backend), prefix="/auth/jwt", tags=["auth"]
|
||||
)
|
||||
@@ -5,7 +5,7 @@ from sqlalchemy import select, delete
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
from app.models.categories import Category
|
||||
from app.schemas.category import CategoryCreate, CategoryRead, CategoryUpdate
|
||||
from app.schemas.category import CategoryCreate, CategoryRead
|
||||
from app.services.db import get_async_session
|
||||
from app.services.user_service import current_active_user
|
||||
from app.models.user import User
|
||||
@@ -43,37 +43,6 @@ async def list_categories(
|
||||
return list(res.scalars())
|
||||
|
||||
|
||||
@router.patch("/{category_id}", response_model=CategoryRead)
|
||||
async def update_category(
|
||||
category_id: int,
|
||||
payload: CategoryUpdate,
|
||||
session: AsyncSession = Depends(get_async_session),
|
||||
user: User = Depends(current_active_user),
|
||||
):
|
||||
res = await session.execute(
|
||||
select(Category).where(Category.id == category_id, Category.user_id == user.id)
|
||||
)
|
||||
category = res.scalar_one_or_none()
|
||||
if not category:
|
||||
raise HTTPException(status_code=404, detail="Category not found")
|
||||
|
||||
# If name changed, check uniqueness per user
|
||||
if payload.name is not None and payload.name != category.name:
|
||||
dup = await session.execute(
|
||||
select(Category.id).where(Category.user_id == user.id, Category.name == payload.name)
|
||||
)
|
||||
if dup.scalar_one_or_none() is not None:
|
||||
raise HTTPException(status_code=409, detail="Category with this name already exists")
|
||||
category.name = payload.name
|
||||
|
||||
if payload.description is not None:
|
||||
category.description = payload.description
|
||||
|
||||
await session.commit()
|
||||
await session.refresh(category)
|
||||
return category
|
||||
|
||||
|
||||
@router.get("/{category_id}", response_model=CategoryRead)
|
||||
async def get_category(
|
||||
category_id: int,
|
||||
@@ -1,8 +1,7 @@
|
||||
from typing import List, Optional
|
||||
from datetime import date
|
||||
|
||||
from fastapi import APIRouter, Depends, HTTPException, status
|
||||
from sqlalchemy import select, and_, func
|
||||
from sqlalchemy import select
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
from app.models.transaction import Transaction
|
||||
@@ -24,7 +23,6 @@ def _to_read_model(tx: Transaction) -> TransactionRead:
|
||||
id=tx.id,
|
||||
amount=tx.amount,
|
||||
description=tx.description,
|
||||
date=tx.date,
|
||||
category_ids=[c.id for c in (tx.categories or [])],
|
||||
)
|
||||
|
||||
@@ -35,21 +33,7 @@ async def create_transaction(
|
||||
session: AsyncSession = Depends(get_async_session),
|
||||
user: User = Depends(current_active_user),
|
||||
):
|
||||
# Build transaction; set `date` only if provided to let DB default apply otherwise
|
||||
tx_kwargs = dict(
|
||||
amount=payload.amount,
|
||||
description=payload.description,
|
||||
user_id=user.id,
|
||||
)
|
||||
if payload.date is not None:
|
||||
parsed_date = payload.date
|
||||
if isinstance(parsed_date, str):
|
||||
try:
|
||||
parsed_date = date.fromisoformat(parsed_date)
|
||||
except ValueError:
|
||||
raise HTTPException(status_code=400, detail="Invalid date format, expected YYYY-MM-DD")
|
||||
tx_kwargs["date"] = parsed_date
|
||||
tx = Transaction(**tx_kwargs)
|
||||
tx = Transaction(amount=payload.amount, description=payload.description, user_id=user.id)
|
||||
|
||||
# Attach categories if provided (and owned by user)
|
||||
if payload.category_ids:
|
||||
@@ -76,18 +60,11 @@ async def create_transaction(
|
||||
|
||||
@router.get("/", response_model=List[TransactionRead])
|
||||
async def list_transactions(
|
||||
start_date: Optional[date] = None,
|
||||
end_date: Optional[date] = None,
|
||||
session: AsyncSession = Depends(get_async_session),
|
||||
user: User = Depends(current_active_user),
|
||||
):
|
||||
cond = [Transaction.user_id == user.id]
|
||||
if start_date is not None:
|
||||
cond.append(Transaction.date >= start_date)
|
||||
if end_date is not None:
|
||||
cond.append(Transaction.date <= end_date)
|
||||
res = await session.execute(
|
||||
select(Transaction).where(and_(*cond)).order_by(Transaction.date, Transaction.id)
|
||||
select(Transaction).where(Transaction.user_id == user.id).order_by(Transaction.id)
|
||||
)
|
||||
txs = list(res.scalars())
|
||||
# Eagerly load categories for each transaction
|
||||
@@ -96,36 +73,6 @@ async def list_transactions(
|
||||
return [_to_read_model(tx) for tx in txs]
|
||||
|
||||
|
||||
@router.get("/balance_series")
|
||||
async def get_balance_series(
|
||||
start_date: Optional[date] = None,
|
||||
end_date: Optional[date] = None,
|
||||
session: AsyncSession = Depends(get_async_session),
|
||||
user: User = Depends(current_active_user),
|
||||
):
|
||||
cond = [Transaction.user_id == user.id]
|
||||
if start_date is not None:
|
||||
cond.append(Transaction.date >= start_date)
|
||||
if end_date is not None:
|
||||
cond.append(Transaction.date <= end_date)
|
||||
res = await session.execute(
|
||||
select(Transaction).where(and_(*cond)).order_by(Transaction.date, Transaction.id)
|
||||
)
|
||||
txs = list(res.scalars())
|
||||
# Group by date and accumulate
|
||||
daily = {}
|
||||
for tx in txs:
|
||||
key = tx.date.isoformat() if hasattr(tx.date, 'isoformat') else str(tx.date)
|
||||
daily[key] = daily.get(key, 0.0) + float(tx.amount)
|
||||
# Build cumulative series sorted by date
|
||||
series = []
|
||||
running = 0.0
|
||||
for d in sorted(daily.keys()):
|
||||
running += daily[d]
|
||||
series.append({"date": d, "balance": running})
|
||||
return series
|
||||
|
||||
|
||||
@router.get("/{transaction_id}", response_model=TransactionRead)
|
||||
async def get_transaction(
|
||||
transaction_id: int,
|
||||
@@ -164,14 +111,6 @@ async def update_transaction(
|
||||
tx.amount = payload.amount
|
||||
if payload.description is not None:
|
||||
tx.description = payload.description
|
||||
if payload.date is not None:
|
||||
new_date = payload.date
|
||||
if isinstance(new_date, str):
|
||||
try:
|
||||
new_date = date.fromisoformat(new_date)
|
||||
except ValueError:
|
||||
raise HTTPException(status_code=400, detail="Invalid date format, expected YYYY-MM-DD")
|
||||
tx.date = new_date
|
||||
|
||||
if payload.category_ids is not None:
|
||||
# Preload categories to avoid async lazy-load during assignment
|
||||
61
7project/backend/app/app.py
Normal file
61
7project/backend/app/app.py
Normal file
@@ -0,0 +1,61 @@
|
||||
from fastapi import Depends, FastAPI
|
||||
from fastapi.middleware.cors import CORSMiddleware
|
||||
|
||||
from app.models.user import User
|
||||
|
||||
from app.services.user_service import current_active_verified_user
|
||||
from app.api.auth import router as auth_router
|
||||
from app.api.categories import router as categories_router
|
||||
from app.api.transactions import router as transactions_router
|
||||
from app.services.user_service import auth_backend, current_active_verified_user, fastapi_users, get_oauth_provider
|
||||
|
||||
fastApi = FastAPI()
|
||||
|
||||
# CORS for frontend dev server
|
||||
fastApi.add_middleware(
|
||||
CORSMiddleware,
|
||||
allow_origins=[
|
||||
"http://localhost:5173",
|
||||
"http://127.0.0.1:5173",
|
||||
],
|
||||
allow_credentials=True,
|
||||
allow_methods=["*"],
|
||||
allow_headers=["*"],
|
||||
)
|
||||
|
||||
fastApi.include_router(auth_router)
|
||||
fastApi.include_router(categories_router)
|
||||
fastApi.include_router(transactions_router)
|
||||
|
||||
fastApi.include_router(
|
||||
fastapi_users.get_oauth_router(
|
||||
get_oauth_provider("MojeID"),
|
||||
auth_backend,
|
||||
"SECRET",
|
||||
associate_by_email=True,
|
||||
),
|
||||
prefix="/auth/mojeid",
|
||||
tags=["auth"],
|
||||
)
|
||||
|
||||
fastApi.include_router(
|
||||
fastapi_users.get_oauth_router(
|
||||
get_oauth_provider("BankID"),
|
||||
auth_backend,
|
||||
"SECRET",
|
||||
associate_by_email=True,
|
||||
),
|
||||
prefix="/auth/bankid",
|
||||
tags=["auth"],
|
||||
)
|
||||
|
||||
|
||||
# Liveness/root endpoint
|
||||
@fastApi.get("/", include_in_schema=False)
|
||||
async def root():
|
||||
return {"status": "ok"}
|
||||
|
||||
|
||||
@fastApi.get("/authenticated-route")
|
||||
async def authenticated_route(user: User = Depends(current_active_verified_user)):
|
||||
return {"message": f"Hello {user.email}!"}
|
||||
@@ -1,7 +1,5 @@
|
||||
import os
|
||||
from sqlalchemy.ext.asyncio import create_async_engine, async_sessionmaker
|
||||
from sqlalchemy import create_engine
|
||||
from sqlalchemy.orm import sessionmaker
|
||||
from app.core.base import Base
|
||||
|
||||
DATABASE_URL = os.getenv("DATABASE_URL")
|
||||
@@ -21,11 +19,9 @@ from app.models.user import User
|
||||
from app.models.transaction import Transaction
|
||||
from app.models.categories import Category
|
||||
|
||||
host_env = os.getenv("MARIADB_HOST", "localhost")
|
||||
ssl_enabled = host_env not in {"localhost", "127.0.0.1"}
|
||||
ssl_enabled = os.getenv("MARIADB_HOST", "localhost") != "localhost"
|
||||
connect_args = {"ssl": {"ssl": True}} if ssl_enabled else {}
|
||||
|
||||
# Async engine/session for the async parts of the app
|
||||
engine = create_async_engine(
|
||||
DATABASE_URL,
|
||||
pool_pre_ping=True,
|
||||
@@ -33,13 +29,3 @@ engine = create_async_engine(
|
||||
connect_args=connect_args,
|
||||
)
|
||||
async_session_maker = async_sessionmaker(engine, expire_on_commit=False)
|
||||
|
||||
# Synchronous engine/session for sync utilities (e.g., bank_scraper)
|
||||
SYNC_DATABASE_URL = DATABASE_URL.replace("+asyncmy", "+pymysql")
|
||||
engine_sync = create_engine(
|
||||
SYNC_DATABASE_URL,
|
||||
pool_pre_ping=True,
|
||||
echo=os.getenv("SQL_ECHO", "0") == "1",
|
||||
connect_args=connect_args,
|
||||
)
|
||||
sync_session_maker = sessionmaker(bind=engine_sync, expire_on_commit=False)
|
||||
@@ -7,8 +7,8 @@ from app.core.base import Base
|
||||
association_table = Table(
|
||||
"category_transaction",
|
||||
Base.metadata,
|
||||
Column("category_id", Integer, ForeignKey("categories.id", ondelete="CASCADE"), primary_key=True),
|
||||
Column("transaction_id", Integer, ForeignKey("transaction.id", ondelete="CASCADE"), primary_key=True)
|
||||
Column("id_category", Integer, ForeignKey("categories.id")),
|
||||
Column("id_transaction", Integer, ForeignKey("transaction.id"))
|
||||
)
|
||||
|
||||
|
||||
@@ -1,24 +1,17 @@
|
||||
import os
|
||||
from fastapi_users_db_sqlalchemy import GUID
|
||||
from sqlalchemy import Column, Integer, String, Float, ForeignKey, Date, func
|
||||
from sqlalchemy import Column, Integer, String, Float, ForeignKey
|
||||
from sqlalchemy.orm import relationship
|
||||
from sqlalchemy_utils import EncryptedType
|
||||
from sqlalchemy_utils.types.encrypted.encrypted_type import FernetEngine
|
||||
|
||||
from app.core.base import Base
|
||||
from app.models.categories import association_table
|
||||
|
||||
SECRET_KEY = os.environ.get("DB_ENCRYPTION_KEY", "localdev")
|
||||
|
||||
|
||||
class Transaction(Base):
|
||||
__tablename__ = "transaction"
|
||||
id = Column(Integer, primary_key=True, autoincrement=True)
|
||||
amount = Column(EncryptedType(Float, SECRET_KEY, engine=FernetEngine), nullable=False)
|
||||
description = Column(EncryptedType(String(length=255), SECRET_KEY, engine=FernetEngine), nullable=True)
|
||||
date = Column(Date, nullable=False, server_default=func.current_date())
|
||||
amount = Column(Float, nullable=False)
|
||||
description = Column(String(length=255), nullable=True)
|
||||
user_id = Column(GUID, ForeignKey("user.id"), nullable=False)
|
||||
|
||||
# Relationship
|
||||
user = relationship("User", back_populates="transactions")
|
||||
categories = relationship("Category", secondary=association_table, back_populates="transactions", passive_deletes=True)
|
||||
categories = relationship("Category", secondary=association_table, back_populates="transactions")
|
||||
@@ -1,8 +1,6 @@
|
||||
from sqlalchemy import Column, String
|
||||
from sqlalchemy.orm import relationship, mapped_column, Mapped
|
||||
from fastapi_users.db import SQLAlchemyBaseUserTableUUID, SQLAlchemyBaseOAuthAccountTableUUID
|
||||
from sqlalchemy.sql.sqltypes import JSON
|
||||
|
||||
from app.core.base import Base
|
||||
|
||||
|
||||
@@ -15,7 +13,6 @@ class User(SQLAlchemyBaseUserTableUUID, Base):
|
||||
first_name = Column(String(length=100), nullable=True)
|
||||
last_name = Column(String(length=100), nullable=True)
|
||||
oauth_accounts = relationship("OAuthAccount", lazy="joined")
|
||||
config = Column(JSON, default={})
|
||||
|
||||
# Relationship
|
||||
transactions = relationship("Transaction", back_populates="user")
|
||||
@@ -11,7 +11,7 @@ class MojeIDOAuth(CustomOpenID):
|
||||
super().__init__(
|
||||
client_id,
|
||||
client_secret,
|
||||
"https://mojeid.cz/.well-known/openid-configuration/",
|
||||
"https://mojeid.regtest.nic.cz/.well-known/openid-configuration/",
|
||||
"MojeID",
|
||||
base_scopes=["openid", "email", "profile"],
|
||||
)
|
||||
@@ -11,11 +11,6 @@ class CategoryCreate(CategoryBase):
|
||||
pass
|
||||
|
||||
|
||||
class CategoryUpdate(BaseModel):
|
||||
name: Optional[str] = None
|
||||
description: Optional[str] = None
|
||||
|
||||
|
||||
class CategoryRead(CategoryBase):
|
||||
id: int
|
||||
model_config = ConfigDict(from_attributes=True)
|
||||
@@ -1,13 +1,10 @@
|
||||
from typing import List, Optional, Union
|
||||
from datetime import date
|
||||
from typing import List, Optional
|
||||
from pydantic import BaseModel, Field, ConfigDict
|
||||
|
||||
|
||||
class TransactionBase(BaseModel):
|
||||
amount: float = Field(..., gt=-1e18, lt=1e18)
|
||||
description: Optional[str] = None
|
||||
# accept either ISO date string or date object
|
||||
date: Optional[Union[date, str]] = None
|
||||
|
||||
class TransactionCreate(TransactionBase):
|
||||
category_ids: Optional[List[int]] = None
|
||||
@@ -15,12 +12,10 @@ class TransactionCreate(TransactionBase):
|
||||
class TransactionUpdate(BaseModel):
|
||||
amount: Optional[float] = Field(None, gt=-1e18, lt=1e18)
|
||||
description: Optional[str] = None
|
||||
# accept either ISO date string or date object
|
||||
date: Optional[Union[date, str]] = None
|
||||
category_ids: Optional[List[int]] = None
|
||||
|
||||
class TransactionRead(TransactionBase):
|
||||
id: int
|
||||
category_ids: List[int] = []
|
||||
date: Optional[Union[date, str]]
|
||||
|
||||
model_config = ConfigDict(from_attributes=True)
|
||||
@@ -1,11 +1,10 @@
|
||||
import uuid
|
||||
from typing import Optional, Dict, Any
|
||||
from typing import Optional
|
||||
from fastapi_users import schemas
|
||||
|
||||
class UserRead(schemas.BaseUser[uuid.UUID]):
|
||||
first_name: Optional[str] = None
|
||||
last_name: Optional[str] = None
|
||||
config: Optional[Dict[str, Any]] = None
|
||||
|
||||
class UserCreate(schemas.BaseUserCreate):
|
||||
first_name: Optional[str] = None
|
||||
@@ -14,7 +14,6 @@ from httpx_oauth.oauth2 import BaseOAuth2
|
||||
|
||||
from app.models.user import User
|
||||
from app.oauth.bank_id import BankID
|
||||
from app.oauth.csas import CSASOAuth
|
||||
from app.oauth.custom_openid import CustomOpenID
|
||||
from app.oauth.moje_id import MojeIDOAuth
|
||||
from app.services.db import get_user_db
|
||||
@@ -33,7 +32,7 @@ providers = {
|
||||
"BankID": BankID(
|
||||
os.getenv("BANKID_CLIENT_ID", "CHANGE_ME_CLIENT_ID"),
|
||||
os.getenv("BANKID_CLIENT_SECRET", "CHANGE_ME_CLIENT_SECRET"),
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -102,7 +101,7 @@ bearer_transport = BearerTransport(tokenUrl="auth/jwt/login")
|
||||
|
||||
|
||||
def get_jwt_strategy() -> JWTStrategy:
|
||||
return JWTStrategy(secret=SECRET, lifetime_seconds=604800)
|
||||
return JWTStrategy(secret=SECRET, lifetime_seconds=3600)
|
||||
|
||||
|
||||
auth_backend = AuthenticationBackend(
|
||||
19
7project/backend/app/workers/celery_tasks.py
Normal file
19
7project/backend/app/workers/celery_tasks.py
Normal file
@@ -0,0 +1,19 @@
|
||||
import logging
|
||||
|
||||
from celery import shared_task
|
||||
|
||||
logger = logging.getLogger("celery_tasks")
|
||||
if not logger.handlers:
|
||||
_h = logging.StreamHandler()
|
||||
logger.addHandler(_h)
|
||||
logger.setLevel(logging.INFO)
|
||||
|
||||
|
||||
@shared_task(name="workers.send_email")
|
||||
def send_email(to: str, subject: str, body: str) -> None:
|
||||
if not (to and subject and body):
|
||||
logger.error("Email task missing fields. to=%r subject=%r body_len=%r", to, subject, len(body) if body else 0)
|
||||
return
|
||||
|
||||
# Placeholder for real email sending logic
|
||||
logger.info("[Celery] Email sent | to=%s | subject=%s | body_len=%d", to, subject, len(body))
|
||||
4
7project/backend/main.py
Normal file
4
7project/backend/main.py
Normal file
@@ -0,0 +1,4 @@
|
||||
import uvicorn
|
||||
|
||||
if __name__ == "__main__":
|
||||
uvicorn.run("app.app:app", host="0.0.0.0", log_level="info")
|
||||
@@ -38,8 +38,6 @@ MarkupSafe==3.0.2
|
||||
multidict==6.6.4
|
||||
packaging==25.0
|
||||
pamqp==3.3.0
|
||||
prometheus-fastapi-instrumentator==7.1.0
|
||||
prometheus_client==0.23.1
|
||||
prompt_toolkit==3.0.52
|
||||
propcache==0.3.2
|
||||
pwdlib==0.2.1
|
||||
@@ -52,17 +50,14 @@ python-dateutil==2.9.0.post0
|
||||
python-dotenv==1.1.1
|
||||
python-multipart==0.0.20
|
||||
PyYAML==6.0.2
|
||||
sentry-sdk==2.42.0
|
||||
six==1.17.0
|
||||
sniffio==1.3.1
|
||||
SQLAlchemy==2.0.43
|
||||
SQLAlchemy-Utils==0.42.0
|
||||
starlette==0.48.0
|
||||
tomli==2.2.1
|
||||
typing-inspection==0.4.1
|
||||
typing_extensions==4.15.0
|
||||
tzdata==2025.2
|
||||
urllib3==2.5.0
|
||||
uvicorn==0.37.0
|
||||
uvloop==0.21.0
|
||||
vine==5.1.0
|
||||
@@ -70,4 +65,3 @@ watchfiles==1.1.0
|
||||
wcwidth==0.2.14
|
||||
websockets==15.0.1
|
||||
yarl==1.20.1
|
||||
python-json-logger==2.0.7
|
||||
@@ -8,12 +8,10 @@ spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
app: {{ .Values.app.name }}
|
||||
endpoint: metrics
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: {{ .Values.app.name }}
|
||||
endpoint: metrics
|
||||
spec:
|
||||
containers:
|
||||
- name: {{ .Values.app.name }}
|
||||
@@ -80,21 +78,6 @@ spec:
|
||||
secretKeyRef:
|
||||
name: prod
|
||||
key: BANKID_CLIENT_SECRET
|
||||
- name: CSAS_CLIENT_ID
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: prod
|
||||
key: CSAS_CLIENT_ID
|
||||
- name: CSAS_CLIENT_SECRET
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: prod
|
||||
key: CSAS_CLIENT_SECRET
|
||||
- name: UNIRATE_API_KEY
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: prod
|
||||
key: UNIRATE_API_KEY
|
||||
- name: DOMAIN
|
||||
value: {{ required "Set .Values.domain" .Values.domain | quote }}
|
||||
- name: DOMAIN_SCHEME
|
||||
@@ -103,16 +86,6 @@ spec:
|
||||
value: {{ required "Set .Values.frontend_domain" .Values.frontend_domain | quote }}
|
||||
- name: FRONTEND_DOMAIN_SCHEME
|
||||
value: {{ required "Set .Values.frontend_domain_scheme" .Values.frontend_domain_scheme | quote }}
|
||||
- name: SENTRY_DSN
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: prod
|
||||
key: SENTRY_DSN
|
||||
- name: DB_ENCRYPTION_KEY
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: prod
|
||||
key: DB_ENCRYPTION_KEY
|
||||
livenessProbe:
|
||||
httpGet:
|
||||
path: /
|
||||
17
7project/charts/myapp-chart/templates/prod.yaml
Normal file
17
7project/charts/myapp-chart/templates/prod.yaml
Normal file
@@ -0,0 +1,17 @@
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: prod
|
||||
type: Opaque
|
||||
stringData:
|
||||
MOJEID_CLIENT_ID: {{ .Values.oauth.mojeid.clientId | quote }}
|
||||
MOJEID_CLIENT_SECRET: {{ .Values.oauth.mojeid.clientSecret | quote }}
|
||||
BANKID_CLIENT_ID: {{ .Values.oauth.bankid.clientId | quote }}
|
||||
BANKID_CLIENT_SECRET: {{ .Values.oauth.bankid.clientSecret | quote }}
|
||||
# Database credentials
|
||||
MARIADB_DB: {{ required "Set .Values.deployment" .Values.deployment | quote }}
|
||||
MARIADB_USER: {{ required "Set .Values.deployment" .Values.deployment | quote }}
|
||||
MARIADB_PASSWORD: {{ .Values.database.password | default "" | quote }}
|
||||
# RabbitMQ credentials
|
||||
RABBITMQ_PASSWORD: {{ .Values.rabbitmq.password | default "" | quote }}
|
||||
RABBITMQ_USERNAME: {{ .Values.rabbitmq.username | quote }}
|
||||
@@ -2,12 +2,9 @@ apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: {{ .Values.app.name }}
|
||||
labels:
|
||||
app: {{ .Values.app.name }}
|
||||
spec:
|
||||
ports:
|
||||
- name: http
|
||||
port: {{ .Values.service.port }}
|
||||
- port: {{ .Values.service.port }}
|
||||
targetPort: {{ .Values.app.port }}
|
||||
selector:
|
||||
app: {{ .Values.app.name }}
|
||||
@@ -20,7 +20,7 @@ spec:
|
||||
securityContext:
|
||||
allowPrivilegeEscalation: false
|
||||
capabilities:
|
||||
drop: [ "ALL" ]
|
||||
drop: ["ALL"]
|
||||
command:
|
||||
- celery
|
||||
- -A
|
||||
@@ -65,60 +65,3 @@ spec:
|
||||
value: {{ .Values.rabbitmq.vhost | default "/" | quote }}
|
||||
- name: MAIL_QUEUE
|
||||
value: {{ .Values.worker.mailQueueName | default "mail_queue" | quote }}
|
||||
- name: SENTRY_DSN
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: prod
|
||||
key: SENTRY_DSN
|
||||
- name: CSAS_CLIENT_ID
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: prod
|
||||
key: CSAS_CLIENT_ID
|
||||
- name: CSAS_CLIENT_SECRET
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: prod
|
||||
key: CSAS_CLIENT_SECRET
|
||||
- name: DB_ENCRYPTION_KEY
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: prod
|
||||
key: DB_ENCRYPTION_KEY
|
||||
- name: SMTP_HOST
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: prod
|
||||
key: SMTP_HOST
|
||||
- name: SMTP_PORT
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: prod
|
||||
key: SMTP_PORT
|
||||
- name: SMTP_USERNAME
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: prod
|
||||
key: SMTP_USERNAME
|
||||
- name: SMTP_PASSWORD
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: prod
|
||||
key: SMTP_PASSWORD
|
||||
- name: SMTP_USE_TLS
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: prod
|
||||
key: SMTP_USE_TLS
|
||||
- name: SMTP_USE_SSL
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: prod
|
||||
key: SMTP_USE_SSL
|
||||
- name: SMTP_FROM
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: prod
|
||||
key: SMTP_FROM
|
||||
- name: APP_POD_URL
|
||||
value: {{ printf "http://%s.%s.svc.cluster.local" .Values.app.name .Release.Namespace | quote }}
|
||||
@@ -5,6 +5,3 @@ app:
|
||||
|
||||
worker:
|
||||
replicas: 3
|
||||
|
||||
cron:
|
||||
enabled: true
|
||||
@@ -13,14 +13,9 @@ deployment: ""
|
||||
domain: ""
|
||||
domain_scheme: ""
|
||||
|
||||
unirate:
|
||||
key: ""
|
||||
|
||||
frontend_domain: ""
|
||||
frontend_domain_scheme: ""
|
||||
|
||||
sentry_dsn: ""
|
||||
|
||||
image:
|
||||
repository: lukastrkan/cc-app-demo
|
||||
# You can use a tag or digest. If digest is provided, it takes precedence.
|
||||
@@ -38,23 +33,6 @@ worker:
|
||||
# Queue name for Celery worker and for CRD Queue
|
||||
mailQueueName: "mail_queue"
|
||||
|
||||
cron:
|
||||
enabled: false
|
||||
schedule: "*/5 * * * *" # every 5 minutes
|
||||
scheme: "http"
|
||||
endpoint: "/_cron"
|
||||
concurrencyPolicy: "Forbid"
|
||||
|
||||
smtp:
|
||||
host:
|
||||
port: 587
|
||||
username: ""
|
||||
password: ""
|
||||
tls: false
|
||||
ssl: false
|
||||
from: ""
|
||||
|
||||
|
||||
|
||||
service:
|
||||
port: 80
|
||||
@@ -66,9 +44,6 @@ oauth:
|
||||
mojeid:
|
||||
clientId: ""
|
||||
clientSecret: ""
|
||||
csas:
|
||||
clientId: ""
|
||||
clientSecret: ""
|
||||
|
||||
rabbitmq:
|
||||
create: true
|
||||
@@ -95,4 +70,3 @@ database:
|
||||
userName: app-demo-user
|
||||
secretName: app-demo-database-secret
|
||||
password: ""
|
||||
encryptionSecret: ""
|
||||
@@ -7,64 +7,64 @@ Focus on areas that align with your project goals and interests.
|
||||
The core deliverables are required.
|
||||
This means that you must get at least 2 points for each item in this category.
|
||||
|
||||
| **Category** | **Item** | **Max Points** | **Points** | **Comments** |
|
||||
|----------------------------------| --------------------------------------- | -------------- |-------------------------------------------------| |
|
||||
| **Core Deliverables (Required)** | | | | |
|
||||
| Codebase & Organization | Well-organized project structure | 5 | 5 | |
|
||||
| | Clean, readable code | 5 | 4 | |
|
||||
| | Use planning tool (e.g., GitHub issues) | 5 | 4 | |
|
||||
| | Proper version control usage | 5 | 5 | |
|
||||
| 23 | Complete source code | 5 | 5 | |
|
||||
| Documentation | Comprehensive reproducibility report | 10 | 4-5 | |
|
||||
| | Updated design document | 5 | 2 | |
|
||||
| | Clear build/deployment instructions | 5 | 2 | |
|
||||
| | Troubleshooting guide | 5 | 1 | |
|
||||
| | Completed self-assessment table | 5 | 2 | |
|
||||
| 14 | Hour sheets for all members | 5 | 3 | |
|
||||
| Presentation Video | Project demonstration | 5 | 0 | |
|
||||
| | Code walk-through | 5 | 0 | |
|
||||
| 0 | Deployment showcase | 5 | 0 | |
|
||||
| **Technical Implementation** | | | | |
|
||||
| Application Functionality | Basic functionality works | 10 | 8 | |
|
||||
| | Advanced features implemented | 10 | 0 | |
|
||||
| | Error handling & robustness | 10 | 4 | |
|
||||
| 16 | User-friendly interface | 5 | 4 | |
|
||||
| Backend & Architecture | Stateless web server | 5 | 5 | |
|
||||
| | Stateful application | 10 | ? WHAT DOES THIS MEAN | |
|
||||
| | Database integration | 10 | 10 | |
|
||||
| | API design | 5 | 5 | |
|
||||
| 20 | Microservices architecture | 10 | 0 | |
|
||||
| Cloud Integration | Basic cloud deployment | 10 | 10 | |
|
||||
| | Cloud APIs usage | 10 | ? WHAT DOES THIS MEAN | |
|
||||
| | Serverless components | 10 | 0 | |
|
||||
| 10 | Advanced cloud services | 5 | 0 | |
|
||||
| **DevOps & Deployment** | | | | |
|
||||
| Containerization | Basic Dockerfile | 5 | 5 | |
|
||||
| | Optimized Dockerfile | 5 | 0 | |
|
||||
| | Docker Compose | 5 | 5 - dev only | |
|
||||
| 15 | Persistent storage | 5 | 5 | |
|
||||
| Deployment & Scaling | Manual deployment | 5 | 5 | |
|
||||
| | Automated deployment | 5 | 5 | |
|
||||
| | Multiple replicas | 5 | 5 | |
|
||||
| 20 | Kubernetes deployment | 10 | 10 | |
|
||||
| **Quality Assurance** | | | | |
|
||||
| Testing | Unit tests | 5 | 2 | |
|
||||
| | Integration tests | 5 | 2 | |
|
||||
| | End-to-end tests | 5 | 5 | |
|
||||
| 9 | Performance testing | 5 | 0 | |
|
||||
| Monitoring & Operations | Health checks | 5 | 5 | |
|
||||
| | Logging | 5 | 2 - only to terminal add logstash | |
|
||||
| 9 | Metrics/Monitoring | 5 | 2 - only DB, need to create Prometheus endpoint | |
|
||||
| Security | HTTPS/TLS | 5 | 5 | |
|
||||
| | Authentication | 5 | 5 | |
|
||||
| 15 | Authorization | 5 | 5 | |
|
||||
| **Innovation & Excellence** | | | | |
|
||||
| Advanced Features and | AI/ML Integration | 10 | 0 | |
|
||||
| Technical Excellence | Real-time features | 10 | 0 | |
|
||||
| | Creative problem solving | 10 | ? | |
|
||||
| | Performance optimization | 5 | 2 | |
|
||||
| 2 | Exceptional user experience | 5 | 0 | |
|
||||
| **Total** | | **255** | **153** | |
|
||||
| **Category** | **Item** | **Max Points** | **Points** |
|
||||
| -------------------------------- | --------------------------------------- | -------------- | ---------------- |
|
||||
| **Core Deliverables (Required)** | | | |
|
||||
| Codebase & Organization | Well-organized project structure | 5 | |
|
||||
| | Clean, readable code | 5 | |
|
||||
| | Use planning tool (e.g., GitHub issues) | 5 | |
|
||||
| | Proper version control usage | 5 | |
|
||||
| | Complete source code | 5 | |
|
||||
| Documentation | Comprehensive reproducibility report | 10 | |
|
||||
| | Updated design document | 5 | |
|
||||
| | Clear build/deployment instructions | 5 | |
|
||||
| | Troubleshooting guide | 5 | |
|
||||
| | Completed self-assessment table | 5 | |
|
||||
| | Hour sheets for all members | 5 | |
|
||||
| Presentation Video | Project demonstration | 5 | |
|
||||
| | Code walk-through | 5 | |
|
||||
| | Deployment showcase | 5 | |
|
||||
| **Technical Implementation** | | | |
|
||||
| Application Functionality | Basic functionality works | 10 | |
|
||||
| | Advanced features implemented | 10 | |
|
||||
| | Error handling & robustness | 10 | |
|
||||
| | User-friendly interface | 5 | |
|
||||
| Backend & Architecture | Stateless web server | 5 | |
|
||||
| | Stateful application | 10 | |
|
||||
| | Database integration | 10 | |
|
||||
| | API design | 5 | |
|
||||
| | Microservices architecture | 10 | |
|
||||
| Cloud Integration | Basic cloud deployment | 10 | |
|
||||
| | Cloud APIs usage | 10 | |
|
||||
| | Serverless components | 10 | |
|
||||
| | Advanced cloud services | 5 | |
|
||||
| **DevOps & Deployment** | | | |
|
||||
| Containerization | Basic Dockerfile | 5 | |
|
||||
| | Optimized Dockerfile | 5 | |
|
||||
| | Docker Compose | 5 | |
|
||||
| | Persistent storage | 5 | |
|
||||
| Deployment & Scaling | Manual deployment | 5 | |
|
||||
| | Automated deployment | 5 | |
|
||||
| | Multiple replicas | 5 | |
|
||||
| | Kubernetes deployment | 10 | |
|
||||
| **Quality Assurance** | | | |
|
||||
| Testing | Unit tests | 5 | |
|
||||
| | Integration tests | 5 | |
|
||||
| | End-to-end tests | 5 | |
|
||||
| | Performance testing | 5 | |
|
||||
| Monitoring & Operations | Health checks | 5 | |
|
||||
| | Logging | 5 | |
|
||||
| | Metrics/Monitoring | 5 | |
|
||||
| Security | HTTPS/TLS | 5 | |
|
||||
| | Authentication | 5 | |
|
||||
| | Authorization | 5 | |
|
||||
| **Innovation & Excellence** | | | |
|
||||
| Advanced Features and | AI/ML Integration | 10 | |
|
||||
| Technical Excellence | Real-time features | 10 | |
|
||||
| | Creative problem solving | 10 | |
|
||||
| | Performance optimization | 5 | |
|
||||
| | Exceptional user experience | 5 | |
|
||||
| **Total** | | **255** | **[Your Total]** |
|
||||
|
||||
## Grading Scale
|
||||
|
||||
|
||||
20
7project/deployment/app-demo-database-grant.yaml
Normal file
20
7project/deployment/app-demo-database-grant.yaml
Normal file
@@ -0,0 +1,20 @@
|
||||
apiVersion: k8s.mariadb.com/v1alpha1
|
||||
kind: Grant
|
||||
metadata:
|
||||
name: grant
|
||||
spec:
|
||||
mariaDbRef:
|
||||
name: mariadb-repl
|
||||
namespace: mariadb-operator
|
||||
privileges:
|
||||
- "ALL PRIVILEGES"
|
||||
database: "app-demo-database"
|
||||
table: "*"
|
||||
username: "app-demo-user"
|
||||
grantOption: true
|
||||
host: "%"
|
||||
# Delete the resource in the database whenever the CR gets deleted.
|
||||
# Alternatively, you can specify Skip in order to omit deletion.
|
||||
cleanupPolicy: Skip
|
||||
requeueInterval: 10h
|
||||
retryInterval: 30s
|
||||
7
7project/deployment/app-demo-database-secret.yaml
Normal file
7
7project/deployment/app-demo-database-secret.yaml
Normal file
@@ -0,0 +1,7 @@
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: app-demo-database-secret
|
||||
type: kubernetes.io/basic-auth
|
||||
stringData:
|
||||
password: "strongpassword"
|
||||
20
7project/deployment/app-demo-database-user.yaml
Normal file
20
7project/deployment/app-demo-database-user.yaml
Normal file
@@ -0,0 +1,20 @@
|
||||
apiVersion: k8s.mariadb.com/v1alpha1
|
||||
kind: User
|
||||
metadata:
|
||||
name: app-demo-user
|
||||
spec:
|
||||
# If you want the user to be created with a different name than the resource name
|
||||
# name: user-custom
|
||||
mariaDbRef:
|
||||
name: mariadb-repl
|
||||
namespace: mariadb-operator
|
||||
passwordSecretKeyRef:
|
||||
name: app-demo-database-secret
|
||||
key: password
|
||||
maxUserConnections: 20
|
||||
host: "%"
|
||||
# Delete the resource in the database whenever the CR gets deleted.
|
||||
# Alternatively, you can specify Skip in order to omit deletion.
|
||||
cleanupPolicy: Skip
|
||||
requeueInterval: 10h
|
||||
retryInterval: 30s
|
||||
15
7project/deployment/app-demo-database.yaml
Normal file
15
7project/deployment/app-demo-database.yaml
Normal file
@@ -0,0 +1,15 @@
|
||||
apiVersion: k8s.mariadb.com/v1alpha1
|
||||
kind: Database
|
||||
metadata:
|
||||
name: app-demo-database
|
||||
spec:
|
||||
mariaDbRef:
|
||||
name: mariadb-repl
|
||||
namespace: mariadb-operator
|
||||
characterSet: utf8
|
||||
collate: utf8_general_ci
|
||||
# Delete the resource in the database whenever the CR gets deleted.
|
||||
# Alternatively, you can specify Skip in order to omit deletion.
|
||||
cleanupPolicy: Skip
|
||||
requeueInterval: 10h
|
||||
retryInterval: 30s
|
||||
48
7project/deployment/app-demo-deployment.yaml
Normal file
48
7project/deployment/app-demo-deployment.yaml
Normal file
@@ -0,0 +1,48 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: app-demo
|
||||
spec:
|
||||
replicas: 3
|
||||
revisionHistoryLimit: 3
|
||||
selector:
|
||||
matchLabels:
|
||||
app: app-demo
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: app-demo
|
||||
spec:
|
||||
containers:
|
||||
- image: lukastrkan/cc-app-demo@sha256:75634b4d97282b6b8424fe17767c81adf44af5f7359c1d25883073b5629b3e05
|
||||
name: app-demo
|
||||
ports:
|
||||
- containerPort: 8000
|
||||
env:
|
||||
- name: MARIADB_HOST
|
||||
value: mariadb-repl.mariadb-operator.svc.cluster.local
|
||||
- name: MARIADB_PORT
|
||||
value: '3306'
|
||||
- name: MARIADB_DB
|
||||
value: app-demo-database
|
||||
- name: MARIADB_USER
|
||||
value: app-demo-user
|
||||
- name: MARIADB_PASSWORD
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: app-demo-database-secret
|
||||
key: password
|
||||
livenessProbe:
|
||||
httpGet:
|
||||
path: /
|
||||
port: 8000
|
||||
initialDelaySeconds: 10
|
||||
periodSeconds: 10
|
||||
failureThreshold: 3
|
||||
readinessProbe:
|
||||
httpGet:
|
||||
path: /
|
||||
port: 8000
|
||||
initialDelaySeconds: 10
|
||||
periodSeconds: 10
|
||||
failureThreshold: 3
|
||||
10
7project/deployment/app-demo-svc.yaml
Normal file
10
7project/deployment/app-demo-svc.yaml
Normal file
@@ -0,0 +1,10 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: app-demo
|
||||
spec:
|
||||
ports:
|
||||
- port: 80
|
||||
targetPort: 8000
|
||||
selector:
|
||||
app: app-demo
|
||||
41
7project/deployment/app-demo-worker-deployment.yaml
Normal file
41
7project/deployment/app-demo-worker-deployment.yaml
Normal file
@@ -0,0 +1,41 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: app-demo-worker
|
||||
spec:
|
||||
replicas: 3
|
||||
revisionHistoryLimit: 3
|
||||
selector:
|
||||
matchLabels:
|
||||
app: app-demo-worker
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: app-demo-worker
|
||||
spec:
|
||||
containers:
|
||||
- image: lukastrkan/cc-app-demo@sha256:75634b4d97282b6b8424fe17767c81adf44af5f7359c1d25883073b5629b3e05
|
||||
name: app-demo-worker
|
||||
command:
|
||||
- celery
|
||||
- -A
|
||||
- app.celery_app
|
||||
- worker
|
||||
- -Q
|
||||
- $(MAIL_QUEUE)
|
||||
- --loglevel
|
||||
- INFO
|
||||
env:
|
||||
- name: RABBITMQ_USERNAME
|
||||
value: demo-app
|
||||
- name: RABBITMQ_PASSWORD
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: demo-app-user-credentials
|
||||
key: password
|
||||
- name: RABBITMQ_HOST
|
||||
value: rabbitmq.rabbitmq.svc.cluster.local
|
||||
- name: RABBITMQ_PORT
|
||||
value: '5672'
|
||||
- name: RABBITMQ_VHOST
|
||||
value: "/"
|
||||
14
7project/deployment/tunnel.yaml
Normal file
14
7project/deployment/tunnel.yaml
Normal file
@@ -0,0 +1,14 @@
|
||||
apiVersion: networking.cfargotunnel.com/v1alpha1
|
||||
kind: TunnelBinding
|
||||
metadata:
|
||||
name: guestbook-tunnel-binding
|
||||
namespace: group-project
|
||||
subjects:
|
||||
- name: app-server
|
||||
spec:
|
||||
target: http://app-demo.group-project.svc.cluster.local
|
||||
fqdn: demo.ltrk.cz
|
||||
noTlsVerify: true
|
||||
tunnelRef:
|
||||
kind: ClusterTunnel
|
||||
name: cluster-tunnel
|
||||
@@ -9,8 +9,7 @@
|
||||
"version": "0.0.0",
|
||||
"dependencies": {
|
||||
"react": "^19.1.1",
|
||||
"react-dom": "^19.1.1",
|
||||
"recharts": "^3.3.0"
|
||||
"react-dom": "^19.1.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@eslint/js": "^9.36.0",
|
||||
@@ -1048,32 +1047,6 @@
|
||||
"node": ">= 8"
|
||||
}
|
||||
},
|
||||
"node_modules/@reduxjs/toolkit": {
|
||||
"version": "2.9.1",
|
||||
"resolved": "https://registry.npmjs.org/@reduxjs/toolkit/-/toolkit-2.9.1.tgz",
|
||||
"integrity": "sha512-sETJ3qO72y7L7WiR5K54UFLT3jRzAtqeBPVO15xC3bGA6kDqCH8m/v7BKCPH4czydXzz/1lPEGLvew7GjOO3Qw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@standard-schema/spec": "^1.0.0",
|
||||
"@standard-schema/utils": "^0.3.0",
|
||||
"immer": "^10.0.3",
|
||||
"redux": "^5.0.1",
|
||||
"redux-thunk": "^3.1.0",
|
||||
"reselect": "^5.1.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"react": "^16.9.0 || ^17.0.0 || ^18 || ^19",
|
||||
"react-redux": "^7.2.1 || ^8.1.3 || ^9.0.0"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"react": {
|
||||
"optional": true
|
||||
},
|
||||
"react-redux": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/@rolldown/pluginutils": {
|
||||
"version": "1.0.0-beta.38",
|
||||
"resolved": "https://registry.npmjs.org/@rolldown/pluginutils/-/pluginutils-1.0.0-beta.38.tgz",
|
||||
@@ -1389,18 +1362,6 @@
|
||||
"win32"
|
||||
]
|
||||
},
|
||||
"node_modules/@standard-schema/spec": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@standard-schema/spec/-/spec-1.0.0.tgz",
|
||||
"integrity": "sha512-m2bOd0f2RT9k8QJx1JN85cZYyH1RqFBdlwtkSlf4tBDYLCiiZnv1fIIwacK6cqwXavOydf0NPToMQgpKq+dVlA==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@standard-schema/utils": {
|
||||
"version": "0.3.0",
|
||||
"resolved": "https://registry.npmjs.org/@standard-schema/utils/-/utils-0.3.0.tgz",
|
||||
"integrity": "sha512-e7Mew686owMaPJVNNLs55PUvgz371nKgwsc4vxE49zsODpJEnxgxRo2y/OKrqueavXgZNMDVj3DdHFlaSAeU8g==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@types/babel__core": {
|
||||
"version": "7.20.5",
|
||||
"resolved": "https://registry.npmjs.org/@types/babel__core/-/babel__core-7.20.5.tgz",
|
||||
@@ -1446,69 +1407,6 @@
|
||||
"@babel/types": "^7.28.2"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/d3-array": {
|
||||
"version": "3.2.2",
|
||||
"resolved": "https://registry.npmjs.org/@types/d3-array/-/d3-array-3.2.2.tgz",
|
||||
"integrity": "sha512-hOLWVbm7uRza0BYXpIIW5pxfrKe0W+D5lrFiAEYR+pb6w3N2SwSMaJbXdUfSEv+dT4MfHBLtn5js0LAWaO6otw==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@types/d3-color": {
|
||||
"version": "3.1.3",
|
||||
"resolved": "https://registry.npmjs.org/@types/d3-color/-/d3-color-3.1.3.tgz",
|
||||
"integrity": "sha512-iO90scth9WAbmgv7ogoq57O9YpKmFBbmoEoCHDB2xMBY0+/KVrqAaCDyCE16dUspeOvIxFFRI+0sEtqDqy2b4A==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@types/d3-ease": {
|
||||
"version": "3.0.2",
|
||||
"resolved": "https://registry.npmjs.org/@types/d3-ease/-/d3-ease-3.0.2.tgz",
|
||||
"integrity": "sha512-NcV1JjO5oDzoK26oMzbILE6HW7uVXOHLQvHshBUW4UMdZGfiY6v5BeQwh9a9tCzv+CeefZQHJt5SRgK154RtiA==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@types/d3-interpolate": {
|
||||
"version": "3.0.4",
|
||||
"resolved": "https://registry.npmjs.org/@types/d3-interpolate/-/d3-interpolate-3.0.4.tgz",
|
||||
"integrity": "sha512-mgLPETlrpVV1YRJIglr4Ez47g7Yxjl1lj7YKsiMCb27VJH9W8NVM6Bb9d8kkpG/uAQS5AmbA48q2IAolKKo1MA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@types/d3-color": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/d3-path": {
|
||||
"version": "3.1.1",
|
||||
"resolved": "https://registry.npmjs.org/@types/d3-path/-/d3-path-3.1.1.tgz",
|
||||
"integrity": "sha512-VMZBYyQvbGmWyWVea0EHs/BwLgxc+MKi1zLDCONksozI4YJMcTt8ZEuIR4Sb1MMTE8MMW49v0IwI5+b7RmfWlg==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@types/d3-scale": {
|
||||
"version": "4.0.9",
|
||||
"resolved": "https://registry.npmjs.org/@types/d3-scale/-/d3-scale-4.0.9.tgz",
|
||||
"integrity": "sha512-dLmtwB8zkAeO/juAMfnV+sItKjlsw2lKdZVVy6LRr0cBmegxSABiLEpGVmSJJ8O08i4+sGR6qQtb6WtuwJdvVw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@types/d3-time": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/d3-shape": {
|
||||
"version": "3.1.7",
|
||||
"resolved": "https://registry.npmjs.org/@types/d3-shape/-/d3-shape-3.1.7.tgz",
|
||||
"integrity": "sha512-VLvUQ33C+3J+8p+Daf+nYSOsjB4GXp19/S/aGo60m9h1v6XaxjiT82lKVWJCfzhtuZ3yD7i/TPeC/fuKLLOSmg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@types/d3-path": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/d3-time": {
|
||||
"version": "3.0.4",
|
||||
"resolved": "https://registry.npmjs.org/@types/d3-time/-/d3-time-3.0.4.tgz",
|
||||
"integrity": "sha512-yuzZug1nkAAaBlBBikKZTgzCeA+k1uy4ZFwWANOfKw5z5LRhV0gNA7gNkKm7HoK+HRN0wX3EkxGk0fpbWhmB7g==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@types/d3-timer": {
|
||||
"version": "3.0.2",
|
||||
"resolved": "https://registry.npmjs.org/@types/d3-timer/-/d3-timer-3.0.2.tgz",
|
||||
"integrity": "sha512-Ps3T8E8dZDam6fUyNiMkekK3XUsaUEik+idO9/YjPtfj2qruF8tFBXS7XhtE4iIXBLxhmLjP3SXpLhVf21I9Lw==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@types/estree": {
|
||||
"version": "1.0.8",
|
||||
"resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.8.tgz",
|
||||
@@ -1537,7 +1435,7 @@
|
||||
"version": "19.2.0",
|
||||
"resolved": "https://registry.npmjs.org/@types/react/-/react-19.2.0.tgz",
|
||||
"integrity": "sha512-1LOH8xovvsKsCBq1wnT4ntDUdCJKmnEakhsuoUSy6ExlHCkGP2hqnatagYTgFk6oeL0VU31u7SNjunPN+GchtA==",
|
||||
"devOptional": true,
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"csstype": "^3.0.2"
|
||||
@@ -1553,12 +1451,6 @@
|
||||
"@types/react": "^19.2.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/use-sync-external-store": {
|
||||
"version": "0.0.6",
|
||||
"resolved": "https://registry.npmjs.org/@types/use-sync-external-store/-/use-sync-external-store-0.0.6.tgz",
|
||||
"integrity": "sha512-zFDAD+tlpf2r4asuHEj0XH6pY6i0g5NeAHPn+15wk3BV6JA69eERFXC1gyGThDkVa1zCyKr5jox1+2LbV/AMLg==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@typescript-eslint/eslint-plugin": {
|
||||
"version": "8.45.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.45.0.tgz",
|
||||
@@ -2037,15 +1929,6 @@
|
||||
"url": "https://github.com/chalk/chalk?sponsor=1"
|
||||
}
|
||||
},
|
||||
"node_modules/clsx": {
|
||||
"version": "2.1.1",
|
||||
"resolved": "https://registry.npmjs.org/clsx/-/clsx-2.1.1.tgz",
|
||||
"integrity": "sha512-eYm0QWBtUrBWZWG0d386OGAw16Z995PiOVo2B7bjWSbHedGl5e0ZWaq65kOGgUSNesEIDkB9ISbTg/JK9dhCZA==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=6"
|
||||
}
|
||||
},
|
||||
"node_modules/color-convert": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
|
||||
@@ -2099,130 +1982,9 @@
|
||||
"version": "3.1.3",
|
||||
"resolved": "https://registry.npmjs.org/csstype/-/csstype-3.1.3.tgz",
|
||||
"integrity": "sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw==",
|
||||
"devOptional": true,
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/d3-array": {
|
||||
"version": "3.2.4",
|
||||
"resolved": "https://registry.npmjs.org/d3-array/-/d3-array-3.2.4.tgz",
|
||||
"integrity": "sha512-tdQAmyA18i4J7wprpYq8ClcxZy3SC31QMeByyCFyRt7BVHdREQZ5lpzoe5mFEYZUWe+oq8HBvk9JjpibyEV4Jg==",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"internmap": "1 - 2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
},
|
||||
"node_modules/d3-color": {
|
||||
"version": "3.1.0",
|
||||
"resolved": "https://registry.npmjs.org/d3-color/-/d3-color-3.1.0.tgz",
|
||||
"integrity": "sha512-zg/chbXyeBtMQ1LbD/WSoW2DpC3I0mpmPdW+ynRTj/x2DAWYrIY7qeZIHidozwV24m4iavr15lNwIwLxRmOxhA==",
|
||||
"license": "ISC",
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
},
|
||||
"node_modules/d3-ease": {
|
||||
"version": "3.0.1",
|
||||
"resolved": "https://registry.npmjs.org/d3-ease/-/d3-ease-3.0.1.tgz",
|
||||
"integrity": "sha512-wR/XK3D3XcLIZwpbvQwQ5fK+8Ykds1ip7A2Txe0yxncXSdq1L9skcG7blcedkOX+ZcgxGAmLX1FrRGbADwzi0w==",
|
||||
"license": "BSD-3-Clause",
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
},
|
||||
"node_modules/d3-format": {
|
||||
"version": "3.1.0",
|
||||
"resolved": "https://registry.npmjs.org/d3-format/-/d3-format-3.1.0.tgz",
|
||||
"integrity": "sha512-YyUI6AEuY/Wpt8KWLgZHsIU86atmikuoOmCfommt0LYHiQSPjvX2AcFc38PX0CBpr2RCyZhjex+NS/LPOv6YqA==",
|
||||
"license": "ISC",
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
},
|
||||
"node_modules/d3-interpolate": {
|
||||
"version": "3.0.1",
|
||||
"resolved": "https://registry.npmjs.org/d3-interpolate/-/d3-interpolate-3.0.1.tgz",
|
||||
"integrity": "sha512-3bYs1rOD33uo8aqJfKP3JWPAibgw8Zm2+L9vBKEHJ2Rg+viTR7o5Mmv5mZcieN+FRYaAOWX5SJATX6k1PWz72g==",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"d3-color": "1 - 3"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
},
|
||||
"node_modules/d3-path": {
|
||||
"version": "3.1.0",
|
||||
"resolved": "https://registry.npmjs.org/d3-path/-/d3-path-3.1.0.tgz",
|
||||
"integrity": "sha512-p3KP5HCf/bvjBSSKuXid6Zqijx7wIfNW+J/maPs+iwR35at5JCbLUT0LzF1cnjbCHWhqzQTIN2Jpe8pRebIEFQ==",
|
||||
"license": "ISC",
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
},
|
||||
"node_modules/d3-scale": {
|
||||
"version": "4.0.2",
|
||||
"resolved": "https://registry.npmjs.org/d3-scale/-/d3-scale-4.0.2.tgz",
|
||||
"integrity": "sha512-GZW464g1SH7ag3Y7hXjf8RoUuAFIqklOAq3MRl4OaWabTFJY9PN/E1YklhXLh+OQ3fM9yS2nOkCoS+WLZ6kvxQ==",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"d3-array": "2.10.0 - 3",
|
||||
"d3-format": "1 - 3",
|
||||
"d3-interpolate": "1.2.0 - 3",
|
||||
"d3-time": "2.1.1 - 3",
|
||||
"d3-time-format": "2 - 4"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
},
|
||||
"node_modules/d3-shape": {
|
||||
"version": "3.2.0",
|
||||
"resolved": "https://registry.npmjs.org/d3-shape/-/d3-shape-3.2.0.tgz",
|
||||
"integrity": "sha512-SaLBuwGm3MOViRq2ABk3eLoxwZELpH6zhl3FbAoJ7Vm1gofKx6El1Ib5z23NUEhF9AsGl7y+dzLe5Cw2AArGTA==",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"d3-path": "^3.1.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
},
|
||||
"node_modules/d3-time": {
|
||||
"version": "3.1.0",
|
||||
"resolved": "https://registry.npmjs.org/d3-time/-/d3-time-3.1.0.tgz",
|
||||
"integrity": "sha512-VqKjzBLejbSMT4IgbmVgDjpkYrNWUYJnbCGo874u7MMKIWsILRX+OpX/gTk8MqjpT1A/c6HY2dCA77ZN0lkQ2Q==",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"d3-array": "2 - 3"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
},
|
||||
"node_modules/d3-time-format": {
|
||||
"version": "4.1.0",
|
||||
"resolved": "https://registry.npmjs.org/d3-time-format/-/d3-time-format-4.1.0.tgz",
|
||||
"integrity": "sha512-dJxPBlzC7NugB2PDLwo9Q8JiTR3M3e4/XANkreKSUxF8vvXKqm1Yfq4Q5dl8budlunRVlUUaDUgFt7eA8D6NLg==",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"d3-time": "1 - 3"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
},
|
||||
"node_modules/d3-timer": {
|
||||
"version": "3.0.1",
|
||||
"resolved": "https://registry.npmjs.org/d3-timer/-/d3-timer-3.0.1.tgz",
|
||||
"integrity": "sha512-ndfJ/JxxMd3nw31uyKoY2naivF+r29V+Lc0svZxe1JvvIRmi8hUsrMvdOwgS1o6uBHmiz91geQ0ylPP0aj1VUA==",
|
||||
"license": "ISC",
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
},
|
||||
"node_modules/debug": {
|
||||
"version": "4.4.3",
|
||||
"resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz",
|
||||
@@ -2241,12 +2003,6 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/decimal.js-light": {
|
||||
"version": "2.5.1",
|
||||
"resolved": "https://registry.npmjs.org/decimal.js-light/-/decimal.js-light-2.5.1.tgz",
|
||||
"integrity": "sha512-qIMFpTMZmny+MMIitAB6D7iVPEorVw6YQRWkvarTkT4tBeSLLiHzcwj6q0MmYSFCiVpiqPJTJEYIrpcPzVEIvg==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/deep-is": {
|
||||
"version": "0.1.4",
|
||||
"resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.4.tgz",
|
||||
@@ -2261,16 +2017,6 @@
|
||||
"dev": true,
|
||||
"license": "ISC"
|
||||
},
|
||||
"node_modules/es-toolkit": {
|
||||
"version": "1.40.0",
|
||||
"resolved": "https://registry.npmjs.org/es-toolkit/-/es-toolkit-1.40.0.tgz",
|
||||
"integrity": "sha512-8o6w0KFmU0CiIl0/Q/BCEOabF2IJaELM1T2PWj6e8KqzHv1gdx+7JtFnDwOx1kJH/isJ5NwlDG1nCr1HrRF94Q==",
|
||||
"license": "MIT",
|
||||
"workspaces": [
|
||||
"docs",
|
||||
"benchmarks"
|
||||
]
|
||||
},
|
||||
"node_modules/esbuild": {
|
||||
"version": "0.25.10",
|
||||
"resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.25.10.tgz",
|
||||
@@ -2514,12 +2260,6 @@
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/eventemitter3": {
|
||||
"version": "5.0.1",
|
||||
"resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-5.0.1.tgz",
|
||||
"integrity": "sha512-GWkBvjiSZK87ELrYOSESUYeVIc9mvLLf/nXalMOS5dYrgZq9o5OVkbZAVM06CVxYsCwH9BDZFPlQTlPA1j4ahA==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/fast-deep-equal": {
|
||||
"version": "3.1.3",
|
||||
"resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz",
|
||||
@@ -2723,16 +2463,6 @@
|
||||
"node": ">= 4"
|
||||
}
|
||||
},
|
||||
"node_modules/immer": {
|
||||
"version": "10.1.3",
|
||||
"resolved": "https://registry.npmjs.org/immer/-/immer-10.1.3.tgz",
|
||||
"integrity": "sha512-tmjF/k8QDKydUlm3mZU+tjM6zeq9/fFpPqH9SzWmBnVVKsPBg/V66qsMwb3/Bo90cgUN+ghdVBess+hPsxUyRw==",
|
||||
"license": "MIT",
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/immer"
|
||||
}
|
||||
},
|
||||
"node_modules/import-fresh": {
|
||||
"version": "3.3.1",
|
||||
"resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.1.tgz",
|
||||
@@ -2760,15 +2490,6 @@
|
||||
"node": ">=0.8.19"
|
||||
}
|
||||
},
|
||||
"node_modules/internmap": {
|
||||
"version": "2.0.3",
|
||||
"resolved": "https://registry.npmjs.org/internmap/-/internmap-2.0.3.tgz",
|
||||
"integrity": "sha512-5Hh7Y1wQbvY5ooGgPbDaL5iYLAPzMTUrjMulskHLH6wnv/A+1q5rgEaiuqEjB+oxGXIVZs1FF+R/KPN3ZSQYYg==",
|
||||
"license": "ISC",
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
},
|
||||
"node_modules/is-extglob": {
|
||||
"version": "2.1.1",
|
||||
"resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz",
|
||||
@@ -3204,36 +2925,6 @@
|
||||
"react": "^19.2.0"
|
||||
}
|
||||
},
|
||||
"node_modules/react-is": {
|
||||
"version": "19.2.0",
|
||||
"resolved": "https://registry.npmjs.org/react-is/-/react-is-19.2.0.tgz",
|
||||
"integrity": "sha512-x3Ax3kNSMIIkyVYhWPyO09bu0uttcAIoecO/um/rKGQ4EltYWVYtyiGkS/3xMynrbVQdS69Jhlv8FXUEZehlzA==",
|
||||
"license": "MIT",
|
||||
"peer": true
|
||||
},
|
||||
"node_modules/react-redux": {
|
||||
"version": "9.2.0",
|
||||
"resolved": "https://registry.npmjs.org/react-redux/-/react-redux-9.2.0.tgz",
|
||||
"integrity": "sha512-ROY9fvHhwOD9ySfrF0wmvu//bKCQ6AeZZq1nJNtbDC+kk5DuSuNX/n6YWYF/SYy7bSba4D4FSz8DJeKY/S/r+g==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@types/use-sync-external-store": "^0.0.6",
|
||||
"use-sync-external-store": "^1.4.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@types/react": "^18.2.25 || ^19",
|
||||
"react": "^18.0 || ^19",
|
||||
"redux": "^5.0.0"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"@types/react": {
|
||||
"optional": true
|
||||
},
|
||||
"redux": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/react-refresh": {
|
||||
"version": "0.17.0",
|
||||
"resolved": "https://registry.npmjs.org/react-refresh/-/react-refresh-0.17.0.tgz",
|
||||
@@ -3244,54 +2935,6 @@
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/recharts": {
|
||||
"version": "3.3.0",
|
||||
"resolved": "https://registry.npmjs.org/recharts/-/recharts-3.3.0.tgz",
|
||||
"integrity": "sha512-Vi0qmTB0iz1+/Cz9o5B7irVyUjX2ynvEgImbgMt/3sKRREcUM07QiYjS1QpAVrkmVlXqy5gykq4nGWMz9AS4Rg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@reduxjs/toolkit": "1.x.x || 2.x.x",
|
||||
"clsx": "^2.1.1",
|
||||
"decimal.js-light": "^2.5.1",
|
||||
"es-toolkit": "^1.39.3",
|
||||
"eventemitter3": "^5.0.1",
|
||||
"immer": "^10.1.1",
|
||||
"react-redux": "8.x.x || 9.x.x",
|
||||
"reselect": "5.1.1",
|
||||
"tiny-invariant": "^1.3.3",
|
||||
"use-sync-external-store": "^1.2.2",
|
||||
"victory-vendor": "^37.0.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0",
|
||||
"react-dom": "^16.0.0 || ^17.0.0 || ^18.0.0 || ^19.0.0",
|
||||
"react-is": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/redux": {
|
||||
"version": "5.0.1",
|
||||
"resolved": "https://registry.npmjs.org/redux/-/redux-5.0.1.tgz",
|
||||
"integrity": "sha512-M9/ELqF6fy8FwmkpnF0S3YKOqMyoWJ4+CS5Efg2ct3oY9daQvd/Pc71FpGZsVsbl3Cpb+IIcjBDUnnyBdQbq4w==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/redux-thunk": {
|
||||
"version": "3.1.0",
|
||||
"resolved": "https://registry.npmjs.org/redux-thunk/-/redux-thunk-3.1.0.tgz",
|
||||
"integrity": "sha512-NW2r5T6ksUKXCabzhL9z+h206HQw/NJkcLm1GPImRQ8IzfXwRGqjVhKJGauHirT0DAuyy6hjdnMZaRoAcy0Klw==",
|
||||
"license": "MIT",
|
||||
"peerDependencies": {
|
||||
"redux": "^5.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/reselect": {
|
||||
"version": "5.1.1",
|
||||
"resolved": "https://registry.npmjs.org/reselect/-/reselect-5.1.1.tgz",
|
||||
"integrity": "sha512-K/BG6eIky/SBpzfHZv/dd+9JBFiS4SWV7FIujVyJRux6e45+73RaUHXLmIR1f7WOMaQ0U1km6qwklRQxpJJY0w==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/resolve-from": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz",
|
||||
@@ -3454,12 +3097,6 @@
|
||||
"node": ">=8"
|
||||
}
|
||||
},
|
||||
"node_modules/tiny-invariant": {
|
||||
"version": "1.3.3",
|
||||
"resolved": "https://registry.npmjs.org/tiny-invariant/-/tiny-invariant-1.3.3.tgz",
|
||||
"integrity": "sha512-+FbBPE1o9QAYvviau/qC5SE3caw21q3xkvWKBtja5vgqOWIHHJ3ioaq1VPfn/Szqctz2bU/oYeKd9/z5BL+PVg==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/tinyglobby": {
|
||||
"version": "0.2.15",
|
||||
"resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.15.tgz",
|
||||
@@ -3633,41 +3270,10 @@
|
||||
"punycode": "^2.1.0"
|
||||
}
|
||||
},
|
||||
"node_modules/use-sync-external-store": {
|
||||
"version": "1.6.0",
|
||||
"resolved": "https://registry.npmjs.org/use-sync-external-store/-/use-sync-external-store-1.6.0.tgz",
|
||||
"integrity": "sha512-Pp6GSwGP/NrPIrxVFAIkOQeyw8lFenOHijQWkUTrDvrF4ALqylP2C/KCkeS9dpUM3KvYRQhna5vt7IL95+ZQ9w==",
|
||||
"license": "MIT",
|
||||
"peerDependencies": {
|
||||
"react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/victory-vendor": {
|
||||
"version": "37.3.6",
|
||||
"resolved": "https://registry.npmjs.org/victory-vendor/-/victory-vendor-37.3.6.tgz",
|
||||
"integrity": "sha512-SbPDPdDBYp+5MJHhBCAyI7wKM3d5ivekigc2Dk2s7pgbZ9wIgIBYGVw4zGHBml/qTFbexrofXW6Gu4noGxrOwQ==",
|
||||
"license": "MIT AND ISC",
|
||||
"dependencies": {
|
||||
"@types/d3-array": "^3.0.3",
|
||||
"@types/d3-ease": "^3.0.0",
|
||||
"@types/d3-interpolate": "^3.0.1",
|
||||
"@types/d3-scale": "^4.0.2",
|
||||
"@types/d3-shape": "^3.1.0",
|
||||
"@types/d3-time": "^3.0.0",
|
||||
"@types/d3-timer": "^3.0.0",
|
||||
"d3-array": "^3.1.6",
|
||||
"d3-ease": "^3.0.1",
|
||||
"d3-interpolate": "^3.0.1",
|
||||
"d3-scale": "^4.0.2",
|
||||
"d3-shape": "^3.1.0",
|
||||
"d3-time": "^3.0.0",
|
||||
"d3-timer": "^3.0.1"
|
||||
}
|
||||
},
|
||||
"node_modules/vite": {
|
||||
"version": "7.1.11",
|
||||
"resolved": "https://registry.npmjs.org/vite/-/vite-7.1.11.tgz",
|
||||
"integrity": "sha512-uzcxnSDVjAopEUjljkWh8EIrg6tlzrjFUfMcR1EVsRDGwf/ccef0qQPRyOrROwhrTDaApueq+ja+KLPlzR/zdg==",
|
||||
"version": "7.1.9",
|
||||
"resolved": "https://registry.npmjs.org/vite/-/vite-7.1.9.tgz",
|
||||
"integrity": "sha512-4nVGliEpxmhCL8DslSAUdxlB6+SMrhB0a1v5ijlh1xB1nEPuy1mxaHxysVucLHuWryAxLWg6a5ei+U4TLn/rFg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
@@ -11,8 +11,7 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"react": "^19.1.1",
|
||||
"react-dom": "^19.1.1",
|
||||
"recharts": "^3.3.0"
|
||||
"react-dom": "^19.1.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@eslint/js": "^9.36.0",
|
||||
|
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.5 KiB |
1
7project/frontend/src/App.css
Normal file
1
7project/frontend/src/App.css
Normal file
@@ -0,0 +1 @@
|
||||
/* App-level styles moved to ui.css for a cleaner layout. */
|
||||
39
7project/frontend/src/App.tsx
Normal file
39
7project/frontend/src/App.tsx
Normal file
@@ -0,0 +1,39 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
import './App.css';
|
||||
import LoginRegisterPage from './pages/LoginRegisterPage';
|
||||
import Dashboard from './pages/Dashboard';
|
||||
import { logout } from './api';
|
||||
|
||||
function App() {
|
||||
const [hasToken, setHasToken] = useState<boolean>(!!localStorage.getItem('token'));
|
||||
|
||||
useEffect(() => {
|
||||
// Handle OAuth callback: /oauth-callback?access_token=...&token_type=...
|
||||
if (window.location.pathname === '/oauth-callback') {
|
||||
const params = new URLSearchParams(window.location.search);
|
||||
const token = params.get('access_token');
|
||||
if (token) {
|
||||
localStorage.setItem('token', token);
|
||||
setHasToken(true);
|
||||
}
|
||||
// Clean URL and redirect to home
|
||||
window.history.replaceState({}, '', '/');
|
||||
}
|
||||
|
||||
const onStorage = (e: StorageEvent) => {
|
||||
if (e.key === 'token') setHasToken(!!e.newValue);
|
||||
};
|
||||
window.addEventListener('storage', onStorage);
|
||||
return () => window.removeEventListener('storage', onStorage);
|
||||
}, []);
|
||||
|
||||
if (!hasToken) {
|
||||
return <LoginRegisterPage onLoggedIn={() => setHasToken(true)} />;
|
||||
}
|
||||
|
||||
return (
|
||||
<Dashboard onLogout={() => { logout(); setHasToken(false); }} />
|
||||
);
|
||||
}
|
||||
|
||||
export default App;
|
||||
@@ -16,20 +16,8 @@ export type Transaction = {
|
||||
amount: number;
|
||||
description?: string | null;
|
||||
category_ids: number[];
|
||||
date?: string | null; // ISO date (YYYY-MM-DD)
|
||||
};
|
||||
|
||||
export async function deleteTransaction(id: number): Promise<void> {
|
||||
const res = await fetch(`${getBaseUrl()}/transactions/${id}/delete`, {
|
||||
method: 'DELETE',
|
||||
headers: getHeaders('none'),
|
||||
});
|
||||
if (!res.ok) {
|
||||
const text = await res.text();
|
||||
throw new Error(text || 'Failed to delete transaction');
|
||||
}
|
||||
}
|
||||
|
||||
function getBaseUrl() {
|
||||
const base = BACKEND_URL?.replace(/\/$/, '') || '';
|
||||
return base || '';
|
||||
@@ -96,7 +84,6 @@ export type CreateTransactionInput = {
|
||||
amount: number;
|
||||
description?: string;
|
||||
category_ids?: number[];
|
||||
date?: string; // YYYY-MM-DD
|
||||
};
|
||||
|
||||
export async function createTransaction(input: CreateTransactionInput): Promise<Transaction> {
|
||||
@@ -112,13 +99,8 @@ export async function createTransaction(input: CreateTransactionInput): Promise<
|
||||
return res.json();
|
||||
}
|
||||
|
||||
export async function getTransactions(start_date?: string, end_date?: string): Promise<Transaction[]> {
|
||||
const params = new URLSearchParams();
|
||||
if (start_date) params.set('start_date', start_date);
|
||||
if (end_date) params.set('end_date', end_date);
|
||||
const qs = params.toString();
|
||||
const url = `${getBaseUrl()}/transactions/${qs ? `?${qs}` : ''}`;
|
||||
const res = await fetch(url, {
|
||||
export async function getTransactions(): Promise<Transaction[]> {
|
||||
const res = await fetch(`${getBaseUrl()}/transactions/`, {
|
||||
headers: getHeaders(),
|
||||
});
|
||||
if (!res.ok) throw new Error('Failed to load transactions');
|
||||
@@ -133,9 +115,6 @@ export type User = {
|
||||
is_active: boolean;
|
||||
is_superuser: boolean;
|
||||
is_verified: boolean;
|
||||
// Optional JSON config object for user-level integrations and settings
|
||||
// Example: { csas: "{\"expires_at\": 1761824615, ...}" } or { csas: { expires_at: 1761824615, ... } }
|
||||
config?: Record<string, any> | null;
|
||||
};
|
||||
|
||||
export async function getMe(): Promise<User> {
|
||||
@@ -174,68 +153,3 @@ export async function deleteMe(): Promise<void> {
|
||||
export function logout() {
|
||||
localStorage.removeItem('token');
|
||||
}
|
||||
|
||||
// Categories
|
||||
export type CreateCategoryInput = { name: string; description?: string };
|
||||
export async function createCategory(input: CreateCategoryInput): Promise<Category> {
|
||||
const res = await fetch(`${getBaseUrl()}/categories/create`, {
|
||||
method: 'POST',
|
||||
headers: getHeaders(),
|
||||
body: JSON.stringify(input),
|
||||
});
|
||||
if (!res.ok) {
|
||||
const text = await res.text();
|
||||
throw new Error(text || 'Failed to create category');
|
||||
}
|
||||
return res.json();
|
||||
}
|
||||
|
||||
export type UpdateCategoryInput = { name?: string; description?: string };
|
||||
export async function updateCategory(category_id: number, input: UpdateCategoryInput): Promise<Category> {
|
||||
const res = await fetch(`${getBaseUrl()}/categories/${category_id}`, {
|
||||
method: 'PATCH',
|
||||
headers: getHeaders(),
|
||||
body: JSON.stringify(input),
|
||||
});
|
||||
if (!res.ok) {
|
||||
const text = await res.text();
|
||||
throw new Error(text || 'Failed to update category');
|
||||
}
|
||||
return res.json();
|
||||
}
|
||||
|
||||
// Transactions update
|
||||
export type UpdateTransactionInput = {
|
||||
amount?: number;
|
||||
description?: string;
|
||||
date?: string;
|
||||
category_ids?: number[];
|
||||
};
|
||||
export async function updateTransaction(id: number, input: UpdateTransactionInput): Promise<Transaction> {
|
||||
const res = await fetch(`${getBaseUrl()}/transactions/${id}/edit`, {
|
||||
method: 'PATCH',
|
||||
headers: getHeaders(),
|
||||
body: JSON.stringify(input),
|
||||
});
|
||||
if (!res.ok) {
|
||||
const text = await res.text();
|
||||
throw new Error(text || 'Failed to update transaction');
|
||||
}
|
||||
return res.json();
|
||||
}
|
||||
|
||||
// Balance series
|
||||
export type BalancePoint = { date: string; balance: number };
|
||||
export async function getBalanceSeries(start_date?: string, end_date?: string): Promise<BalancePoint[]> {
|
||||
const params = new URLSearchParams();
|
||||
if (start_date) params.set('start_date', start_date);
|
||||
if (end_date) params.set('end_date', end_date);
|
||||
const qs = params.toString();
|
||||
const url = `${getBaseUrl()}/transactions/balance_series${qs ? `?${qs}` : ''}`;
|
||||
const res = await fetch(url, { headers: getHeaders() });
|
||||
if (!res.ok) {
|
||||
const text = await res.text();
|
||||
throw new Error(text || 'Failed to load balance series');
|
||||
}
|
||||
return res.json();
|
||||
}
|
||||
@@ -13,9 +13,9 @@ export function applyTheme(theme: Theme) {
|
||||
export function applyFontSize(size: FontSize) {
|
||||
const root = document.documentElement;
|
||||
const map: Record<FontSize, string> = {
|
||||
small: '12px',
|
||||
medium: '15px',
|
||||
large: '21px',
|
||||
small: '14px',
|
||||
medium: '16px',
|
||||
large: '18px',
|
||||
};
|
||||
root.style.fontSize = map[size];
|
||||
}
|
||||
|
Before Width: | Height: | Size: 4.0 KiB After Width: | Height: | Size: 4.0 KiB |
2
7project/frontend/src/config.ts
Normal file
2
7project/frontend/src/config.ts
Normal file
@@ -0,0 +1,2 @@
|
||||
export const BACKEND_URL: string =
|
||||
import.meta.env.VITE_BACKEND_URL ?? '';
|
||||
@@ -24,6 +24,8 @@ a:hover {
|
||||
|
||||
body {
|
||||
margin: 0;
|
||||
display: flex;
|
||||
place-items: center;
|
||||
min-width: 320px;
|
||||
min-height: 100vh;
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
import { applyFontSize, applyTheme, loadAppearance, saveAppearance, type FontSize, type Theme } from '../appearance.ts';
|
||||
import { applyFontSize, applyTheme, loadAppearance, saveAppearance, type FontSize, type Theme } from '../appearance';
|
||||
|
||||
export default function AppearancePage() {
|
||||
const [theme, setTheme] = useState<Theme>('light');
|
||||
172
7project/frontend/src/pages/Dashboard.tsx
Normal file
172
7project/frontend/src/pages/Dashboard.tsx
Normal file
@@ -0,0 +1,172 @@
|
||||
import { useEffect, useMemo, useState } from 'react';
|
||||
import { type Category, type Transaction, createTransaction, getCategories, getTransactions } from '../api';
|
||||
import AccountPage from './AccountPage';
|
||||
import AppearancePage from './AppearancePage';
|
||||
|
||||
function formatAmount(n: number) {
|
||||
return new Intl.NumberFormat(undefined, { minimumFractionDigits: 2, maximumFractionDigits: 2 }).format(n);
|
||||
}
|
||||
|
||||
export default function Dashboard({ onLogout }: { onLogout: () => void }) {
|
||||
const [current, setCurrent] = useState<'home' | 'account' | 'appearance'>('home');
|
||||
const [transactions, setTransactions] = useState<Transaction[]>([]);
|
||||
const [categories, setCategories] = useState<Category[]>([]);
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
|
||||
// New transaction form state
|
||||
const [amount, setAmount] = useState<string>('');
|
||||
const [description, setDescription] = useState('');
|
||||
const [selectedCategoryId, setSelectedCategoryId] = useState<number | ''>('');
|
||||
|
||||
// Filters
|
||||
const [minAmount, setMinAmount] = useState<string>('');
|
||||
const [maxAmount, setMaxAmount] = useState<string>('');
|
||||
const [filterCategoryId, setFilterCategoryId] = useState<number | ''>('');
|
||||
const [searchText, setSearchText] = useState('');
|
||||
|
||||
async function loadAll() {
|
||||
setLoading(true);
|
||||
setError(null);
|
||||
try {
|
||||
const [txs, cats] = await Promise.all([getTransactions(), getCategories()]);
|
||||
setTransactions(txs);
|
||||
setCategories(cats);
|
||||
} catch (err: any) {
|
||||
setError(err?.message || 'Failed to load data');
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
}
|
||||
|
||||
useEffect(() => { loadAll(); }, []);
|
||||
|
||||
const last10 = useMemo(() => {
|
||||
const sorted = [...transactions].sort((a, b) => b.id - a.id);
|
||||
return sorted.slice(0, 10);
|
||||
}, [transactions]);
|
||||
|
||||
const filtered = useMemo(() => {
|
||||
let arr = last10;
|
||||
const min = minAmount !== '' ? Number(minAmount) : undefined;
|
||||
const max = maxAmount !== '' ? Number(maxAmount) : undefined;
|
||||
if (min !== undefined) arr = arr.filter(t => t.amount >= min);
|
||||
if (max !== undefined) arr = arr.filter(t => t.amount <= max);
|
||||
if (filterCategoryId !== '') arr = arr.filter(t => t.category_ids.includes(filterCategoryId as number));
|
||||
if (searchText.trim()) arr = arr.filter(t => (t.description || '').toLowerCase().includes(searchText.toLowerCase()));
|
||||
return arr;
|
||||
}, [last10, minAmount, maxAmount, filterCategoryId, searchText]);
|
||||
|
||||
function categoryNameById(id: number) { return categories.find(c => c.id === id)?.name || `#${id}`; }
|
||||
|
||||
async function handleCreate(e: React.FormEvent) {
|
||||
e.preventDefault();
|
||||
if (!amount) return;
|
||||
const payload = {
|
||||
amount: Number(amount),
|
||||
description: description || undefined,
|
||||
category_ids: selectedCategoryId !== '' ? [Number(selectedCategoryId)] : undefined,
|
||||
};
|
||||
try {
|
||||
const created = await createTransaction(payload);
|
||||
setTransactions(prev => [created, ...prev]);
|
||||
setAmount(''); setDescription(''); setSelectedCategoryId('');
|
||||
} catch (err: any) {
|
||||
alert(err?.message || 'Failed to create transaction');
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="app-layout">
|
||||
<aside className="sidebar">
|
||||
<div className="logo">7Project</div>
|
||||
<nav className="nav">
|
||||
<button className={current === 'home' ? 'active' : ''} onClick={() => setCurrent('home')}>Home</button>
|
||||
<button className={current === 'account' ? 'active' : ''} onClick={() => setCurrent('account')}>Account</button>
|
||||
<button className={current === 'appearance' ? 'active' : ''} onClick={() => setCurrent('appearance')}>Appearance</button>
|
||||
</nav>
|
||||
</aside>
|
||||
<div className="content">
|
||||
<div className="topbar">
|
||||
<h2 style={{ margin: 0 }}>{current === 'home' ? 'Dashboard' : current === 'account' ? 'Account' : 'Appearance'}</h2>
|
||||
<div className="actions">
|
||||
<span className="user muted">Signed in</span>
|
||||
<button className="btn" onClick={onLogout}>Logout</button>
|
||||
</div>
|
||||
</div>
|
||||
<main className="page space-y">
|
||||
{current === 'home' && (
|
||||
<>
|
||||
<section className="card">
|
||||
<h3>Add Transaction</h3>
|
||||
<form onSubmit={handleCreate} className="form-row">
|
||||
<input className="input" type="number" step="0.01" placeholder="Amount" value={amount} onChange={(e) => setAmount(e.target.value)} required />
|
||||
<input className="input" type="text" placeholder="Description (optional)" value={description} onChange={(e) => setDescription(e.target.value)} />
|
||||
<select className="input" value={selectedCategoryId} onChange={(e) => setSelectedCategoryId(e.target.value ? Number(e.target.value) : '')}>
|
||||
<option value="">No category</option>
|
||||
{categories.map(c => (<option key={c.id} value={c.id}>{c.name}</option>))}
|
||||
</select>
|
||||
<button className="btn primary" type="submit">Add</button>
|
||||
</form>
|
||||
</section>
|
||||
|
||||
<section className="card">
|
||||
<h3>Filters</h3>
|
||||
<div className="form-row">
|
||||
<input className="input" type="number" step="0.01" placeholder="Min amount" value={minAmount} onChange={(e) => setMinAmount(e.target.value)} />
|
||||
<input className="input" type="number" step="0.01" placeholder="Max amount" value={maxAmount} onChange={(e) => setMaxAmount(e.target.value)} />
|
||||
<select className="input" value={filterCategoryId} onChange={(e) => setFilterCategoryId(e.target.value ? Number(e.target.value) : '')}>
|
||||
<option value="">All categories</option>
|
||||
{categories.map(c => (<option key={c.id} value={c.id}>{c.name}</option>))}
|
||||
</select>
|
||||
<input className="input" type="text" placeholder="Search in description" value={searchText} onChange={(e) => setSearchText(e.target.value)} />
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section className="card">
|
||||
<h3>Latest Transactions (last 10)</h3>
|
||||
{loading ? (
|
||||
<div>Loading…</div>
|
||||
) : error ? (
|
||||
<div style={{ color: 'crimson' }}>{error}</div>
|
||||
) : filtered.length === 0 ? (
|
||||
<div>No transactions</div>
|
||||
) : (
|
||||
<table className="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th style={{ textAlign: 'right' }}>Amount</th>
|
||||
<th>Description</th>
|
||||
<th>Categories</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{filtered.map(t => (
|
||||
<tr key={t.id}>
|
||||
<td>{t.id}</td>
|
||||
<td className="amount">{formatAmount(t.amount)}</td>
|
||||
<td>{t.description || ''}</td>
|
||||
<td>{t.category_ids.map(id => categoryNameById(id)).join(', ')}</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
)}
|
||||
</section>
|
||||
</>
|
||||
)}
|
||||
|
||||
{current === 'account' && (
|
||||
// lazy import avoided for simplicity
|
||||
<AccountPage onDeleted={onLogout} />
|
||||
)}
|
||||
|
||||
{current === 'appearance' && (
|
||||
<AppearancePage />
|
||||
)}
|
||||
</main>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -2,21 +2,10 @@ import { useState, useEffect } from 'react';
|
||||
import { login, register } from '../api';
|
||||
import { BACKEND_URL } from '../config';
|
||||
|
||||
// Minimal helper to start OAuth: fetch authorization_url and redirect
|
||||
async function startOauth(provider: 'mojeid' | 'bankid') {
|
||||
function oauthUrl(provider: 'mojeid' | 'bankid') {
|
||||
const base = BACKEND_URL.replace(/\/$/, '');
|
||||
const url = `${base}/auth/${provider}/authorize`;
|
||||
try {
|
||||
const res = await fetch(url, { credentials: 'include' });
|
||||
const data = await res.json();
|
||||
if (data && typeof data.authorization_url === 'string') {
|
||||
window.location.assign(data.authorization_url);
|
||||
} else {
|
||||
alert('Cannot start OAuth.');
|
||||
}
|
||||
} catch (e) {
|
||||
alert('Cannot start OAuth.');
|
||||
}
|
||||
const redirect = encodeURIComponent(window.location.origin + '/oauth-callback');
|
||||
return `${base}/auth/${provider}/authorize?redirect_url=${redirect}`;
|
||||
}
|
||||
|
||||
export default function LoginRegisterPage({ onLoggedIn }: { onLoggedIn: () => void }) {
|
||||
@@ -80,7 +69,7 @@ export default function LoginRegisterPage({ onLoggedIn }: { onLoggedIn: () => vo
|
||||
<input className="input" type="password" required value={password} onChange={(e) => setPassword(e.target.value)} />
|
||||
</div>
|
||||
{mode === 'register' && (
|
||||
<div className="space-y">
|
||||
<div className="form-row">
|
||||
<div>
|
||||
<label className="muted">First name (optional)</label>
|
||||
<input className="input" type="text" value={firstName} onChange={(e) => setFirstName(e.target.value)} />
|
||||
@@ -95,8 +84,8 @@ export default function LoginRegisterPage({ onLoggedIn }: { onLoggedIn: () => vo
|
||||
<div className="actions" style={{ justifyContent: 'space-between' }}>
|
||||
<div className="muted">Or continue with</div>
|
||||
<div className="actions">
|
||||
<button type="button" className="btn" onClick={() => startOauth('mojeid')}>MojeID</button>
|
||||
<button type="button" className="btn" onClick={() => startOauth('bankid')}>BankID</button>
|
||||
<a className="btn" href={oauthUrl('mojeid')}>MojeID</a>
|
||||
<a className="btn" href={oauthUrl('bankid')}>BankID</a>
|
||||
<button className="btn primary" type="submit" disabled={loading}>{loading ? 'Please wait…' : (mode === 'login' ? 'Login' : 'Register')}</button>
|
||||
</div>
|
||||
</div>
|
||||
85
7project/frontend/src/ui.css
Normal file
85
7project/frontend/src/ui.css
Normal file
@@ -0,0 +1,85 @@
|
||||
:root {
|
||||
--bg: #f7f7fb;
|
||||
--panel: #ffffff;
|
||||
--text: #9aa3b2;
|
||||
--muted: #6b7280;
|
||||
--primary: #6f49fe;
|
||||
--primary-600: #5a37fb;
|
||||
--border: #e5e7eb;
|
||||
--radius: 12px;
|
||||
--shadow: 0 1px 2px rgba(0,0,0,0.04), 0 8px 24px rgba(0,0,0,0.08);
|
||||
|
||||
font-family: Inter, ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
|
||||
color: var(--text);
|
||||
}
|
||||
|
||||
* { box-sizing: border-box; }
|
||||
|
||||
html, body, #root { height: 100%; }
|
||||
|
||||
body { background: var(--bg); margin: 0; display: block; }
|
||||
|
||||
/* Dark theme variables */
|
||||
body[data-theme="dark"] {
|
||||
--bg: #161a2b;
|
||||
--panel: #283046;
|
||||
--text: #283046;
|
||||
--muted: #cbd5e1;
|
||||
--primary: #8b7bff;
|
||||
--primary-600: #7b69ff;
|
||||
--border: #283046;
|
||||
}
|
||||
|
||||
/* Layout */
|
||||
.app-layout { display: grid; grid-template-columns: 260px 1fr; height: 100%; }
|
||||
.sidebar { background: #15172a; color: #e5e7eb; display: flex; flex-direction: column; padding: 20px 12px; }
|
||||
.sidebar .logo { color: #fff; font-weight: 700; font-size: 18px; padding: 12px 14px; display: flex; align-items: center; gap: 10px; }
|
||||
.nav { margin-top: 12px; display: grid; gap: 4px; }
|
||||
.nav a, .nav button { color: #cbd5e1; text-align: left; background: transparent; border: 0; padding: 10px 12px; border-radius: 8px; cursor: pointer; }
|
||||
.nav a.active, .nav a:hover, .nav button:hover { background: rgba(255,255,255,0.08); color: #fff; }
|
||||
|
||||
.content { display: flex; flex-direction: column; height: 100%; }
|
||||
.topbar { height: 64px; display: flex; align-items: center; justify-content: space-between; padding: 0 24px; background: var(--panel); border-bottom: 1px solid var(--border); }
|
||||
.topbar .user { color: var(--muted); }
|
||||
.page { padding: 24px; max-width: 1100px; margin: auto; }
|
||||
|
||||
/* Cards */
|
||||
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
|
||||
.card h3 { margin: 0 0 12px; }
|
||||
|
||||
/* Forms */
|
||||
.input, select, textarea { width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border); background: #fff; color: var(--text); }
|
||||
.input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); border-color: var(--primary); }
|
||||
.form-row { display: grid; gap: 8px; grid-template-columns: repeat(4, minmax(0,1fr)); }
|
||||
.form-row > * { min-width: 140px; }
|
||||
.actions { display: flex; align-items: center; gap: 8px; }
|
||||
|
||||
/* Buttons */
|
||||
.btn { border: 1px solid var(--border); background: #fff; color: var(--text); padding: 10px 14px; border-radius: 10px; cursor: pointer; }
|
||||
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
|
||||
.btn.primary:hover { background: var(--primary-600); }
|
||||
.btn.ghost { background: transparent; color: var(--muted); }
|
||||
|
||||
/* Tables */
|
||||
.table { width: 100%; border-collapse: collapse; }
|
||||
.table th, .table td { padding: 10px; border-bottom: 1px solid var(--border); }
|
||||
.table th { text-align: left; color: var(--muted); font-weight: 600; }
|
||||
.table td.amount { text-align: right; font-variant-numeric: tabular-nums; }
|
||||
|
||||
/* Segmented control */
|
||||
.segmented { display: inline-flex; background: #f1f5f9; border-radius: 10px; padding: 4px; border: 1px solid var(--border); }
|
||||
.segmented button { border: 0; background: transparent; padding: 8px 12px; border-radius: 8px; color: var(--muted); cursor: pointer; }
|
||||
.segmented button.active { background: #fff; color: var(--text); box-shadow: var(--shadow); }
|
||||
|
||||
/* Auth layout */
|
||||
body.auth-page #root {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
min-height: 100vh;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
/* Utility */
|
||||
.muted { color: var(--muted); }
|
||||
.space-y > * + * { margin-top: 12px; }
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user