Skip to main content
Knowledge Hub · Give Back Initiative

HUB_STATUS: OPERATIONAL // 20_YRS_OF_KNOWLEDGE · FREE_ACCESS

Two Decades of Engineering Knowledge,Given Back. For Free.

Thousands of interview questions, real-world errors with root-cause solutions, reusable code archives, and structured learning paths — built through 20 years of actual engineering.

One lamp can light a hundred more without losing its own flame. This knowledge hub is not a product. It is not a funnel. It is a contribution — to every developer who once searched alone at 2 AM for an answer that did not exist anywhere on the internet. It exists now. Here.

"A lamp loses nothing by lighting another lamp. This is why this knowledge exists — not to be held, but to be shared."
— Debasis Bhattacharjee
3,500+
Interview Questions

Across 18 languages & frameworks

1,200+
Debug Solutions

Real errors. Root-cause fixes.

800+
Code Snippets

Copy-paste ready. Production tested.

24
Learning Paths

Beginner → Advanced, structured

Section IV · Knowledge Domains

DOMAINS_MAPPED // PHP · JS · PYTHON · AI · SECURITY · ARCHITECTURE

Explore the Ecosystem

View All Domains →
01 · DOMAIN
Interview Questions

Categorized by language, role, and difficulty. From junior to architect-level. With curated model answers built from real hiring experience.

3,500+ questions Explore →
02 · DOMAIN
Error & Debug Archive

Searchable archive of real runtime errors, stack traces, and exceptions — each with root cause analysis and tested fix. Like Stack Overflow, but curated.

1,200+ solutions Explore →
03 · DOMAIN
Code Snippet Library

Reusable, production-tested code patterns across PHP, Python, JavaScript, VB.NET, SQL and more. No fluff — just working implementations.

800+ snippets Explore →
04 · DOMAIN
System Design Notes

Architecture patterns, design principles, scalability thinking, and real-world system breakdowns explained from an engineer who has built them.

150+ case studies Explore →
05 · DOMAIN
Learning Paths

Structured progression from beginner to professional — curriculum-style roadmaps with sequenced topics, milestones, and recommended resources.

24 paths Explore →
06 · DOMAIN
Security & Ethical Hacking

Penetration testing concepts, vulnerability patterns, OWASP deep dives, and defensive coding practices drawn from real security consulting work.

200+ topics Explore →
Section V · Interview Preparation

INTERVIEW_PREP: ACTIVE // JUNIOR · MID · SENIOR · ARCHITECT

Questions & Answers

All 1,774 Questions →
Q·001 Can you explain the difference between ‘interface’ and ‘type’ in TypeScript and when you would use one over the other?
TypeScript Language Fundamentals Mid-Level

In TypeScript, 'interface' is used to define the shape of an object, while 'type' can create more complex types, including unions and intersections. I would typically use 'interface' for defining the structure of an object, especially when I expect to extend it later, and 'type' for creating aliases or combining types.

Deep Dive: The primary difference between 'interface' and 'type' in TypeScript lies in their use cases and capabilities. 'Interface' is specifically designed for defining the structure of an object and is extendable, meaning you can create new interfaces that inherit from existing ones. This can be particularly useful when building a library or framework where you anticipate future extensions or modifications. On the other hand, 'type' can represent not only object shapes but also primitive types, unions, intersections, and tuples. This flexibility makes 'type' more powerful for complex type definitions or when defining types that aren't just shapes of objects. However, it does not support declaration merging like 'interface' does, which could be a deciding factor based on project needs.

Real-World: In a project where we were building a user management system, I used 'interface' to define the shape of our User object, which included properties like name and email. This allowed me to easily extend the User interface later for features like roles or permissions without breaking existing code. When dealing with a function that could handle either a User or an Admin object, I used 'type' to create a union that made the function signatures clear and concise, efficiently handling both types in one function.

⚠ Common Mistakes: One common mistake developers make is confusing 'interface' and 'type' when defining object shapes, often opting for 'type' even when they should use 'interface' due to the latter's extensibility and declaration merging capabilities. Another mistake is assuming 'type' can serve every purpose of 'interface', which leads to rigid code structure that is difficult to extend or maintain. It's also important to note that using 'type' for defining structures that should logically extend can hinder future development. Developers may also overlook the benefits of interface merging, which can simplify the addition of new properties over time.

🏭 Production Scenario: In a previous role in a software company, we had a growing codebase where multiple developers were adding features to our application. Misunderstanding the differences between 'type' and 'interface' led to inconsistencies in how we defined shared objects. This caused issues when extending these definitions, as some objects were defined as types and couldn't be merged or extended easily. The result was a significant refactor effort just to streamline the object definitions, which could have been avoided with a clearer understanding of their differences from the start.

