A production-ready Node.js/Express REST API for the WTWR applicationβa weather-aware clothing recommendation system. Built with modular architecture, robust error handling, and MongoDB integration.
GitHub: Noa-GH/se_project_express
- Overview
- Project Links
- Features
- Tech Stack
- Getting Started
- API Reference
- Project Structure
- Architecture
- Error Handling
- Contributing
WTWR is a RESTful backend service that powers a weather-based clothing recommendation platform. Users can:
- Create & manage accounts with secure authentication
- Browse clothing items filtered by weather conditions
- Like/save favorite items for quick access
- Build personalized wardrobes based on climate preferences
Built with scalability and clean architecture in mind, this API enforces strict data validation, implements proper error handling, and follows REST best practices.
Use Case: Perfect for weather-aware fashion apps, seasonal wardrobe planning, and climate-adapted shopping assistants.
- Deployed project domain: https://weathergcpserver.jumpingcrab.com/
- Frontend GitHub repository: https://github.com/Noa-GH/se_project_react
- Project pitch video (GoogleDrive Link): https://drive.google.com/file/d/124Y7BANMPWZmVG8G1RjSU0fJtzMpCGe9/view?usp=sharing
- β User Management β Sign up, sign in, retrieve profile, update profile
- β Clothing Item CRUD β Create, read, and delete clothing items
- β Like System β Mark items as favorites with persistent storage
- β JWT Authentication β Secure endpoint protection with token-based auth
- β Data Validation β Schema enforcement with Mongoose
- β Error Handling β Centralized, standardized error responses
- β CORS Support β Cross-origin request handling
- β MVC Pattern β Clear separation of concerns (Models, Controllers, Routes)
- β Middleware Pipeline β Auth, error handling, and request logging
- β Modular Routes β Organized endpoint management
- β
Environment Config β Flexible configuration via
.env
| Category | Technology |
|---|---|
| Runtime | Node.js |
| Framework | Express.js v5 |
| Database | MongoDB |
| ODM | Mongoose v8 |
| Authentication | JWT + bcryptjs |
| Validation | Celebrate (Joi) + Validator.js + Mongoose schemas |
| Linting | ESLint (Airbnb config) |
| Code Formatting | Prettier |
| Dev Tools | Nodemon |
| CORS | Built-in CORS middleware |
- Node.js v18+ (Download)
- MongoDB v5+ (local or MongoDB Atlas)
- npm or yarn package manager
git clone https://github.com/Noa-GH/se_project_express.git
cd se_project_express
npm installCreate a .env file in the root directory:
PORT=3001
DB_URL=mongodb://127.0.0.1:27017/wtwr_db
NODE_ENV=development
JWT_SECRET=your_jwt_secret_hereEnvironment Variables:
| Variable | Description | Default |
|---|---|---|
PORT |
Server listening port | 3001 |
DB_URL |
MongoDB connection string | mongodb://127.0.0.1:27017/wtwr_db |
NODE_ENV |
Runtime environment | development |
JWT_SECRET |
Secret used to sign JWTs | dev-fallback-secret (development) |
Development mode (with auto-reload):
npm run devProduction mode:
npm startLint code:
npm run lintThe server will start and connect to MongoDB. You should see the app logs in the console, for example:
Connect to MongoDB
Server running on port 3001
POST /signup
Content-Type: application/json
{
"name": "John Doe",
"email": "john@example.com",
"password": "securePassword123"
}Response (201):
{
"_id": "507f1f77bcf86cd799439011",
"name": "John Doe",
"email": "john@example.com"
}POST /signin
Content-Type: application/json
{
"email": "john@example.com",
"password": "securePassword123"
}Response (200):
{
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
}GET /users/me
Authorization: Bearer {token}Response (200):
{
"_id": "507f1f77bcf86cd799439011",
"name": "John Doe",
"email": "john@example.com",
"createdAt": "2024-01-15T10:30:00Z"
}PATCH /users/me
Authorization: Bearer {token}
Content-Type: application/json
{
"name": "Jane Doe",
"email": "jane@example.com"
}Response (200): Updated user object
GET /itemsResponse (200):
[
{
"_id": "507f1f77bcf86cd799439012",
"name": "Winter Jacket",
"imageUrl": "https://...",
"weather": "cold",
"season": "winter",
"owner": "507f1f77bcf86cd799439011",
"likes": ["507f1f77bcf86cd799439010"]
}
]POST /items
Authorization: Bearer {token}
Content-Type: application/json
{
"name": "Summer T-Shirt",
"imageUrl": "https://example.com/tshirt.jpg",
"weather": "warm",
"season": "summer"
}Response (201): Created item object
DELETE /items/:itemId
Authorization: Bearer {token}Response (200):
{ "message": "Item deleted successfully" }PUT /items/:itemId/likes
Authorization: Bearer {token}Response (200):
{
"_id": "507f1f77bcf86cd799439012",
"name": "Winter Jacket",
"likes": ["507f1f77bcf86cd799439011"]
}DELETE /items/:itemId/likes
Authorization: Bearer {token}Response (200): Updated item object with removed like
se_project_express/
βββ π app.js # Express app entry point
βββ π package.json # Project metadata & dependencies
βββ π .env # Environment variables (create this)
βββ π README.md # This file
βββ π sprint.txt # Project sprint notes
β
βββ π controllers/ # Business logic
β βββ clothingItems.js # Item CRUD handlers
β βββ users.js # Auth & user handlers
β
βββ π models/ # Database schemas
β βββ clothingItem.model.js # Clothing item schema
β βββ user.model.js # User schema with validation
β
βββ π routes/ # API route definitions
β βββ index.js # Main router
β βββ users.js # User routes
β βββ clothingItems.js # Item routes
β
βββ π middlewares/ # Custom middleware
β βββ auth.js # JWT authentication
β
βββ π utils/ # Utility functions
β βββ config.js # Configuration helpers
β βββ errors.js # Error codes & messages
β
βββ π demos/ # Demo screenshots & guides
βββ API_DEMO.md # API usage examples
βββ SCREENSHOTS.md # Feature screenshots guide
HTTP Request
β
[Express Middleware] (CORS, JSON parsing)
β
[Routes] (Route matching)
β
[Auth Middleware] (JWT verification, if protected)
β
[Controllers] (Business logic)
β
[Models] (Database operations)
β
[MongoDB] (Persistent storage)
β
HTTP Response
- Models (
/models) β Define data schemas and validation rules - Controllers (
/controllers) β Handle request processing and business logic - Routes (
/routes) β Define API endpoints and map to controllers - Middleware (
/middlewares) β Auth, error handling, request preprocessing
The API returns standardized error responses:
{
"message": "Error description",
"statusCode": 400
}| Code | Meaning | Example |
|---|---|---|
| 200 | β Success | Successful item fetch |
| 201 | β Created | User/item successfully created |
| 400 | β Bad Request | Invalid input data |
| 401 | π Unauthorized | Missing/invalid token |
| 404 | β Not Found | Item/user doesn't exist |
| 409 | Duplicate email on signup | |
| 500 | π₯ Server Error | Unexpected error |
- Sign Up β User creates account β Server generates JWT
- Sign In β User logs in β Server returns JWT token
- Protected Routes β Client includes
Authorization: Bearer {token} - Auth Middleware β Verifies token β Extracts user ID
- Controller Logic β Uses user ID from token
Example Header:
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...
DEBUG=* npm run devmongosh "mongodb://127.0.0.1:27017/wtwr_db"# Get all items
curl http://localhost:3001/items
# Sign up
curl -X POST http://localhost:3001/signup \
-H "Content-Type: application/json" \
-d '{"name":"John","email":"john@test.com","password":"pass123"}'See SCREENSHOTS.md for:
- API Request/Response Examples with screenshots
- Authentication Flow diagram
- Feature Demonstrations
- Sign Up β POST
/signupwith name, email, password - Get Token β POST
/signinto receive JWT - Create Items β POST
/itemswith authentication - Browse Items β GET
/items(public endpoint) - Like Items β PUT
/items/:itemId/likeswith authentication
Contributions are welcome! Please follow these steps:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
Run ESLint before committing:
npm run lintThis project is licensed under the ISC License β see LICENSE file for details.
Noah Ford β GitHub Profile
- Issues: Report a bug
- Discussions: Ask a question
Last updated: May 2026 | Made with β€οΈ for the WTWR project . βββ controllers # Request handlers βββ models # Mongoose schemas βββ routes # API route definitions βββ middlewares # Error handling & validation βββ utils # Helper functions
---
## β οΈ Error Handling
The API uses centralized error handling middleware to ensure consistent responses.
Typical response format:
```json
{
"message": "Error description"
}
- Rate limiting & security middleware
- Logging (Winston / Morgan)
- Docker containerization
This backend demonstrates real-world API design patterns, including:
- Separation of concerns
- Scalable folder structure
- Data validation and integrity
- RESTful resource modeling
MIT