How tanamettpk/wongnaiwechallenge works
Main Components Identification
• Client (Frontend):
• Located under the “client” directory.
• Built using React, with TypeScript files in the src directory.
• Includes environment configuration files, Dockerfile, and README for client-specific instructions.
• Server (Backend):
• Found within the “server” directory.
• Implements an Express.js web server.
• Contains directories for configs, controllers, models, and routes which indicate use of the MVC pattern.
• Database (MongoDB):
• Although not present as a dedicated directory, MongoDB is used as indicated in both the README and the server and load_data configurations.
• The server’s mongoose and database configuration files point to a MongoDB database.
• Load Data Utility:
• Located in “load_data.”
• Contains datasets, models, and a main.js file suggesting functionality to seed or process data before it's used by the server.
• Additional Artifacts:
• Docker and docker-compose files are provided at the root level and within child directories (client, server, load_data) to support containerized deployment.
Key Relationships and Data Flow
• The Client (React App) communicates with the Server via API calls (HTTP requests).
• The Server processes these requests by interacting with the Database. This is handled via Express routing, controllers, and mongoose connections to MongoDB.
• There is also a Load Data component that likely interacts with the database directly to populate or manage data (e.g., using scripts in load_data/main.js).
• Docker configurations should encapsulate each component into appropriate containers, with a docker-compose file orchestrating the overall services (client, server, and any additional services such as load_data jobs or even a MongoDB container if needed).
Architectural Patterns and Design Principles
• MV(C) - The server structure follows the Model-Controller-Route (or MVC) pattern, seen from the “controllers”, “models”, and “routes” directories.
• Separation of concerns – The project clearly divides responsibilities among client, server, and data loading tools.
• Containerization – Use of Docker to encapsulate and deploy different parts of the system.
• Environment-based configuration – The use of .env files and separate configuration directories for managing different environments and deployment settings.
• API Routes
• Controllers
• Models (including mongoose connections)
• Configuration components (e.g., environment configurations and middleware)
• Optionally, show a “Docker/Container Ecosystem” component that wraps the client, server, and possibly the database, which can be visually represented as runtime containers managed by docker-compose.