# aymensat/satsat_first architecture

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

- Interactive diagram: https://gitdiagram.com/aymensat/satsat_first
- Repository: https://github.com/aymensat/satsat_first

## Overview

##### Project type and purpose
- This is a **full-stack Angular Universal** project:
- Frontend: Angular SPA with multiple feature modules (admin, teacher, student).
- SSR layer: `server.ts` and `main.server.ts` set up an Express server for server-side rendering.
- No embedded database code—data is fetched from external REST APIs via services (e.g., `admin.service.ts`, `auth.service.ts`).

##### File structure
- Top-level:
- Angular CLI files (`angular.json`, `tsconfig.json`, etc.)
- `public/` and `src/` directories
- `src/` breakdown:
- `app/` – core Angular modules, components and routing (`app.routes.ts`)
- `app/guards/` – route-guard classes (`auth.guard.ts`, etc.)
- `app/services/` – HTTP services & an interceptor for JWT
- Feature modules:
– `admin-space/`
– `teacher-space/`
– `student-space/`
– `login/`, `navbar/`
- `main.ts` – client bootstrap
- `main.server.ts` & `server.ts` – SSR bootstrap and Express server

##### Extract architecture hints from the README
- Built/served via `ng serve` for dev
- Built into `dist/` for production (separate browser + server bundles)
- No mention of internal DB: it relies on remote HTTP backends.

##### Main components & interactions
a. **Browser Client**
– Loads initial HTML/CSS/JS assets.
– Runs Angular app in the browser after hydration.
b. **Angular Universal Server**
– Express app in `server.ts` uses `main.server.ts` to pre-render pages.
– Serves static assets plus pre-rendered HTML.
c. **External REST API**
– Unspecified (likely running elsewhere).
– Services (`auth.service.ts`, `admin.service.ts`, etc.) make HTTP calls.
d. **Feature Modules**
– `AdminSpace`, `TeacherSpace`, `StudentSpace`, `Login`, `Navbar`.
– Route guards secure routes (`AuthGuard`, `AdminGuard`, `TeacherGuard`).

Relationships:
– Browser ↔ SSR Server: HTTP requests for pages & assets
– SSR Server ↔ External API: HTTP for data fetching during SSR
– Browser App ↔ External API: HTTP via JWT-intercepted requests after hydration

