How rpkaur1408/fragments works
Project type and purpose
• This is a standalone backend microservice written in Node.js/Express (no frontend).
• It exposes a REST-style API to create, read, and manage “fragments.”
• It includes pluggable authentication (Basic Auth and AWS Cognito), in-memory data storage, logging, and a health-check endpoint.
File structure
• Top-level tooling/config: .github, .gitignore, Prettier, ESLint, Jest config.
• src/server.js boots the HTTP listener on port 8080.
• src/app.js configures the Express app: loads middleware, routes, error handlers.
• src/auth holds authentication middleware and strategies (basic-auth.js, cognito.js).
• src/routes defines API endpoints under /api (GET, POST) and the root health check.
• src/model contains data access logic: an abstract data layer at src/model/data, with a memory implementation in memory-db.js.
• Cross-cutting modules: src/logger.js for structured logging; src/hash.js for hashing fragments; src/response.js encapsulates HTTP response structure.
• tests/ covers unit tests for each module.
README for additional insights
• The README confirms it’s a Week-1 assignment exposing endpoints via “npm start,” health-check at GET /, and has dev/debug modes.
Elements
• Clear labels: “Client,” “Express Server,” “Auth Middleware,” “Router,” “Fragment Controller,” “Memory-DB.”
• Green for auth strategies
• Orange for data store
• Annotations: note ports (8080), endpoints (/api, /), and config files (.env, jest.config.js).