# spa51/front-end-spiro-sports architecture

> Architecture diagram of the GitHub repository spa51/front-end-spiro-sports, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-20). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/spa51/front-end-spiro-sports
- Repository: https://github.com/spa51/front-end-spiro-sports

## Overview

##### Project type and purpose
- This is a single‐page front-end application built with Angular (v17.1.0).
- Its responsibilities include user authentication (sign-in/log-in), managing “categories” and “locations,” and rendering a map view with markers.

##### File structure
- Top-level Angular config: angular.json, tsconfig*.json, package.json.
- src/app:
- app.component, app.config.ts, app.routes.ts
- components/: UI pieces grouped by feature (login, sign-in, nav-bar, list-category, edit-categorys, list-locations, edit-locations, map)
- services/: CategoryService, LocationService, UserService, ErrorService
- interfaces/: TypeScript interfaces for Category, Location, User
- utils/: HTTP interceptor (add-token.interceptor.ts), Route guard (auth.guard.ts)
- src/environments: dev/prod config
- Unit tests co-located with each service and component

##### Extract architecture clues from the README
- Angular CLI–generated SPA
- Dev server at localhost:4200, build outputs to dist/
- Standard Angular testing with Karma

a. Main components
- Browser/Client (the end user’s browser)
- Angular App (App Module)
– Components layer: UI components (Login, Sign-In, Nav-Bar, List/Edit Category, List/Edit Location, Map)
– Services layer: HTTP-backed services (UserService, CategoryService, LocationService, ErrorService)
– Utils: add-token interceptor, auth guard
– Routing: app.routes.ts orchestrating navigation
– Configuration: app.config.ts, environment.ts/prod
- External Backend API (RESTful endpoints for auth, categories, locations)
- Third-party Map API (e.g. Google Maps/OpenStreetMap)

b. Relationships & data flows
1. User interacts with a Component in the browser
2. Component invokes a Service (via dependency injection)
3. Service uses Angular HTTPClient, passing through add-token.interceptor for auth headers
4. HTTP request → External Backend API
5. Backend returns JSON → Service → Component (via RxJS Observable)
6. auth.guard protects routes by blocking unauthorized access
7. Component calls external Maps API (e.g. to render markers)

c. Architectural patterns & principles
- Component-based UI with separation of concerns
- Layered architecture: Presentation (Components) → Business/data (Services) → Infrastructure (HTTP/Interceptors)
- Dependency Injection for services & guards
- Route-driven navigation configured centrally in app.routes.ts
- Environment-based configuration (dev vs production)

