How andresz74/react-photogram works
Main System Components
a. Frontend (Browser/Client)
• React App (src/index.tsx → AppInitializer)
• UI Components (components/Layout, Gallery, Login, Common, etc.)
• State Management (Redux store in src/state; actionCreators, reducers, middleware)
• API Client Layer (src/api/*.ts[x])
b. Backend Service (External Node.js image-API)
• Node.js service managed by PM2
• Exposes endpoints: POST /image-api/upload, POST /image-api/delete-image
• Hosted behind Nginx proxy on port 3003
c. Cloud Services (Firebase)
• Authentication (Firebase Auth)
• Firestore Database (metadata storage)
• Firebase Storage (image file storage)
Relationships & Data Flows
a. Authentication flow:
Browser → Firebase Auth ← AuthProvider & AuthContext
b. Data retrieval & state updates:
React components → Redux actions → Redux reducers → Redux store → UI
c. API interactions:
API client (src/api) → Node.js backend →
• Store files in Firebase Storage
• Persist metadata in Firestore
d. Direct Firestore reads (e.g., listing images) can be done either via backend or directly through Firebase SDK in src/api.
Architectural Patterns
• Single-Page Application (SPA) with React Router
• Container/Presenter split:
– “Container” components dispatch Redux actions
– “Presenter” components render UI based on props/state
• Centralized State Management with Redux
• Feature-based folder structure (components/Gallery, components/Layout, state/, api/)
• API abstraction layer (src/api) decouples UI from backend implementation
• Environment configuration (config.ts, .env) isolates secrets