# shreyansh-geek/enigma architecture

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

- Interactive diagram: https://gitdiagram.com/shreyansh-geek/enigma
- Repository: https://github.com/shreyansh-geek/enigma

## Overview

##### Project type and purpose
- This is a React-based single-page application (SPA) that uses Firebase as its backend (Auth, Firestore, Storage).
- The public directory holds the static HTML/CSS/manifest; src/ contains all React components, context, and service wrappers.
- There’s also a Node script (scripts/seedProblem.js) that uses a Firebase service account to seed data into Firestore.

##### File structure
- Top-level:
- package.json / package-lock.json – front-end dependencies and scripts
- public/ – static hosting assets (index.html, manifest.json, robots.txt)
- src/ – React source code
- scripts/ – back-office Node scripts
- serviceAccountKey.json – credentials for admin scripts
- src/:
- Context/AuthContext.js – React Context for user state & protected routes
- components/ – logical grouping of UI features (Login, SignUp, Blog, Gallery, ProblemHub, AdminProblemCreator, etc.)
- components/Firebase/config.js & Firebase.js – Firebase SDK initialization & wrappers
- There are also test files (App.test.js, setupTests.js) and tooling config (renovate.json).

##### Main components & interactions
a. Front-end (Browser)
- React SPA (src/index.js → App.js → various UI components)
- React Context (AuthContext) manages authentication state and protects routes.
- Static assets served from public/.
b. Firebase services (external)
- Firebase Authentication – sign-in/sign-up flows invoked by Login/Signup components.
- Firestore Database – data store for blog posts, problems, resources, events.
- Firebase Storage (if used by Gallery for images).
c. Admin script (Node)
- scripts/seedProblem.js uses serviceAccountKey.json to connect to Firestore with elevated privileges and seed data.
d. Build & hosting
- npm scripts build the React app → deploy to static host (e.g., Firebase Hosting or Netlify).

