# abdullahhasan42/streamlit-team-activity-crud architecture

> Architecture diagram of the GitHub repository abdullahhasan42/streamlit-team-activity-crud, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-03-14). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/abdullahhasan42/streamlit-team-activity-crud
- Repository: https://github.com/abdullahhasan42/streamlit-team-activity-crud

## Overview

Summary / Project type and purpose
- This is a small single-repository web application (monolith) implemented with Streamlit that provides a CRUD interface for logging team activities.
- Purpose: authenticated users open the Streamlit UI, fill forms and view/update team activity records which are persisted in a Google Sheets spreadsheet. The app is hosted on Render. Authentication is handled with streamlit-authenticator.

Analysis of the file tree and README
- Files:
- login.py — responsibility: authentication UI / login flow (Streamlit + streamlit-authenticator).
- team.py — responsibility: the main app pages / CRUD forms and Views for activities.
- requirements.txt — lists runtime libraries (not shown, but expect streamlit, streamlit-authenticator, Google Sheets client libs, pandas, etc.).
- img/ — static images used in README and UI (branding/screenshots).
- README.md — describes the architecture: Streamlit front-end, Google Sheets backend, hosted on Render.
- Architectural inference:
- Single-process Streamlit server serves browser UI to users.
- The Streamlit app calls Google Sheets API (via a Python client library or gspread/pygsheets) for persistence.
- Authentication occurs in-process using streamlit-authenticator.
- Deployment is handled by Render; secrets (Google credentials, auth config) are expected to be supplied as environment variables / Render secrets.

##### Main components
- Users (Browsers / Clients)
- Streamlit App (single server process in the repo)
- Authentication module (login.py + streamlit-authenticator)
- UI / Presentation layer (forms, pages — team.py)
- Business logic / CRUD handlers (functions that validate input and call storage)
- External assets (img directory)
- Persistence: Google Sheets (spreadsheet(s) storing activities)
- Hosting / Infrastructure: Render (app host that runs the Streamlit server)
- Source repository (GitHub) — optional but useful to show code origin / CI
- Secrets & Config store (Render environment variables / service account JSON)
- External services & APIs: Google Sheets API / Google OAuth (token endpoint) — show as distinct external service

##### Relationships and interactions (show these
- User -> HTTPS -> Render-hosted Streamlit app: browser sends requests, receives HTML/JS stream.
- Streamlit app (authentication module) -> streamlit-authenticator (internal lib) — validate credentials (local hash or credentials config).
- Streamlit app -> Google Sheets API (via client library) using OAuth/service account credentials — read/write CRUD operations.
- Streamlit app -> Render (runtime environment) for environment variables/secrets access (show as the app reading secrets).
- Data flow for CRUD:
- Create/Register Activity: User fills form -> Streamlit UI -> Business logic validates -> Google Sheets API write -> confirmation to UI.
- Read/List Activities: UI requests -> Google Sheets API read -> UI displays table.
- Update/Delete: same pattern via row index / ID in sheet.

##### Important architectural patterns & design principles used
- Monolithic single-process server: UI, auth and persistence code run in same Streamlit process.
- Thin UI / server-side app model: Streamlit keeps state server-side; the browser is a thin client.
- Externalized persistence: uses Google Sheets as a remote store (not a traditional DB). This implies eventual consistency, limited query abilities, and rate limits.
- Secret management: Authorization credentials (service account JSON or OAuth tokens) must be kept out of source and provided via environment variables or a secret manager at deployment.

- Streamlit (frontend / app server)
- streamlit-authenticator (authentication)
- Google Sheets API (persistence) — implemented via a Python client library such as gspread or google-api-python-client (check requirements.txt)
- Hosting: Render
- Python runtime (requirements.txt)
- Optional: pandas for data handling; OAuth / service account credential mechanism (google-auth)
- Tools (repo): GitHub (README and images in repo)

- Boundaries:
- Client boundary: browser clients vs server (Streamlit).
- Deployment boundary: Render-hosted runtime vs external Google services.
- Separation of concerns even inside the single-process app:
- Authentication module (login.py) clearly separated from the CRUD pages (team.py).
- Operational and security concerns:
- Where secrets/config reside (Render secrets / environment variables).
- Network protocol (HTTPS) between client and Streamlit server, and HTTPS/TLS to Google APIs.

- Layout:
- Left: Users (Browsers)
- Top/Bottom: Git repo/CI and Monitoring/Logs
- UI / client components: light blue
- App components (auth, business logic): green
- Data stores / persistence: orange/yellow
- External cloud services / hosting: purple/gray

- login.py -> Authentication module (Streamlit UI + streamlit-authenticator)
- team.py -> UI pages and CRUD handlers (forms + business logic)
- README.md -> documentation (annotate as repo-level artifact)

- Secrets and config:
- How are Google credentials provided? (service account JSON stored as Render secret or environment variable)
- How are user credentials or auth config provided for streamlit-authenticator? (YAML/ENV/config)
- Scalability & limitations:
- Google Sheets as DB: low write throughput, limited concurrent edits, limited query capabilities.
- Introduce a Storage Adapter interface between business logic and Google Sheets (makes swap to a SQL DB easier).

- Clear, human-readable labels for all components (match names in the repo: login.py, team.py).
- Notes for secrets and config (where they live and who can access them).

