# radadiyaaditya/telescope_logging architecture

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

- Interactive diagram: https://gitdiagram.com/radadiyaaditya/telescope_logging
- Repository: https://github.com/radadiyaaditya/telescope_logging

## Overview

##### Project Type and Purpose
- The project is a web-based telescope logging system used for recording astronomical observation data.
- It combines a Django-based frontend (using Django Templates for the user interface) with real-time functionalities (using WebSockets via Django channels) and REST API endpoints (referenced as FastAPI in the README, suggesting an integration or a migrated/parallel API style) that let users start and end observation sessions.
- The system stores observational records in a relational database. Although the repository includes a SQLite file (db.sqlite3) for ease of use or development, PostgreSQL is referenced as the intended production database.

##### Analyzing the File Structure
- Top-level Files/Folders:
- “manage.py” and the “telescope_log” directory form the core Django project setup (including ASGI, WSGI, settings, and URL configuration).
- “logging_system” acts as the main Django application, containing models, views, forms, templates, consumers (for live data/WebSocket handling), migrations, tests, and routing.
- The presence of “db.sqlite3” indicates the default database; however, PostgreSQL is used for deployment.
- The “requirements.txt” file lists dependencies and confirms Python/Django as the underlying framework.
- Key Components Extracted:
- Backend Logic: “views.py”, “models.py”, “forms.py”, and various migrations.
- Real-Time Communication: “consumers.py” in the logging_system app and asynchronous setup in “telescope_log/asgi.py.”
- Frontend UI: Templates in “logging_system/templates/logging_system.”
- Deployment/Configuration: “telescope_log/settings.py”, “urls.py”, and ASGI/WSGI configurations.

- Main Components:
- Client Interface: Web browsers or API consumers.
- Frontend: Django templates that render the UI components for logging observations.
- Backend Application Server: The core Django application, including both HTTP view handling and asynchronous WebSocket consumers.
- API layer endpoints (e.g., POST /log/start, GET /logs) which may be illustrated as a separate service or as a part of the Django app that interacts with external API testing tools (like Swagger UI).
- Real-time Communication Manager: Highlight how WebSocket connections (handled by “consumers.py” and facilitated through the ASGI configuration in “telescope_log/asgi.py”) allow for live updates (e.g., real-time LST & UTC updates).

- Representing Relationships and Interactions:
- Browser ⇄ Frontend (Django Templates rendering HTML).
- Browser/API Client ⇄ API Endpoints (indicating HTTP/REST calls for logging session start and end).
- Browser ⇄ WebSocket connection (real-time data streaming).
- If applicable, show interactions between the asynchronous components and standard synchronous endpoints.
- Configuration modules (ASGI/WSGI settings, routing) as connecting elements that govern both HTTP and WebSocket requests.

- Architectural Patterns:
- MVC/MVT: Clearly distinguish between the Model (data structures in models.py), View (views.py and Django Templates), and the Template rendering layers.
- Real-time Asynchrony: Emphasize WebSockets for live data streaming.
- API Layer: Even if implemented within Django itself, show a separate module responsible for handling RESTful requests (as per the README documentation).

- Technologies, Frameworks, or Libraries:
- Django for web framework and backend logic.
- Django Channels (implied by the presence of consumers and ASGI configuration) for WebSocket support.
- PostgreSQL/SQLite as the database engines.
- FastAPI is mentioned in the README for API endpoints—indicate this if it’s used in tandem with Django or as a proxy layer.
- Daphne, as indicated by the command in the README, to serve the ASGI application.

