How lollytim/full-stack-project-memories works
Project type and purpose
• This is a full-stack “memories” project with a React (or similar) client in the client/ folder, and a Node/Express REST API server in the server/ folder.
• Purpose: allow users to register/login and create, read, update, delete “memory” posts. Authentication is JWT-based.
File structure
• client/
• The front-end code (likely a React SPA).
• server/
• index.js – app bootstrap and mount point for routes and middleware.
• config/ – CORS and allowed origin configuration; reads from .env.
• routes/ – Express routers for /posts and /users.
• controllers/ – Request handlers implementing business logic per route.
• middleware/auth.js – JWT verification gate.
• models/ – Mongoose schemas: user.js and postMessage.js.
• .env – environment settings (e.g. DB URI, JWT secret).
• package.json / lock – dependencies (Express, Mongoose, CORS, etc.).
Architectural patterns & key technologies
• Layered (MVC-style) architecture:
• Routes → Controllers → Models → Database
• Middleware for cross-cutting concerns (auth, CORS).
• Tech stack:
• Front-end: React (client side routing, state management).
• Back-end: Node.js, Express.js, JWT auth.
• Database: MongoDB via Mongoose.
• Configuration: dotenv, CORS policy.
Main components
a. Client (React SPA)
– UI Components
– HTTP/API Service (axios or fetch layer)
b. API Server (Express)
– Router Layer (routes/)
– Controller Layer (controllers/)
– Middleware Layer (auth, CORS)
– Data Layer (Mongoose models)
c. Database
– MongoDB cluster or instance
d. External/Infrastructure
– Environment/config service (.env)
– Optional: Cloud storage or external auth if present
Relationships and data flow
• Client → (HTTP/JSON) → Express Router
• Router → Controller → (calls) → Model (Mongoose) → MongoDB
• Model → Controller → (HTTP/JSON) → Client
• Auth path: Client sends JWT in Authorization header → auth middleware validates → allows controller execution
• Config/CORS: Happens at server startup, applies to all incoming requests
Essential details to capture
• Environment/config (how the server reads DB URI and secrets)
• CORS policy (allowedOrigins.js, corsOption.js)
• auth.js middleware intercepting protected endpoints
• Two main resource flows: /users (registration, login) and /posts (CRUD)