How shreyansh-geek/enigma works
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