# shivacharan369/astronexus architecture

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

- Interactive diagram: https://gitdiagram.com/shivacharan369/astronexus
- Repository: https://github.com/shivacharan369/astronexus

## Overview

##### Main Components
- Frontend (Client):
- Built with React.js. Includes directories like “src” (holding components, pages, routes), “public” (static assets such as index.html, images, and even a video), and “services” (with, for example, the authService.js for interacting with backend endpoints).
- Uses React Router for navigation and Tailwind CSS for styling.
- Backend (Server):
- Developed with Node.js and Express.js. Contains directories for controllers (handling business logic for articles and feedback), middlewares (like user authentication middleware), models (defining schemas for User, Article, and Feedback), and routes (mapping HTTP calls to controllers).
- The server configuration (server.js), along with environment variables (.env), handles API endpoints for authentication, article management, and feedback.
- Database:
- Although the file tree doesn’t list a database configuration file, the README clearly states the use of MongoDB for storing user data and saved articles. This component should be represented as an external database.
- External API Integration:
- Integration with the NASA API. Represent this as an external system that the backend communicates with to fetch real-time space news, images, and data.
- Authentication & Security:
- JWT authentication is implemented on the backend with the use of password-hashing (bcrypt.js) to secure the user login process. This adds a secure layer between the client and server.

##### Relationships and Interactions
- The Client (React App) sends HTTP requests (via Axios or similar) to the Backend API.
- The Backend processes data through controllers, authenticates using JWT and middleware, and interacts with the Database (MongoDB) to store or retrieve user data and saved articles.
- For real-time content, the Backend periodically or on-demand communicates with the NASA API and then returns the dynamic content to the client.
- Both the client and server have distinct functions but are tightly coupled through RESTful API calls and shared authentication standards.

##### Architectural Patterns and Design Principles
- Split Architecture (Separation of Concerns): Clear division between frontend and backend responsibilities.
- MVC-like Pattern on the Server: Controllers, Models, and Routes reflect an MVC pattern.
- Stateless Authentication: JWT is used to maintain a secure and token-based authentication mechanism.
- Responsive Design and Theming: The client has implemented both dark and light themes with state management and localStorage persistence.
- API Integration: The design emphasizes a microservice-like interaction with external systems such as NASA’s API.

##### Relevant Technologies and Frameworks
- Frontend: React.js, React Router, Tailwind CSS, Axios.
- Backend: Node.js, Express.js, JWT, bcrypt.js.
- Database: MongoDB (implied in README).
- External Services: NASA API for space news and updates.

- Use clear labels: Label nodes as “Client (React App)”, “Server (Express API)”, “MongoDB Database”, and “NASA API”.

##### Additional Detail
- In the client’s section, include major subcomponents such as “Pages”, “Components” (Header, Footer, Sidebar), “Services” (like authService), and “Routes”.
- On the backend, highlight components such as “Controllers”, “Middleware”, “Models”, and “Routes”.

Happy diagramming!

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Section
    subgraph "Client (React App)"
        A1("Public Assets"):::frontend
        A2("Source Code"):::frontend
        A3("Auth Service"):::frontend
        A4("Components"):::frontend
        A5("Pages"):::frontend
        A6("Routes"):::frontend
    end

    %% Backend Section
    subgraph "Server (Express API)"
        B1("Server Config"):::backend
        B2("Controllers"):::backend
        B3("Middlewares"):::backend
        B4("Models"):::backend
        B5("Routes"):::backend
    end

    %% External Systems
    C1("MongoDB Database"):::external
    C2("NASA API"):::external

    %% Relationships
    A6 -->|"sends_API_requests"| B1
    B1 -->|"invokes"| B2
    B1 -->|"invokes"| B3
    B1 -->|"invokes"| B4
    B1 -->|"invokes"| B5
    A3 -->|"handles_auth"| A6
    B5 -->|"JWT_validation"| B3
    B1 -->|"data_ops"| C1
    B1 -->|"external_API_calls"| C2

    %% Click Events for Frontend Components
    click A1 "https://github.com/shivacharan369/astronexus/tree/main/client/public"
    click A2 "https://github.com/shivacharan369/astronexus/tree/main/client/src"
    click A3 "https://github.com/shivacharan369/astronexus/blob/main/client/services/authService.js"
    click A4 "https://github.com/shivacharan369/astronexus/tree/main/client/src/components"
    click A5 "https://github.com/shivacharan369/astronexus/tree/main/client/src/pages"
    click A6 "https://github.com/shivacharan369/astronexus/blob/main/client/src/routes.js"

    %% Click Events for Backend Components
    click B1 "https://github.com/shivacharan369/astronexus/blob/main/server/server.js"
    click B2 "https://github.com/shivacharan369/astronexus/tree/main/server/controllers"
    click B3 "https://github.com/shivacharan369/astronexus/tree/main/server/middlewares"
    click B4 "https://github.com/shivacharan369/astronexus/tree/main/server/models"
    click B5 "https://github.com/shivacharan369/astronexus/tree/main/server/routes"

    %% Styles
    classDef frontend fill:#F9E79F,stroke:#B7950B,stroke-width:2px;
    classDef backend fill:#AED6F1,stroke:#2471A3,stroke-width:2px;
    classDef external fill:#F5B7B1,stroke:#C0392B,stroke-width:2px;
```