Closing guidance

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Top: Users
    A["User Browser\n(Clients)"]:::client

    %% Render hosting boundary containing the Streamlit app
    subgraph "Render (Hosting & Runtime)" 
        style RenderBoundary fill:#f3f0ff,stroke:#9b87ff
        subgraph "Streamlit App (single-process monolith)"
            direction TB
            UI["UI / Presentation\n(team.py)"]:::ui
            Auth["Authentication Module\n(login.py)\n(streamlit-authenticator)"]:::auth
            BL["Business Logic / CRUD\n(team.py)"]:::logic
            Adapter["Storage Adapter\n(gspread / google-api client)"]:::adapter
            Assets["Static Assets\n(img/)"]:::assets
            Secrets["Secrets & Config\n(Render env vars / service account JSON)"]:::secrets

            %% internal flows
            UI -->|"invokes forms / pages"| BL
            UI -->|"renders images"| Assets
            UI -->|"requires auth"| Auth
            Auth -->|"validates credentials (in-process)"| Secrets
            BL -->|"uses creds"| Secrets
            BL -->|"calls Sheets via adapter (HTTPS + OAuth2)"| Adapter
        end
    end

    %% External services to the right
    GSAPI["Google Sheets\n(Spreadsheet storage)"]:::db
    GoogleAuth["Google OAuth / IAM\n(Token endpoint, Service Account)"]:::external
    GitHub["GitHub Repo\n(source code, README.md, img/)"]:::repo
    Logs["Render Logs / Monitoring"]:::monitor

    %% Connections from Users to Streamlit App (via Render)
    A -->|"HTTPS (browser <-> Streamlit UI)"| UI

    %% App to external Google services (secure HTTPS)
    Adapter -->|"HTTPS (Google Sheets API)"| GSAPI
    Adapter -->|"OAuth2 / Service Account (token exchange)"| GoogleAuth

    %% Deployment & CI
    GitHub -->|"push / webhook -> Render deploy"| RenderBoundary

    %% Monitoring access
    RenderBoundary -->|"runtime logs"| Logs

    %% CRUD sequence inset (vertical)
    subgraph "CRUD Flow (Create Activity)" 
        direction TB
        C1["1. User fills form\n(UI - team.py)"]:::step
        C2["2. UI posts to Business Logic\n(team.py)"]:::step
        C3["3. Business Logic validates\nand formats data"]:::step
        C4["4. Storage Adapter writes\nvia Google Sheets API"]:::step
        C5["5. Google Sheets stores row\nand returns success"]:::step
        C6["6. UI shows confirmation"]:::step

        C1 --> C2 --> C3 --> C4 --> C5 --> C6
        C4 -->|"HTTPS + OAuth2"| GSAPI
    end

    %% Legend / Technologies
    subgraph "Legend & Tech Stack"
        direction TB
        L1["Streamlit"]:::tech
        L2["streamlit-authenticator"]:::tech
        L3["gspread / google-api-python-client\ngoogle-auth"]:::tech
        L4["Render (hosting)"]:::tech
        L5["GitHub (repo)"]:::tech
        L6["Pandas, Requirements.txt"]:::tech
    end

    %% Notes for secrets & security
    NoteSecrets["Note: Secrets stored in Render env vars\n(service account JSON, auth config)"]:::note
    Secrets --> NoteSecrets

    %% Click events for mapped components (paths only)
    click Auth "https://github.com/abdullahhasan42/streamlit-team-activity-crud/blob/master/login.py"
    click UI "https://github.com/abdullahhasan42/streamlit-team-activity-crud/blob/master/team.py"
    click BL "https://github.com/abdullahhasan42/streamlit-team-activity-crud/blob/master/team.py"
    click Assets "https://github.com/abdullahhasan42/streamlit-team-activity-crud/tree/master/img/"
    click L6 "https://github.com/abdullahhasan42/streamlit-team-activity-crud/blob/master/requirements.txt"
    click GitHub "https://github.com/abdullahhasan42/streamlit-team-activity-crud/blob/master/README.md"

    %% Styling
    classDef client fill:#e6f7ff,stroke:#66b3ff,color:#03396c;
    classDef ui fill:#e8fff0,stroke:#2dbf63,color:#044d22;
    classDef auth fill:#fff3e6,stroke:#ffb84d,color:#663800;
    classDef logic fill:#e8fbff,stroke:#33c1ff,color:#003f5c;
    classDef adapter fill:#fff0f5,stroke:#ff80bf,color:#5b1033;
    classDef assets fill:#fffbe6,stroke:#ffd24d,color:#6b4f00;
    classDef secrets fill:#ffecec,stroke:#ff6b6b,color:#7a1120;
    classDef db fill:#fff2cc,stroke:#ffcc33,color:#663c00;
    classDef external fill:#f2f2f7,stroke:#bfbfdc,color:#3f3f5c;
    classDef repo fill:#f0f7ff,stroke:#99ccff,color:#0a3f66;
    classDef monitor fill:#f7f0ff,stroke:#c8a2ff,color:#3f1f66;
    classDef step fill:#f0fff4,stroke:#88f0a0,color:#0a5f2a;
    classDef tech fill:#ffffff,stroke:#cccccc,color:#222222;
    classDef note fill:#fff1f1,stroke:#ffbdbd,color:#7a0b0b;

    %% Ensure RenderBoundary node reference for GitHub arrow
    RenderBoundary((" ")):::external
    style RenderBoundary stroke-width:2px,stroke-dasharray: 5 5

    %% Vertical layout enforcement
    A --- RenderBoundary
    RenderBoundary --- GSAPI
    RenderBoundary --- GitHub
    RenderBoundary --- Logs
```