##### Architectural patterns & design principles
- **Modular design**: each feature is a separate Angular module/component folder
- **Separation of concerns**:
- Guards handle routing/security
- Services handle API interaction
- **Universal rendering**: dual bootstraps (client & server)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Browser Client Layer
    subgraph "Browser Client"
        direction TB
        MC["main.ts"]:::frontend
        IDX["index.html"]:::frontend
    end

    Browser["Browser Client"]:::frontend

    %% Angular Universal Server Layer
    subgraph "Angular Universal Server"
        direction TB
        SS["server.ts"]:::ssr
        MS["main.server.ts"]:::ssr
        AR["app.routes.ts"]:::ssr
        AC1["app.config.ts"]:::ssr
        AC2["app.config.server.ts"]:::ssr

        subgraph "Route Guards"
            direction TB
            G1["auth.guard.ts"]:::ssr
            G2["admin.guard.ts"]:::ssr
            G3["teacher.guard.ts"]:::ssr
        end

        subgraph "HTTP Services & Interceptor"
            direction TB
            S1["auth.service.ts"]:::ssr
            S2["admin.service.ts"]:::ssr
            S3["teacher-space.service.ts"]:::ssr
            S4["student-space.service.ts"]:::ssr
            S5["jwt-interceptor.ts"]:::ssr
        end

        subgraph "Feature Modules"
            direction TB
            subgraph "AdminSpace"
                direction TB
                A_TS["admin-space.component.ts"]:::frontend
                A_HTML["admin-space.component.html"]:::frontend
                A_CSS["admin-space.component.css"]:::frontend
            end
            subgraph "TeacherSpace"
                direction TB
                T_TS["teacher-space.component.ts"]:::frontend
                T_HTML["teacher-space.component.html"]:::frontend
                T_CSS["teacher-space.component.css"]:::frontend
            end
            subgraph "StudentSpace"
                direction TB
                St_TS["student-space.component.ts"]:::frontend
                St_HTML["student-space.component.html"]:::frontend
                St_CSS["student-space.component.css"]:::frontend
            end
            subgraph "Login"
                direction TB
                L_TS["login.component.ts"]:::frontend
                L_HTML["login.component.html"]:::frontend
                L_CSS["login.component.css"]:::frontend
            end
            subgraph "Navbar"
                direction TB
                N_TS["navbar.component.ts"]:::frontend
                N_HTML["navbar.component.html"]:::frontend
                N_CSS["navbar.component.css"]:::frontend
            end
        end
    end

    ExternalAPI["External REST API"]:::external

    %% Connections
    Browser -->|"GET /admin"| SS
    SS -->|"HTTP GET /api/... "| ExternalAPI
    Browser -->|"XHR POST /auth/login"| ExternalAPI

    %% Click Events
    click MC "https://github.com/aymensat/satsat_first/blob/main/src/main.ts"
    click IDX "https://github.com/aymensat/satsat_first/blob/main/src/index.html"
    click SS "https://github.com/aymensat/satsat_first/blob/main/src/server.ts"
    click MS "https://github.com/aymensat/satsat_first/blob/main/src/main.server.ts"
    click AR "https://github.com/aymensat/satsat_first/blob/main/src/app/app.routes.ts"
    click AC1 "https://github.com/aymensat/satsat_first/blob/main/src/app/app.config.ts"
    click AC2 "https://github.com/aymensat/satsat_first/blob/main/src/app/app.config.server.ts"
    click G1 "https://github.com/aymensat/satsat_first/blob/main/src/app/guards/auth.guard.ts"
    click G2 "https://github.com/aymensat/satsat_first/blob/main/src/app/guards/admin.guard.ts"
    click G3 "https://github.com/aymensat/satsat_first/blob/main/src/app/guards/teacher.guard.ts"
    click S1 "https://github.com/aymensat/satsat_first/blob/main/src/app/services/auth.service.ts"
    click S2 "https://github.com/aymensat/satsat_first/blob/main/src/app/services/admin.service.ts"
    click S3 "https://github.com/aymensat/satsat_first/blob/main/src/app/services/teacher-space.service.ts"
    click S4 "https://github.com/aymensat/satsat_first/blob/main/src/app/services/student-space.service.ts"
    click S5 "https://github.com/aymensat/satsat_first/blob/main/src/app/services/jwt-interceptor.ts"
    click A_TS "https://github.com/aymensat/satsat_first/blob/main/src/app/admin-space/admin-space.component.ts"
    click A_HTML "https://github.com/aymensat/satsat_first/blob/main/src/app/admin-space/admin-space.component.html"
    click A_CSS "https://github.com/aymensat/satsat_first/blob/main/src/app/admin-space/admin-space.component.css"
    click T_TS "https://github.com/aymensat/satsat_first/blob/main/src/app/teacher-space/teacher-space.component.ts"
    click T_HTML "https://github.com/aymensat/satsat_first/blob/main/src/app/teacher-space/teacher-space.component.html"
    click T_CSS "https://github.com/aymensat/satsat_first/blob/main/src/app/teacher-space/teacher-space.component.css"
    click St_TS "https://github.com/aymensat/satsat_first/blob/main/src/app/student-space/student-space.component.ts"
    click St_HTML "https://github.com/aymensat/satsat_first/blob/main/src/app/student-space/student-space.component.html"
    click St_CSS "https://github.com/aymensat/satsat_first/blob/main/src/app/student-space/student-space.component.css"
    click L_TS "https://github.com/aymensat/satsat_first/blob/main/src/app/login/login.component.ts"
    click L_HTML "https://github.com/aymensat/satsat_first/blob/main/src/app/login/login.component.html"
    click L_CSS "https://github.com/aymensat/satsat_first/blob/main/src/app/login/login.component.css"
    click N_TS "https://github.com/aymensat/satsat_first/blob/main/src/app/navbar/navbar.component.ts"
    click N_HTML "https://github.com/aymensat/satsat_first/blob/main/src/app/navbar/navbar.component.html"
    click N_CSS "https://github.com/aymensat/satsat_first/blob/main/src/app/navbar/navbar.component.css"

    %% Styles
    classDef frontend fill:#cce5ff,stroke:#333,stroke-width:1px
    classDef ssr fill:#d4edda,stroke:#333,stroke-width:1px
    classDef external fill:#f8f9fa,stroke:#999,stroke-dasharray: 5 5
    class Browser,MC,IDX,A_TS,A_HTML,A_CSS,T_TS,T_HTML,T_CSS,St_TS,St_HTML,St_CSS,L_TS,L_HTML,L_CSS,N_TS,N_HTML,N_CSS frontend
    class SS,MS,AR,AC1,AC2,G1,G2,G3,S1,S2,S3,S4,S5 ssr
    class ExternalAPI external
```