Follow-up questions: Can you give an example of a situation where you would prefer to use 'interface'? What are the implications of using 'type' for ensuring type safety? How do you feel about using declaration merging in larger projects? What are the performance considerations when using complex types in TypeScript?

// ID: TS-MID-003  ·  DIFFICULTY: 5/10  ·  ★★★★★☆☆☆☆☆

Q·002 Can you explain how TypeScript’s type inference works and provide an example of when it might lead to unexpected results?
TypeScript Language Fundamentals Mid-Level

TypeScript uses type inference to automatically determine the types of variables and expressions based on their values. This can lead to unexpected results when TypeScript infers a broader type than intended, like inferring 'any' from a function that returns undefined if not explicitly defined.

Deep Dive: Type inference in TypeScript is a powerful feature that allows the compiler to deduce types automatically when they are not explicitly provided. For instance, if a variable is initialized with a string, TypeScript infers its type as string, allowing you to use it without type annotations. However, there are situations where inference can lead to unintended consequences, such as when a function returns undefined and TypeScript infers the return type as any instead of a more specific type. This can happen in complex return structures or when using generics without clear types, potentially leading to runtime errors or bugs due to incorrect assumptions about variable types.

It's essential to be aware of this behavior, especially when working in larger codebases or with third-party libraries where implicit typing might occur. Developers often overlook adding explicit types or fail to handle cases where undefined can be returned, which could lead to difficult-to-track issues during execution.

Real-World: In a recent project, we had a utility function that processed a list of user objects and returned the first user found based on a search query. The function was meant to return a User type or null if no user matched the query. However, because the function lacked an explicit return type, TypeScript inferred the return type as any. This caused issues downstream where consuming functions expected a User type, leading to type errors when they assumed a valid user would always be returned.

⚠ Common Mistakes: A common mistake is neglecting to specify return types for functions, assuming TypeScript will always infer the correct type. This can lead to situations where the inferred type is broader than expected, especially when returning undefined or null, which can inadvertently lead to runtime errors. Another mistake is using 'any' to bypass type checking altogether; while it seems convenient, it negates TypeScript's benefits, making the code more prone to bugs and less maintainable in the long run.

🏭 Production Scenario: In my experience, during a recent sprint, our team was implementing a feature that utilized multiple data processing functions. Some of these functions returned inferred types, which resulted in one function not returning the expected value type. This mismatch caused issues in the consuming components, leading to delays as we had to debug and add explicit types to ensure type safety. Understanding type inference would have helped us avoid this problem from the beginning.

Follow-up questions: Can you describe a scenario where explicit typing avoids issues with inference? How do you handle third-party libraries with poorly defined types? What strategies do you use to ensure type safety in a large codebase? Can you explain the difference between type assertions and type inference?

// ID: TS-MID-004  ·  DIFFICULTY: 5/10  ·  ★★★★★☆☆☆☆☆

Q·003 How do you handle type safety when integrating TypeScript with machine learning libraries that may not have types defined?
TypeScript AI & Machine Learning Mid-Level

You can handle type safety by creating custom type definitions or using type assertion when integrating with libraries lacking TypeScript support. This ensures that your code remains type-safe while allowing you to use the library's functionality.

Deep Dive: When working with machine learning libraries in TypeScript that do not have official type definitions, you can create your own type declarations to define the expected shapes of data and functions. This allows you to maintain the benefits of TypeScript's type safety. Alternatively, you can use type assertion to specify a variable's type if you're confident about its structure, but this approach comes with risks as it bypasses some of the type-checking mechanisms. It's crucial to regularly evaluate the accuracy of these types, especially when dealing with complex data structures, as mismatches can lead to runtime errors. Furthermore, consider contributing to DefinitelyTyped or creating a small type package for library types that can benefit the community.

Real-World: In a recent project, I integrated a TypeScript application with TensorFlow.js for real-time predictions. Since TensorFlow.js lacked comprehensive type definitions, I created a custom definition file for the most frequently used functions and data structures, like tensors and models. This made it easier for my team to use TensorFlow.js while benefiting from TypeScript's type checking, significantly reducing runtime errors and improving code maintainability over time.

⚠ Common Mistakes: One common mistake developers make is relying heavily on type assertions without fully understanding the underlying data structures. This can lead to incorrect assumptions and runtime errors that type safety was meant to prevent. Another mistake is neglecting to update custom type definitions when the underlying library updates, which can result in mismatched types and bugs that are difficult to trace.

