How 42aditya31/d-mic works
Project Type and Purpose
• This is a full‐stack microblogging platform (“D_MIC”) built as a React single‐page application (SPA) on the frontend and a Strapi headless CMS on the backend.
• Purpose: engineers create, read, update, delete (CRUD) posts, comments, likes and manage profiles via JWT‐secured REST APIs.
Main Components
a. Frontend (React SPA)
• UI Components: PostCard, CommentSection, LikeButton, ProfileHeader, etc.
• Routing: PublicRoute, PrivateRoute for auth gating.
• State Management: Redux slices (postSlice, userSlice, saveSlice) or Context for auth and global state.
• HTTP Client: Axios/Fetch connecting to Strapi REST endpoints.
• Assets & Utilities: custom hooks (useFetchPosts, useTimeAgo), authUtils.
b. Backend (Strapi Headless CMS)
• API Layer: auto‐generated REST endpoints under /posts, /comments, /likes, /users.
• Content Types & Models: defined in /src/api/{post,comment,like,global}/content-types/.../schema.json.
• Controllers, Services & Routes: per‐entity logic in /src/api/*/controllers, /services, /routes.
• Admin Panel: Strapi client under /.strapi/client/ and custom admin config in /src/admin.
• Configuration: config/server.js, config/database.js, config/middlewares.js, etc.
• Scripts & Seeds: scripts/seed.js for data population.
c. Database
• Development: SQLite (default), Production: PostgreSQL.
• Migration folders under database/migrations.
• Upload Storage: local files under /public/uploads.
d. External & Infrastructure
• JWT Auth: /auth/local endpoints, tokens in HTTP‐only cookies or localStorage.
• Hosting: Frontend on Vercel/Netlify; Backend on Heroku/Render/DigitalOcean.
• Environment Variables: .env, REACT_APP_API_URL, DB credentials, email config.
Component Interactions and Data Flow
1. User → React SPA (login/register UI)
2. React → Strapi Auth endpoint → returns JWT
3. React stores token → includes in Authorization header for protected calls
4. React → Strapi CRUD endpoints for Posts/Comments/Likes → Strapi Controller → Service → Database
5. Strapi → returns JSON response → React updates Redux store/UI
6. Strapi Admin UI used by moderators via browser
Architectural Patterns & Design Principles
• Layered Architecture: Presentation (React) → API Gateway (Strapi) → Business Logic (Controllers/Services) → Data Layer (DB).
• MVC‐like within Strapi (Models = Content Types, Views = JSON endpoints, Controllers/Services = business logic).
• Componentization on frontend: reusability, separation of concerns.
• RESTful API design, JWT‐based stateless auth.