# atcoder-novisteps/atcodernovisteps architecture

> Architecture diagram of the GitHub repository atcoder-novisteps/atcodernovisteps, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-31). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/atcoder-novisteps/atcodernovisteps
- Repository: https://github.com/atcoder-novisteps/atcodernovisteps

## Overview

##### Main Components
- Frontend UI: Built using Svelte/SvelteKit. All the view files are in the “src/routes” and “src/lib/components” directories. These include pages for login, signup, workbooks, problem lists, user profiles, and administrative views.
- Backend Server/Routes: The SvelteKit server endpoints (files with “+page.server.ts” and other server entry points) handle server-side logic including authentication and data processing.
- Database & Data Access Layer: The “prisma” folder contains the database schema, migrations, seed files, and utility scripts. This shows that Prisma is the chosen ORM, managing the connection to the database.
- External API Clients: Located in “src/lib/clients”, these modules (e.g., aizu_online_judge.ts, atcoder_problems.ts) encapsulate integrations with external programming contest services.
- Business Logic/Services: Under “src/lib/services” you see several modules (e.g., tasks, workbooks, users) that act as the core business logic layer interacting between the frontend/server and the database.
- Testing Infrastructure: With dedicated “src/test” and “tests” directories, the project includes unit and integration tests (including Playwright and other testing frameworks), showing emphasis on quality and stability.
- DevOps & Deployment: With Dockerfile, compose.yaml, GitHub workflows, and container configuration under “.devcontainer”, the project is set up to support containerized development and continuous integration/deployment.

##### Relationships and Interaction Flows
- Users interact with the Frontend (UI components in “src/lib/components” and pages in “src/routes”) to perform actions such as logging in, updating problem status, and viewing workbooks.
- The Frontend communicates via HTTP/API calls to SvelteKit “server” endpoints (e.g., the “+page.server.ts” files) which serve as the controllers.
- Server endpoints call business logic services (in “src/lib/services”) that encapsulate application rules such as recording answers, updating workbook data, and processing submissions.
- The services interact with the database via Prisma (using configuration files and schema in the “prisma” directory) to perform CRUD operations and maintain synchronization of user data.
- Some services also use external API clients (in “src/lib/clients”) to fetch or update contest problems and data from platforms like AtCoder and Aizu Online Judge.
- The testing components (both unit tests in “src/test” and the end-to-end tests in “tests”) verify that each layer is working correctly and that the data flows between these components adhere to expectations.

##### Architectural Patterns and Design Principles
- Separation of Concerns: The project is structured to separate the UI (Svelte components), server-side routing (in “src/routes”), business logic/services (in “src/lib/services”), and data access via Prisma (in “prisma”).
- Modular Design: Each group of related functionalities (e.g., authentication, workbook management, task/result updates) is kept in its own module or subdirectory, simplifying maintenance and testing.
- MVC-Like Flow: Although not a strict MVC framework, the use of SvelteKit’s routing (controllers), Svelte components (views), and services/Prisma (model) provide a clear separation much like the MVC paradigm.

## Diagram (Mermaid)

```mermaid
flowchart TD
    A["User Browser"]:::browser

    subgraph "Frontend UI"
        FE1["Pages"]:::frontend
        FE2["Components"]:::frontend
    end

    A --> FE1
    A --> FE2

    B["Backend Server (SvelteKit Routes)"]:::server
    FE1 --> B
    FE2 --> B

    subgraph "Business Logic/Services"
        BL1["Tasks Service"]:::logic
        BL2["Users Service"]:::logic
    end
    B --> BL1
    B --> BL2

    DB["Database (Prisma ORM)"]:::database
    BL1 --> DB
    BL2 --> DB

    subgraph "External API Clients"
        API_Aizu["Aizu Client"]:::api
        API_Atcoder["Atcoder Client"]:::api
    end
    BL1 --> API_Aizu
    BL2 --> API_Atcoder

    subgraph "Testing Infrastructure"
        T1["Unit Tests (src/test)"]:::test
        T2["E2E Tests (tests)"]:::test
    end
    B --- T1
    B --- T2

    subgraph "DevOps & Deployment"
        D1["Dockerfile"]:::devops
        D2["compose.yaml"]:::devops
        D3[".devcontainer"]:::devops
        D4[".github/workflows"]:::devops
    end
    B --- D1
    B --- D2
    B --- D3
    B --- D4

    click FE1 "https://github.com/atcoder-novisteps/atcodernovisteps/tree/staging/src/routes"
    click FE2 "https://github.com/atcoder-novisteps/atcodernovisteps/tree/staging/src/lib/components"
    click B "https://github.com/atcoder-novisteps/atcodernovisteps/blob/staging/src/routes/(auth)/login/+page.server.ts"
    click BL1 "https://github.com/atcoder-novisteps/atcodernovisteps/blob/staging/src/lib/services/tasks.ts"
    click BL2 "https://github.com/atcoder-novisteps/atcodernovisteps/blob/staging/src/lib/services/users.ts"
    click DB "https://github.com/atcoder-novisteps/atcodernovisteps/blob/staging/prisma/schema.prisma"
    click API_Aizu "https://github.com/atcoder-novisteps/atcodernovisteps/blob/staging/src/lib/clients/aizu_online_judge.ts"
    click API_Atcoder "https://github.com/atcoder-novisteps/atcodernovisteps/blob/staging/src/lib/clients/atcoder_problems.ts"
    click T1 "https://github.com/atcoder-novisteps/atcodernovisteps/tree/staging/src/test"
    click T2 "https://github.com/atcoder-novisteps/atcodernovisteps/tree/staging/tests"
    click D1 "https://github.com/atcoder-novisteps/atcodernovisteps/tree/staging/Dockerfile"
    click D2 "https://github.com/atcoder-novisteps/atcodernovisteps/blob/staging/compose.yaml"
    click D3 "https://github.com/atcoder-novisteps/atcodernovisteps/blob/staging/.devcontainer"
    click D4 "https://github.com/atcoder-novisteps/atcodernovisteps/tree/staging/.github/workflows"

    class A browser
    class FE1,FE2 frontend
    class B server
    class BL1,BL2 logic
    class DB database
    class API_Aizu,API_Atcoder api
    class T1,T2 test
    class D1,D2,D3,D4 devops
```