🏭 Production Scenario: In a production environment, you might encounter a situation where a new machine learning library is introduced for predictive modeling but lacks TypeScript support. Ensuring type safety during integration becomes critical, as it affects the overall stability of your application. Having custom type definitions ready can facilitate a smoother integration process and mitigate potential errors early in your development cycle.

Follow-up questions: Can you explain the process you use to create type definitions for external libraries? What strategies do you use to keep custom types in sync with library updates? How do you handle debugging type-related issues that arise from third-party integrations? Can you provide an example of a type assertion you've made in a project?

// ID: TS-MID-001  ·  DIFFICULTY: 6/10  ·  ★★★★★★☆☆☆☆

Q·004 How does TypeScript help mitigate security issues related to type safety, and can you give an example of how improper type usage can lead to vulnerabilities?
TypeScript Security Mid-Level

TypeScript enhances security by enforcing strict type checking, which helps catch invalid operations at compile time. Improper type usage, like using 'any' or failing to define types, can lead to runtime errors and potential security vulnerabilities such as injection attacks.

Deep Dive: TypeScript's type system acts as a strong guard against many common security vulnerabilities by ensuring data types are strictly enforced. This means that if a function expects a number, passing a string will result in a compile-time error, thus preventing unintended behavior that could be exploited. For instance, using types like 'any' can defeat the purpose of type safety and may lead to runtime errors that attackers could exploit. Furthermore, not defining interfaces or using union types properly can lead to unexpected inputs, which can be a vector for various attacks, including injection and type-related vulnerabilities. By leveraging TypeScript's robust typing system, developers can build more secure applications from the ground up.

Real-World: In a recent project, our team was handling user input for a web application. We initially used the 'any' type for some parameters that were expected to be strings. This oversight allowed an attacker to supply a malicious input that bypassed validation checks, ultimately leading to a cross-site scripting (XSS) vulnerability. By refactoring the code to use specific string types and implementing stricter validation methods, we mitigated this risk and improved overall security.

⚠ Common Mistakes: A common mistake developers make is overusing the 'any' type, which can lead to losing the benefits of TypeScript's strong typing. This makes the codebase vulnerable to unexpected data types, potentially allowing security issues to creep in. Another mistake is not properly defining interfaces for incoming data, which can lead to assumptions that might not hold true, creating a gap that attackers could exploit. Not considering nullable types can also introduce risks, as failing to handle 'null' or 'undefined' properly can lead to runtime errors or logical flaws that compromise security.

🏭 Production Scenario: In a production environment where user input is constantly being processed, the lack of strict type enforcement can lead to significant security vulnerabilities. For example, if an application does not validate user input and is built with loose type definitions, malicious users could exploit those weaknesses to execute unintended commands or access sensitive data. This scenario underscores the importance of leveraging TypeScript's type system to ensure all inputs are properly validated and typed.

Follow-up questions: Can you explain how TypeScript interfaces can enhance security? What strategies do you use to validate user input in TypeScript? How do you approach type definitions for third-party libraries? Have you ever encountered a specific vulnerability due to poor type handling?

// ID: TS-MID-002  ·  DIFFICULTY: 6/10  ·  ★★★★★★☆☆☆☆

Section VI · Error & Debug Archive

DEBUG_ARCHIVE: LIVE // REAL_ERRORS · ANNOTATED_FIXES

Real Errors. Root-Cause Fixes.

All 1,200 Solutions →
PHP ERROR E_FATAL · #DB-001
Undefined variable: $conn — PDO connection not persisted across scope
Fatal error: Uncaught Error: Call to a member function query() on null

Connection object passed by value. Fix: pass by reference or use dependency injection through constructor.

4,200 views Read Fix →
JAVASCRIPT RUNTIME · #JS-044
Cannot read properties of undefined — React state not yet populated on first render
TypeError: Cannot read properties of undefined (reading 'map')

State initialized as undefined, not empty array. Fix: initialize with useState([]) and guard with optional chaining.

7,800 views Read Fix →
SQL ERROR CONSTRAINT · #SQL-019
Foreign key constraint fails on INSERT — parent row not found in referenced table
ERROR 1452: Cannot add or update a child row: a foreign key constraint fails

Insertion order violation. Fix: insert parent record first, or disable FK checks during bulk migration with SET FOREIGN_KEY_CHECKS=0.

3,100 views Read Fix →
PYTHON IMPORT · #PY-007
ModuleNotFoundError in virtual environment — pip installed globally but not inside venv
ModuleNotFoundError: No module named 'requests'

Package installed to system Python, not active venv. Fix: activate venv first, then pip install. Verify with which python.

