This is the high-performance, resilient REST API powering the Technical Knowledge Base. Built with Node.js and Express, it demonstrates advanced system design patterns focused on High Availability and Error Resilience.
- Runtime:
Node.js(v22+) - Framework:
Express.js - Database:
MongoDB Atlas - Object Modeling:
Mongoose - Testing:
Jest&Supertest - Environment:
Dotenv
As highlighted in my Medium article, this API implements a Guard Clause mechanism using mongoose.connection.readyState.
- The Problem: Cloud databases (MongoDB Atlas) can experience latency or connection drops.
- The Solution: Instead of failing with a timeout, the API instantly detects connection issues and serves a pre-configured Fallback Dataset from a local module.
- Result: 100% UI uptime for the end user.
Quality is verified through automated tests:
- Connection Simulation: Using
Object.definePropertyand custom headers to simulate database failures. - Payload Verification: Ensuring fallback data matches the expected schema during outages.
- Mocking: Implementing Jest spies to isolate business logic from database state.
# 1. Clone & Install
git clone [https://github.com/aysead/portfolio-backend.git](https://github.com/aysead/portfolio-backend.git)
cd portfolio-backend
npm install
# 2. Setup Environment Variables
# Create a .env file and add your MONGO_URI
# 3. Run Automated Tests
npm test
# 4. Start Server
npm startThe API is architected for Serverless Environments and is currently deployed on Vercel.
- CI/CD: Integrated with GitHub for automated deployment and continuous integration.
- Security: Implements
CORSpolicies and strict environment variable protection viadotenv.
"Junior developers focus on the Happy Path; Senior developers design for the Unhappy Path."
Ayşe A. Dagci - Full Stack Developer