d. Key technologies & frameworks
- Angular (CLI, Router, HTTPClient, DI system)
- RxJS Observables for async data streams
- TypeScript interfaces for strong typing
- Karma/Jasmine for unit tests
- CSS/HTML for component templates
- External map library (map component)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% External Entities
    User["User Browser"]:::external
    Backend["External Backend API (/api)"]:::api
    MapAPI["Map API (e.g., Google Maps)"]:::api

    %% Angular Application
    subgraph "Angular SPA"
        subgraph "App Module"
            AppComponent["AppComponent"]:::component
            AppConfig["Application Config"]:::config
            AppRoutes["Routing Module (app.routes.ts)"]:::config
        end

        subgraph "Components"
            Login["LoginComponent"]:::component
            SignIn["SignInComponent"]:::component
            NavBar["NavBarComponent"]:::component
            ListCat["ListCategoryComponent"]:::category
            EditCat["EditCategorysComponent"]:::category
            ListLoc["ListLocationsComponent"]:::location
            EditLoc["EditLocationsComponent"]:::location
            MapCmp["MapComponent"]:::component
        end

        subgraph "Services"
            UserSvc["UserService"]:::service
            CatSvc["CategoryService"]:::service
            LocSvc["LocationService"]:::service
            ErrSvc["ErrorService"]:::service
        end

        subgraph "Utilities"
            Interceptor["AddTokenInterceptor"]:::util
            AuthGuard["AuthGuard"]:::util
        end

        subgraph "Interfaces"
            UserIf["User"]:::interface
            CatIf["Category"]:::interface
            LocIf["Location"]:::interface
        end

        subgraph "Environment"
            EnvDev["environment.ts"]:::config
            EnvProd["environment.prod.ts"]:::config
        end

        subgraph "Static Assets"
            Icons["icons/"]:::asset
        end
    end

    %% User Interactions
    User -->|navigates| Login
    User -->|navigates| SignIn
    User -->|sees| NavBar
    User -->|views| ListCat
    User -->|views| ListLoc
    User -->|edits| EditCat
    User -->|edits| EditLoc
    User -->|views map| MapCmp
    User -->|loads| Icons

    %% Routing
    AppRoutes -->|login route| Login
    AppRoutes -->|sign-in route| SignIn
    AppRoutes -->|categories route| ListCat
    AppRoutes -->|locations route| ListLoc
    AppRoutes -->|map route| MapCmp
    AuthGuard -->|protects categories,locations,map| AppRoutes

    %% Component to Service calls
    Login -->|uses| UserSvc
    SignIn -->|uses| UserSvc
    ListCat -->|uses| CatSvc
    EditCat -->|uses| CatSvc
    ListLoc -->|uses| LocSvc
    EditLoc -->|uses| LocSvc
    MapCmp -->|uses| LocSvc

    %% Services and HTTP
    UserSvc -->|HTTP| Backend
    CatSvc -->|HTTP| Backend
    LocSvc -->|HTTP| Backend
    ErrSvc -->|handles errors from| Backend
    Backend -->|JSON| UserSvc
    Backend -->|JSON| CatSvc
    Backend -->|JSON| LocSvc

    Interceptor -.->|intercepts HTTP calls| UserSvc
    Interceptor -.->|intercepts HTTP calls| CatSvc
    Interceptor -.->|intercepts HTTP calls| LocSvc
    Interceptor -.->|intercepts HTTP calls| ErrSvc

    %% Map API call
    MapCmp -->|calls| MapAPI

    %% Interfaces usage
    UserSvc -->|returns| UserIf
    CatSvc -->|returns| CatIf
    LocSvc -->|returns| LocIf
    Login -->|models| UserIf
    SignIn -->|models| UserIf
    ListCat -->|models| CatIf
    EditCat -->|models| CatIf
    ListLoc -->|models| LocIf
    EditLoc -->|models| LocIf

    %% Config & Env
    AppConfig --> EnvDev
    AppConfig --> EnvProd

    %% Click Events
    click AppComponent "https://github.com/spa51/front-end-spiro-sports/blob/main/src/app/app.component.ts"
    click AppConfig "https://github.com/spa51/front-end-spiro-sports/blob/main/src/app/app.config.ts"
    click AppRoutes "https://github.com/spa51/front-end-spiro-sports/blob/main/src/app/app.routes.ts"
    click Login "https://github.com/spa51/front-end-spiro-sports/blob/main/src/app/components/login/login.component.ts"
    click SignIn "https://github.com/spa51/front-end-spiro-sports/blob/main/src/app/components/sign-in/sign-in.component.ts"
    click NavBar "https://github.com/spa51/front-end-spiro-sports/blob/main/src/app/components/nav-bar/nav-bar.component.ts"
    click ListCat "https://github.com/spa51/front-end-spiro-sports/blob/main/src/app/components/list-category/list-category.component.ts"
    click EditCat "https://github.com/spa51/front-end-spiro-sports/blob/main/src/app/components/edit-categorys/edit-categorys.component.ts"
    click ListLoc "https://github.com/spa51/front-end-spiro-sports/blob/main/src/app/components/list-locations/list-locations.component.ts"
    click EditLoc "https://github.com/spa51/front-end-spiro-sports/blob/main/src/app/components/edit-locations/edit-locations.component.ts"
    click MapCmp "https://github.com/spa51/front-end-spiro-sports/blob/main/src/app/components/map/map.component.ts"
    click UserSvc "https://github.com/spa51/front-end-spiro-sports/blob/main/src/app/services/user.service.ts"
    click CatSvc "https://github.com/spa51/front-end-spiro-sports/blob/main/src/app/services/category.service.ts"
    click LocSvc "https://github.com/spa51/front-end-spiro-sports/blob/main/src/app/services/location.service.ts"
    click ErrSvc "https://github.com/spa51/front-end-spiro-sports/blob/main/src/app/services/error.service.ts"
    click UserIf "https://github.com/spa51/front-end-spiro-sports/blob/main/src/app/interfaces/user.ts"
    click CatIf "https://github.com/spa51/front-end-spiro-sports/blob/main/src/app/interfaces/category.ts"
    click LocIf "https://github.com/spa51/front-end-spiro-sports/blob/main/src/app/interfaces/location.ts"
    click Interceptor "https://github.com/spa51/front-end-spiro-sports/blob/main/src/app/utils/add-toke.interceptor.ts"
    click AuthGuard "https://github.com/spa51/front-end-spiro-sports/blob/main/src/app/utils/auth.guard.ts"
    click EnvDev "https://github.com/spa51/front-end-spiro-sports/blob/main/src/environments/environment.ts"
    click EnvProd "https://github.com/spa51/front-end-spiro-sports/blob/main/src/environments/environment.prod.ts"
    click Icons "https://github.com/spa51/front-end-spiro-sports/tree/main/src/assets/icons/"

    %% Styles
    classDef component fill:#AEDFF7,stroke:#036;
    classDef service fill:#F7D6AE,stroke:#630;
    classDef util fill:#D3F7AE,stroke:#3A6;
    classDef interface fill:#F7AECF,stroke:#630;
    classDef config fill:#E2E2E2,stroke:#999;
    classDef asset fill:#DADADA,stroke:#666;
    classDef api fill:#C8E6C9,stroke:#256;
    classDef external fill:#FFFFFF,stroke:#000,stroke-dasharray: 5 5
```
