# oksanabaza/setu-final-project architecture

> Architecture diagram of the GitHub repository oksanabaza/setu-final-project, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-08). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/oksanabaza/setu-final-project
- Repository: https://github.com/oksanabaza/setu-final-project

## Overview

##### Main Components Identification
- Frontend:
- Base UI Layer: Represent the “frontend” directory, indicating that it handles client-side rendering, user interaction, and API communication. Note key files like index.html, main.jsx, and the components subdirectory.
- Client-Side Utilities: Mention API utility files (api.js) and configuration (e.g., .env, vite.config.js) that define how the client interacts with services.
- Backend:
- API Server: Represent the main Go application (backend/main.go) as the entry point for the API server.
- Authentication Module: Include the auth package (auth.go, jwt.go) which handles user authentication and JWT processing.
- Configuration Module: Mark the config folder (config.go), which manages settings and environment configurations.
- Database Layer: Highlight the database package (db.go) that encapsulates database connections and operations.
- Handlers: Illustrate the collection of handlers (results, scrape, scraping_tasks, templates, website) that serve as endpoints for different functionalities.
- Middleware: Add the middleware folder for cross-cutting concerns like authentication verification.
- Infrastructure and Deployment:
- Docker Compose: Reference the docker-compose.yml under the backend to indicate containerization or orchestration, which may include linked services (like the database or even the frontend in a deployment scenario).
- Shell Scripting: Note the scrape_task.sh if it’s used for scheduling or batch processing.

##### Relationships and Data Flow
- Within the backend, connect:
- The API Server to the Authentication Module (for securing endpoints).
- The API Server to Handlers, showing that each handler routes specific requests.
- Middleware to the API Server, showing that it intercepts incoming requests.

##### Highlighting Architectural Patterns and Technologies
- That there’s a clear separation of concerns: the frontend functions as the presentation layer while the backend acts as the business logic and data layer.
- The RESTful API pattern is implied by the presence of distinct handlers for each endpoint.
- Authentication through JWT and middleware-based request filtering indicates a secure design pattern.
- Containerization support via docker-compose hints at a design that favors reproducible deployment and possibly microservice or service isolation.

##### Detailed Component Separation
- For each backend module (auth, config, database, handlers, middleware), briefly note down its primary responsibility.
- For the frontend, emphasize components that handle user input (e.g., LoginForm, SignupForm), visualization (Charts, NivoCharts, SunburstCharts), and management (ScraperDashboard, ProfilePage).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Subgraph
    subgraph "Frontend (React/Vite)"
        FUI["Base UI (React/Vite)"]:::frontend
        FAPI["API Utility (api.js)"]:::utility
        FVite["Vite Config (vite.config.js)"]:::utility
        FEnv["Environment (.env)"]:::utility
    end

    %% Backend Subgraph
    subgraph "Backend (Go API)"
        APIServer["API Server (Go)"]:::backend
        Auth["Auth Module"]:::backend
        Config["Configuration Module"]:::backend
        Handlers["HTTP Handlers"]:::backend
        DB["Database Layer"]:::backend
        MW["Middleware"]:::middleware
        Docker["Docker Compose"]:::deployment
        Scrape["Scrape Task"]:::scheduled
    end

    %% Connections from Frontend to Backend
    FUI -->|"APIcalls"| APIServer
    FAPI -->|"APIcalls"| APIServer
    FVite -->|"config"| APIServer
    FEnv -->|"env"| APIServer

    %% Internal Backend Connections
    APIServer -->|"auth"| Auth
    APIServer -->|"routes"| Handlers
    Handlers -->|"dbops"| DB
    APIServer -->|"middleware"| MW
    APIServer -->|"config"| Config
    Scrape -->|"schedule"| Handlers
    Docker -->|"deploys"| APIServer
    Docker -->|"schedules"| Scrape

    %% Click Events for Frontend
    click FUI "https://github.com/oksanabaza/setu-final-project/tree/main/frontend/"
    click FAPI "https://github.com/oksanabaza/setu-final-project/blob/main/frontend/api.js"
    click FVite "https://github.com/oksanabaza/setu-final-project/blob/main/frontend/vite.config.js"
    click FEnv "https://github.com/oksanabaza/setu-final-project/blob/main/frontend/.env"

    %% Click Events for Backend
    click APIServer "https://github.com/oksanabaza/setu-final-project/blob/main/backend/main.go"
    click Auth "https://github.com/oksanabaza/setu-final-project/tree/main/backend/auth/"
    click Config "https://github.com/oksanabaza/setu-final-project/blob/main/backend/config/config.go"
    click Handlers "https://github.com/oksanabaza/setu-final-project/tree/main/backend/handlers/"
    click DB "https://github.com/oksanabaza/setu-final-project/blob/main/backend/database/db.go"
    click MW "https://github.com/oksanabaza/setu-final-project/tree/main/backend/middleware/"
    click Docker "https://github.com/oksanabaza/setu-final-project/blob/main/backend/docker-compose.yml"
    click Scrape "https://github.com/oksanabaza/setu-final-project/blob/main/backend/scrape_task.sh"

    %% Styles
    classDef frontend fill:#ccffcc,stroke:#333,stroke-width:1px;
    classDef utility fill:#aee1ff,stroke:#333,stroke-width:1px;
    classDef backend fill:#ffcccc,stroke:#333,stroke-width:1px;
    classDef middleware fill:#ffffcc,stroke:#333,stroke-width:1px;
    classDef deployment fill:#e0d8ff,stroke:#333,stroke-width:1px;
    classDef scheduled fill:#ffd9b3,stroke:#333,stroke-width:1px;
```