5,400 views Read Fix →
VB.NET RUNTIME · #VB-031
NullReferenceException on DataGridView load — DataSource bound before data fetched
System.NullReferenceException: Object reference not set to an instance

Binding fires before async fetch completes. Fix: await the data load, then set DataSource. Use BindingSource for dynamic updates.

2,700 views Read Fix →
WORDPRESS PLUGIN · #WP-012
White Screen of Death after plugin activation — memory limit exhausted on init hook
Fatal error: Allowed memory size of 67108864 bytes exhausted

Plugin loading heavy library on every request. Fix: lazy-load on relevant admin pages only. Increase WP_MEMORY_LIMIT in wp-config as temporary measure.

6,200 views Read Fix →
Section VII · Code Archive

Copy. Adapt. Ship.

All 800 Snippets →
PHP · PATTERN
Singleton Database Connection

Thread-safe PDO connection with single instance guarantee. Works with MySQL, PostgreSQL, SQLite.

private static ?self $instance = null;
12 uses this week View →
PYTHON · UTILITY
Rate-Limited API Client

Async HTTP client with automatic retry, exponential backoff, and per-domain rate limiting.

async def fetch_with_retry(url, max=3):
28 uses this week View →
SQL · QUERY
Recursive CTE Hierarchy

Self-referencing table traversal for category trees, org charts, and menu structures using Common Table Expressions.

WITH RECURSIVE tree AS (SELECT ...)
19 uses this week View →
JAVASCRIPT · HOOK
Custom useDebounce Hook

React hook for debouncing search inputs, form fields, and resize events. Prevents excessive API calls.

const useDebounce = (value, delay) => {
41 uses this week View →
Section VIII · Structured Learning

LEARNING_PATHS: READY // 4_TRACKS · STRUCTURED · MENTOR_GUIDED

Learning Paths

All 24 Paths →

PHP Developer: Zero to Production

Beginner

From syntax fundamentals to building RESTful APIs and WordPress plugins. Designed for complete beginners with no prior programming background.

PHP Syntax & Data Types
OOP: Classes, Interfaces, Traits
Database: PDO & MySQL
REST API Design
WordPress Plugin Development
18 modules · ~40 hrs Start Path →

Full-Stack JavaScript: React + Node

Mid-Level

Modern full-stack development with React, Node.js, Express, and PostgreSQL. Includes deployment, auth, and real project builds.

Modern ES2024 JavaScript
React: State, Hooks, Context
Node.js & Express APIs
Auth: JWT & OAuth 2.0
CI/CD & Deployment
22 modules · ~60 hrs Start Path →

Software Architecture Mastery

Advanced

Design patterns, SOLID principles, microservices, event-driven architecture, and real-world system design interview preparation.

Design Patterns: GoF 23
Domain-Driven Design
Microservices & Event Bus
Scalability Patterns
System Design Interviews
16 modules · ~35 hrs Start Path →

AI Integration for Developers

Mid-Level

Practical AI integration using Claude API, OpenAI, and MCP. Build real AI-powered applications, tools, and automation workflows.

LLM Fundamentals & Prompting
Claude API & OpenAI SDK
Model Context Protocol (MCP)
RAG Systems & Embeddings
Deploying AI-Powered Apps
14 modules · ~28 hrs Start Path →

"The best engineering knowledge is not found in textbooks — it is extracted from late nights, broken builds, angry clients, and the stubborn refusal to stop until the problem is solved."

— Debasis Bhattacharjee · Software Architect · 20 Years in Production

Section X · The Ecosystem Grows

ARCHIVE_GROWING // CONTRIBUTIONS_OPEN · LIVING_DOCUMENT

This Is a Living Archive. Not a Static Library.

Every week, new errors are documented, new interview patterns are added, and new solutions are tested in production. The knowledge hub grows because real problems keep appearing — and every answer earns its place here by actually working.

If you found a fix that saved your project, or spotted an answer that could be better — the door is always open. This ecosystem belongs to everyone who uses it.

Submit via Email
Send your question, error, or solution directly
Submit →
Leave a Testimonial
Did something here help you? Share your experience
Share →
Comment on Facebook
Find us at @iamdebasisbhattacharjee
Visit →
Get Update Alerts
Subscribe to be notified of new additions
Subscribe →
Section XI · Let's Talk

Knowledge is Free.
Mentorship is Personal.

The hub is open to everyone — but if you need structured guidance, 1-on-1 mentorship, or corporate training, that's a different conversation. Let's have it.

hello@debasisbhattacharjee.com  ·  +91 8777088548  ·  Mon–Fri, 9AM–6PM IST