// Build scalable backend systems with Node.js, Python, databases, APIs, authentication, and cloud deployment. Use when developing server-side applications, APIs, or infrastructure systems.
| name | backend-infrastructure |
| description | Build scalable backend systems with Node.js, Python, databases, APIs, authentication, and cloud deployment. Use when developing server-side applications, APIs, or infrastructure systems. |
Build production-grade backend systems and APIs.
Create a simple REST API with Express.js:
import express from 'express';
import cors from 'cors';
const app = express();
app.use(cors());
app.use(express.json());
// In-memory database for demo
let users = [];
// GET all users
app.get('/api/users', (req, res) => {
res.json(users);
});
// POST new user
app.post('/api/users', (req, res) => {
const user = { id: Date.now(), ...req.body };
users.push(user);
res.status(201).json(user);
});
// GET user by ID
app.get('/api/users/:id', (req, res) => {
const user = users.find(u => u.id === parseInt(req.params.id));
if (!user) return res.status(404).json({ error: 'Not found' });
res.json(user);
});
app.listen(3000, () => console.log('Server running on port 3000'));
// RESTful API endpoints
GET /api/users // List all users
GET /api/users/:id // Get user by ID
POST /api/users // Create user
PUT /api/users/:id // Update user
DELETE /api/users/:id // Delete user
PATCH /api/users/:id // Partial update
// Structured error responses
{
"error": "Bad Request",
"code": 400,
"message": "Email is required",
"timestamp": "2025-11-18T22:30:00Z"
}
# Using SQLAlchemy with FastAPI
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
DATABASE_URL = "postgresql://user:password@localhost/dbname"
engine = create_engine(DATABASE_URL)
SessionLocal = sessionmaker(bind=engine)
def get_db():
db = SessionLocal()
try:
yield db
finally:
db.close()
✅ Use HTTPS for all communications ✅ Validate all user inputs ✅ Use parameterized queries to prevent SQL injection ✅ Implement rate limiting ✅ Hash passwords with bcrypt ✅ Use environment variables for secrets ✅ Implement proper logging and monitoring