# lizzy-gs/cs290final architecture

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

- Interactive diagram: https://gitdiagram.com/lizzy-gs/cs290final
- Repository: https://github.com/lizzy-gs/cs290final

## Overview

##### Main Components

A. Frontend Layer:
- Static Assets Component
- JavaScript files (script.js, tasksPage.js)
- CSS files (style.css, styleAccount.css, styleTasks.css)
- View Templates Component
- Handlebars templates (home, account, tasks)
- Layout templates (main.handlebars)

B. Backend Layer:
- Server Component (server.js)
- Authentication Service (auth.js)
- Database Service (db.js)
- Route Handlers
- User Management (login, logout, register, me)
- Task Management (tasks, todos)
- Preferences (set_theme)
- Data Operations (save, purchase)

C. Database Layer (implied by db.js)

**[Client Tier]**
- ↕
**[Application Tier]**
- ↕
**[Data Tier]**

##### Component Relationships to Highlight

- How the static assets are served to the client
- Template rendering flow using Handlebars
- Demonstrate the authentication flow through auth.js
- Route handling and API endpoints
- Database interactions
- Theme management flow (themes.json)

##### Specific Elements

- User Session Flow
- Task Management Flow
- Theme Management Flow
- Static Asset Serving
- Template Rendering Pipeline
- API Endpoints Structure

**[Client Browser]**
- ↓↑
**[Static Assets] ← [Handlebars Templates]**
- ↓↑
**[Express Server]**
- ↓↑
**[Route Handlers] ← [Authentication]**
- ↓↑
**[Database Layer]**

##### Additional Notes

- Notes about the development environment setup
- Deployment flow if relevant

Remember to:
- Keep components properly grouped by functionality
- Clear data flow directions
- Security boundaries
- Major subsystems
- Document external service interactions
- Caching or state management

This will provide a comprehensive view of the system while maintaining clarity and usefulness for development and maintenance purposes.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client
        Browser["Web Browser"]
        StaticAssets["Static Assets"]:::frontend
        Templates["View Templates"]:::frontend
    end

    subgraph Server
        ExpressServer["Express Server"]:::backend
        AuthService["Authentication Service"]:::auth
        BuildSystem["Build System"]:::dev
        ThemeManager["Theme Manager"]:::backend

        subgraph RouteHandlers["Route Handlers"]
            UserRoutes["User Management"]:::route
            TaskRoutes["Task Management"]:::route
            PrefRoutes["Preferences"]:::route
            DataRoutes["Data Operations"]:::route
        end
    end

    subgraph Storage
        Database[(Database)]:::storage
        ThemeStorage[("themes.json")]:::storage
    end

    subgraph Infrastructure
        Docker["Docker Container"]:::infra
        FlyIO["Fly.io Deployment"]:::infra
        Nodemon["Nodemon Dev Server"]:::dev
    end

    %% Relationships
    Browser --> StaticAssets
    Browser --> Templates
    StaticAssets --> ExpressServer
    Templates --> ExpressServer
    ExpressServer --> AuthService
    ExpressServer --> RouteHandlers
    ExpressServer --> ThemeManager
    AuthService --> Database
    RouteHandlers --> Database
    ThemeManager --> ThemeStorage
    ExpressServer --> BuildSystem
    ExpressServer --> Docker
    Docker --> FlyIO
    Nodemon --> ExpressServer

    %% Click Events
    click StaticAssets "https://github.com/lizzy-gs/cs290final/tree/main/static"
    click Templates "https://github.com/lizzy-gs/cs290final/tree/main/views"
    click ExpressServer "https://github.com/lizzy-gs/cs290final/blob/main/server.js"
    click AuthService "https://github.com/lizzy-gs/cs290final/blob/main/auth.js"
    click BuildSystem "https://github.com/lizzy-gs/cs290final/blob/main/build.js"
    click UserRoutes "https://github.com/lizzy-gs/cs290final/tree/main/routes"
    click TaskRoutes "https://github.com/lizzy-gs/cs290final/tree/main/routes"
    click PrefRoutes "https://github.com/lizzy-gs/cs290final/tree/main/routes"
    click DataRoutes "https://github.com/lizzy-gs/cs290final/tree/main/routes"
    click ThemeStorage "https://github.com/lizzy-gs/cs290final/blob/main/themes.json"
    click Docker "https://github.com/lizzy-gs/cs290final/tree/main/Dockerfile"
    click FlyIO "https://github.com/lizzy-gs/cs290final/blob/main/fly.toml"
    click Nodemon "https://github.com/lizzy-gs/cs290final/blob/main/nodemon.json"

    %% Styles
    classDef frontend fill:#3498db,stroke:#2980b9,color:white
    classDef backend fill:#2ecc71,stroke:#27ae60,color:white
    classDef auth fill:#e74c3c,stroke:#c0392b,color:white
    classDef storage fill:#f1c40f,stroke:#f39c12,color:black
    classDef route fill:#9b59b6,stroke:#8e44ad,color:white
    classDef infra fill:#34495e,stroke:#2c3e50,color:white
    classDef dev fill:#e67e22,stroke:#d35400,color:white

    %% Legend
    subgraph Legend
        Frontend["Frontend Component"]:::frontend
        Backend["Backend Component"]:::backend
        Auth["Authentication"]:::auth
        Storage["Storage"]:::storage
        Route["Route Handler"]:::route
        Infrastructure["Infrastructure"]:::infra
        Development["Development Tool"]:::dev
    end
```