##### Architectural patterns & design principles
- Single-page application (SPA) with component-based decomposition
- Context API for cross-cutting concerns (authentication state)
- Service wrappers (components/Firebase) isolate third-party SDK usage
- Separation of concerns: UI layer vs. data layer vs. admin scripts

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Layer 1: Browser and Entry
    Browser["User's Browser"]:::frontend
    IndexJS["src/index.js"]:::frontend
    AppJS["src/App.js"]:::frontend

    Browser -->|"loads"| IndexJS
    IndexJS -->|"renders"| AppJS

    %% Layer 2: UI Components
    subgraph "UI Components"
        direction TB
        NavBar["Navbar Component"]:::frontend
        Home["Home Page"]:::frontend
        Blog["Blog Module"]:::frontend
        ProblemHub["ProblemHub Module"]:::frontend
        Gallery["Gallery Module"]:::frontend
        Login["Login Component"]:::frontend
        SignUp["Signup Component"]:::frontend
        Profile["Profile Module"]:::frontend
        Resources["Resources Module"]:::frontend
        EventsList["Event Listing"]:::frontend
        EventReg["Event Registration"]:::frontend
        ContactEvents["Contact Events"]:::frontend
        Discussion["Discussion Module"]:::frontend
        Opportunities["Opportunities Module"]:::frontend
        Countdown["Countdown Component"]:::frontend
        Particles["Particles Background"]:::frontend
        Footer["Footer Component"]:::frontend
        AdminCreator["AdminProblemCreator"]:::frontend
    end

    AppJS -->|"renders UI components"| NavBar
    AppJS --> Home
    AppJS --> Blog
    AppJS --> ProblemHub
    AppJS --> Gallery
    AppJS --> Login
    AppJS --> SignUp
    AppJS --> Profile
    AppJS --> Resources
    AppJS --> EventsList
    AppJS --> EventReg
    AppJS --> ContactEvents
    AppJS --> Discussion
    AppJS --> Opportunities
    AppJS --> Countdown
    AppJS --> Particles
    AppJS --> Footer
    AppJS --> AdminCreator

    %% Layer 3: State & Service Wrappers
    subgraph "State & Service Layer"
        direction TB
        AuthContext["AuthContext"]:::service
        FirebaseConfig["Firebase Config"]:::service
        FirebaseWrapper["Firebase Wrapper"]:::service
    end

    NavBar -->|"uses auth state"| AuthContext
    Login --> AuthContext
    SignUp --> AuthContext
    Profile --> AuthContext

    Home --> FirebaseWrapper
    Blog --> FirebaseWrapper
    ProblemHub --> FirebaseWrapper
    Resources --> FirebaseWrapper
    Discussion --> FirebaseWrapper
    Opportunities --> FirebaseWrapper
    EventsList --> FirebaseWrapper
    EventReg --> FirebaseWrapper
    ContactEvents --> FirebaseWrapper

    Gallery --> FirebaseWrapper

    AuthContext --> FirebaseConfig
    FirebaseWrapper --> FirebaseConfig

    %% Layer 4: External Services & Databases
    subgraph "External Services"
        direction TB
        AuthService["Firebase Auth"]:::external
        FirestoreDB["Firestore Database"]:::database
        StorageService["Firebase Storage"]:::external
    end

    AuthContext -->|"auth SDK calls"| AuthService
    FirebaseWrapper -->|"read/write SDK calls"| FirestoreDB
    Gallery -->|"storage SDK calls"| StorageService

    %% Admin Script Side
    AdminScript["scripts/seedProblem.js"]:::script
    ServiceAccount["serviceAccountKey.json"]:::script
    AdminScript --> ServiceAccount
    AdminScript -->|"seeds data"| FirestoreDB

    %% Click Events
    click IndexJS "https://github.com/shreyansh-geek/enigma/blob/master/src/index.js"
    click AppJS "https://github.com/shreyansh-geek/enigma/blob/master/src/App.js"
    click NavBar "https://github.com/shreyansh-geek/enigma/blob/master/src/components/NavBar/Navbar.js"
    click Home "https://github.com/shreyansh-geek/enigma/blob/master/src/components/Home.js"
    click Blog "https://github.com/shreyansh-geek/enigma/blob/master/src/components/Blog/Blog.js"
    click ProblemHub "https://github.com/shreyansh-geek/enigma/blob/master/src/components/ProblemHub/ProblemHub.js"
    click Gallery "https://github.com/shreyansh-geek/enigma/blob/master/src/components/Gallery/Gallery.js"
    click Login "https://github.com/shreyansh-geek/enigma/blob/master/src/components/Login/Login.js"
    click SignUp "https://github.com/shreyansh-geek/enigma/blob/master/src/components/SignUp/Signup.js"
    click Profile "https://github.com/shreyansh-geek/enigma/blob/master/src/components/Profile/profile.js"
    click Resources "https://github.com/shreyansh-geek/enigma/blob/master/src/components/Resources/Resource.js"
    click EventsList "https://github.com/shreyansh-geek/enigma/blob/master/src/components/events/Event.js"
    click EventReg "https://github.com/shreyansh-geek/enigma/blob/master/src/components/events/EventRegistration.js"
    click ContactEvents "https://github.com/shreyansh-geek/enigma/blob/master/src/components/contact/Events.js"
    click Discussion "https://github.com/shreyansh-geek/enigma/blob/master/src/components/Discussion/Discussion.js"
    click Opportunities "https://github.com/shreyansh-geek/enigma/blob/master/src/components/Opportunities/Opportunities.js"
    click Countdown "https://github.com/shreyansh-geek/enigma/blob/master/src/components/Countdown/Countdown.js"
    click Particles "https://github.com/shreyansh-geek/enigma/blob/master/src/components/Particles.js"
    click Footer "https://github.com/shreyansh-geek/enigma/blob/master/src/components/Footer.js"
    click AdminCreator "https://github.com/shreyansh-geek/enigma/blob/master/src/components/Admin/AdminProblemCreator.js"
    click FirebaseConfig "https://github.com/shreyansh-geek/enigma/blob/master/src/components/Firebase/config.js"
    click FirebaseWrapper "https://github.com/shreyansh-geek/enigma/blob/master/src/components/Firebase/Firebase.js"
    click AdminScript "https://github.com/shreyansh-geek/enigma/blob/master/scripts/seedProblem.js"
    click ServiceAccount "https://github.com/shreyansh-geek/enigma/blob/master/serviceAccountKey.json"

    %% Styles
    classDef frontend fill:#D0E8FF,stroke:#0366d6,color:#0366d6;
    classDef service fill:#E8DFD0,stroke:#a36d00,color:#a36d00;
    classDef external fill:#D0FFD8,stroke:#1a7f37,color:#1a7f37;
    classDef database fill:#FFE8D0,stroke:#d66300,color:#d66300;
    classDef script fill:#F0F0F0,stroke:#888888,color:#555555;
```