##### Final Advice
- Be as detailed as possible while ensuring that each component and its interactions are clearly marked.
- The key is to capture all architectural elements—include modules for HTTP processing, asynchronous communication, UI rendering, and data persistence.
- Review both the file tree and README to verify all essential components are represented and their interdependencies are accurate.
- Do not hesitate to split components into sub-components if it helps delineate responsibilities (e.g., separating authentication if it gets added, separating the API layer).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client
    Client("Client Browser"):::client

    %% Frontend
    Frontend("Frontend UI (Django Templates)"):::frontend

    %% Real-time Communication
    Realtime("Real-Time Communication Manager"):::realtime

    %% API Endpoints
    APIGateway("API Gateway (FastAPI)"):::api

    %% Backend Application Server
    Backend("Backend Application Server"):::backend

    %% Database
    DB("Database (SQLite/PostgreSQL)"):::database

    %% Django Project Setup subgraph
    subgraph "Django Project Setup"
        managePy("manage.py"):::config
        settings("Settings"):::config
        urls("URLs"):::config
        asgi("ASGI"):::config
        wsgi("WSGI"):::config
    end

    %% Logging System Application subgraph
    subgraph "Logging System App"
        models("Models"):::backend
        views("Views"):::backend
        forms("Forms"):::backend
        admin("Admin"):::backend
        tests("Tests"):::backend
        migrations("Migrations"):::backend
        consumers("Consumers"):::backend
        lst("LST Calculations"):::backend
        templates("Templates"):::frontend
    end

    %% Relationships between high-level components
    Client -->|"HTTP"| Frontend
    Client -->|"REST"| APIGateway
    Client -->|"WebSocket"| Realtime

    Frontend -->|"renders"| Backend
    Backend -->|"persists"| DB

    %% Integration of configuration into backend and real-time
    managePy --> Backend
    settings --> Backend
    urls --> Backend
    asgi -- "configures" --> Realtime
    wsgi --> Backend

    %% Internal relationships within Logging System App
    views -->|"uses"| models
    forms --> views
    views -->|"renders"| templates
    consumers -->|"calculates"| lst

    %% Connect API layer to configuration (defining endpoints)
    urls --> APIGateway

    %% Styles
    classDef client fill:#ffeb99,stroke:#333,stroke-width:2px;
    classDef frontend fill:#cce5ff,stroke:#333,stroke-width:2px;
    classDef realtime fill:#d4edda,stroke:#333,stroke-width:2px;
    classDef backend fill:#f8d7da,stroke:#333,stroke-width:2px;
    classDef database fill:#fdfd96,stroke:#333,stroke-width:2px;
    classDef config fill:#e2e3e5,stroke:#333,stroke-width:2px;
    classDef api fill:#f9c0c0,stroke:#333,stroke-width:2px;

    %% Click Events for Django Project Setup
    click managePy "https://github.com/radadiyaaditya/telescope_logging/blob/main/manage.py"
    click settings "https://github.com/radadiyaaditya/telescope_logging/blob/main/telescope_log/settings.py"
    click urls "https://github.com/radadiyaaditya/telescope_logging/blob/main/telescope_log/urls.py"
    click asgi "https://github.com/radadiyaaditya/telescope_logging/blob/main/telescope_log/asgi.py"
    click wsgi "https://github.com/radadiyaaditya/telescope_logging/blob/main/telescope_log/wsgi.py"

    %% Click Events for Logging System Application
    click models "https://github.com/radadiyaaditya/telescope_logging/blob/main/logging_system/models.py"
    click views "https://github.com/radadiyaaditya/telescope_logging/blob/main/logging_system/views.py"
    click forms "https://github.com/radadiyaaditya/telescope_logging/blob/main/logging_system/forms.py"
    click admin "https://github.com/radadiyaaditya/telescope_logging/blob/main/logging_system/admin.py"
    click tests "https://github.com/radadiyaaditya/telescope_logging/blob/main/logging_system/tests.py"
    click migrations "https://github.com/radadiyaaditya/telescope_logging/tree/main/logging_system/migrations/"
    click consumers "https://github.com/radadiyaaditya/telescope_logging/blob/main/logging_system/consumers.py"
    click templates "https://github.com/radadiyaaditya/telescope_logging/tree/main/logging_system/templates/logging_system/"
    click lst "https://github.com/radadiyaaditya/telescope_logging/blob/main/logging_system/lst.py"

    %% Click Event for API Endpoints Integration
    click APIGateway "https://github.com/radadiyaaditya/telescope_logging/blob/main/README.md"
```
