Skip to content
Rittick DattaFULL STACK DEVELOPER

DevConnect - A MERN Stack App

A full-stack web application built with MongoDB, Express.js, React, and Node.js (MERN), designed to connect developers through professional profiles and community interactions.

๐Ÿš€ DevConnect โ€” MERN Stack Social Network

A Full-Stack Social Networking Application for Developers

A full-stack web application built with MongoDB, Express.js, React, and Node.js (MERN), designed to connect developers through professional profiles and community interactions.

The project demonstrates core full-stack engineering concepts, including RESTful API design, JWT-based authentication, password hashing, MongoDB data modeling, request validation, and frontend-backend communication.

๐Ÿ› ๏ธ Tech Stack

TechnologyPurpose
ReactComponent-based frontend
Node.jsJavaScript server runtime
Express.jsREST API framework
MongoDBDocument-oriented database
MongooseSchema modeling and database access
JWTToken-based authentication
bcryptjsPassword hashing
express-validatorBackend request validation
GravatarProfile avatar integration
NodemonBackend development
ConcurrentlyRun frontend and backend together

๐ŸŽฏ Problem Statement

Developers often maintain their professional information across multiple platforms, making it difficult to manage their profiles, technical experience, and community interactions in one place.

This project explores how a developer-focused social networking application can be built using a complete JavaScript technology stack.

From an engineering perspective, the application addresses several important challenges:

  • Securely registering and authenticating users.
  • Managing user profiles and related information.
  • Building a maintainable REST API.
  • Persisting application data in MongoDB.
  • Validating incoming requests.
  • Coordinating frontend and backend state.
  • Designing an architecture that can evolve as usage grows.

The goal is to establish a foundation for a developer community while demonstrating practical full-stack application development.

โœจ Project Goals

  • Build a full-stack application using JavaScript.
  • Separate frontend presentation from backend business logic.
  • Implement authentication using JWT and bcryptjs.
  • Integrate MongoDB through Mongoose.
  • Validate API requests using express-validator.
  • Organize backend functionality into routes, middleware, and models.
  • Maintain reusable frontend components.
  • Establish a foundation for future social networking features.

๐Ÿ—๏ธ System Architecture

The application follows a client-server architecture.

High-Level Architecture

flowchart TD
    A[User / Browser] --> B[React Frontend]
    B -->|HTTP Requests| C[Express REST API]
    C --> D[Middleware]
    D --> E[Route Handlers]
    E --> F[Mongoose Models]
    F --> G[(MongoDB)]
    E --> H[JWT Authentication]
    E --> I[Gravatar Integration]

Architectural Responsibilities

LayerResponsibility
FrontendRender UI and manage user interactions
APIHandle requests and return responses
MiddlewareAuthentication and request processing
ValidationValidate incoming data
ModelsDefine database schemas and queries
DatabasePersist application records
AuthenticationVerify user identity and protect resources

Why Separate Frontend and Backend?

The React application focuses on user interaction and presentation, while the Express backend handles authentication, validation, business logic, and database access.

This separation provides:

  • Clear responsibility boundaries.
  • Reusable API endpoints.
  • Independent frontend and backend development.
  • Better organization as the application grows.

The trade-off is additional coordination between the frontend and backend, particularly around API contracts and configuration.

๐Ÿ—„๏ธ Why MongoDB?

MongoDB is a document-oriented database that stores information in flexible, JSON-like documents.

For a developer-focused social network, this model is useful because user profiles may contain varying amounts of information.

For example, one developer may provide only basic profile details, while another may include skills, experience, education, and social links.

Advantages

1. Flexible Schemas

Document-oriented storage supports evolving application data structures.

2. JavaScript-Friendly Data

MongoDB documents integrate naturally with JavaScript objects.

3. Mongoose Integration

Mongoose provides schema definitions, validation, and structured query operations.

4. Extensibility

New profile fields and social features can be introduced as application requirements evolve.

Example User Model

const UserSchema = new mongoose.Schema({
  name: {
    type: String,
    required: true
  },
  email: {
    type: String,
    required: true,
    unique: true
  },
  password: {
    type: String,
    required: true
  },
  avatar: String
});

This is an illustrative model rather than a verified copy of the repository's schema.

Trade-offs

MongoDB offers flexibility, but relationships between users, profiles, posts, and comments require deliberate modeling.

Embedding documents can simplify some reads, while references may provide greater flexibility for independently changing records.

The right approach depends on query patterns, update frequency, and expected data volume.

๐Ÿ” Authentication and Security

Authentication is a fundamental requirement for applications that manage user-specific information.

The project includes JWT, bcryptjs, and express-validator as authentication and security-related dependencies.

JWT Authentication Flow

sequenceDiagram
    participant U as User
    participant R as React Client
    participant A as Express API
    participant D as MongoDB

    U->>R: Enter credentials
    R->>A: Login request
    A->>D: Retrieve user
    D-->>A: User record
    A->>A: Verify password
    A-->>R: Signed JWT
    R->>A: Request with token
    A->>A: Validate token
    A-->>R: Protected response

This diagram illustrates a typical JWT-based authentication flow.

Why JWT?

JWT allows the backend to verify signed authentication tokens without requiring a traditional server-side session lookup for every request.

However, token expiration, revocation, and secure storage must still be handled carefully.

Why bcryptjs?

Passwords should never be stored in plain text.

bcryptjs provides password hashing and verification functionality, helping protect stored credentials.

Why express-validator?

Frontend validation improves usability, but backend validation is essential because clients cannot be trusted.

express-validator helps enforce request requirements before data reaches application logic.

Security Considerations

A production-ready application should additionally address:

  • Token expiration and rotation.
  • Secure token storage.
  • Authorization checks for resource ownership.
  • Authentication rate limiting.
  • Environment secret management.
  • Appropriate CORS configuration.
  • Input validation and sanitization.
  • Dependency vulnerability monitoring.

๐ŸŒ REST API Architecture

The repository contains a routes/api/ directory, establishing an organizational boundary for API endpoints.

Request Lifecycle

flowchart TD
    A[React Client] --> B[HTTP Request]
    B --> C[Express Route]
    C --> D[Request Validation]
    D --> E[Authentication Middleware]
    E --> F[Business Logic]
    F --> G[Mongoose Query]
    G --> H[(MongoDB)]
    H --> I[JSON Response]
    I --> A

Not every endpoint requires authentication, so the exact sequence depends on the operation.

API Design Principles

  • Use resource-oriented endpoints.
  • Apply appropriate HTTP methods.
  • Validate requests before processing.
  • Return consistent response structures.
  • Protect restricted operations.
  • Handle expected and unexpected errors.
  • Separate database access from request validation.

Example API Resources

ResourceExample Operations
AuthenticationRegister and log in
UsersRetrieve user information
ProfilesCreate and update developer profiles
PostsCreate and retrieve community posts
CommentsManage discussions

These represent suitable API resources for the application concept, not a verified list of implemented endpoints.

๐Ÿ”„ State Management

The application operates across three primary categories of state.

1. Client-Side State

React manages UI interactions such as forms, navigation, loading indicators, and feedback.

Shared state may be needed for authentication information and data retrieved from the backend.

2. Authentication State

Authentication state determines whether a user is authenticated and which protected operations are available.

The frontend may retain authentication context, but the backend must independently validate protected requests.

3. Persistent State

MongoDB stores durable application information such as user and profile records.

Unlike temporary frontend state, database records persist across browser sessions and application restarts.

Design Principle

The frontend manages presentation state, while the backend enforces security and business rules and MongoDB stores durable data.

This separation helps prevent UI state from becoming the sole authority for sensitive operations.

โš–๏ธ Engineering Trade-offs

DecisionBenefitTrade-off
MERN stackJavaScript across the applicationClient-server coordination
ReactReusable UI componentsState-management complexity
ExpressFlexible backend frameworkRequires deliberate structure
MongoDBFlexible document storageRelationship management
MongooseStructured database modelingAdditional abstraction
JWTSigned, stateless authenticationToken lifecycle complexity
bcryptjsSecure password hashingComputational overhead
Separate frontend/backendClear responsibilitiesMore deployment configuration
GravatarExternal avatar integrationThird-party dependency

Why MERN?

Using JavaScript across the frontend and backend reduces context switching between languages.

It also makes the API boundary explicit, helping developers understand how frontend requests interact with backend logic and persistent storage.

The trade-off is that separate applications require coordination around development, deployment, and data contracts.

๐Ÿงฉ Technical Challenges

1. End-to-End Authentication

Authentication requires coordinating frontend forms, backend validation, password verification, token issuance, and protected requests.

The main challenge is maintaining consistency across these boundaries.

2. MongoDB Data Modeling

Social networking data contains relationships between users and other resources.

Choosing between embedded and referenced documents affects performance, maintainability, and consistency.

3. Request Validation

Backend endpoints must handle untrusted input.

Validation helps prevent malformed or invalid records from entering the database.

4. Frontend-Backend Communication

The React client and Express server operate as separate applications.

This introduces concerns around API communication, configuration, error handling, and development workflows.

5. Asynchronous Operations

Database queries and HTTP requests are asynchronous.

The application must handle loading, success, failure, and unexpected responses appropriately.

These are engineering challenges associated with the project's architecture rather than independently verified accounts of every issue encountered during implementation.

๐Ÿš€ Performance Considerations

Database Indexing

Frequently queried fields should be indexed appropriately.

Indexes improve lookup performance but introduce storage and write overhead.

Efficient API Responses

API endpoints should return only the information needed by the client.

Pagination

Large collections of users, profiles, or posts should be paginated rather than returned in a single response.

Frontend Rendering

Reusable components and carefully managed state help reduce unnecessary rendering work.

Caching

Frequently accessed public data may benefit from caching as usage increases.

Query Optimization

Mongoose queries should be monitored for unnecessary document retrieval and expensive population operations.

These are optimization opportunities rather than verified performance improvements.

๐Ÿ“ˆ Scaling to 100,000 Users

At approximately 100,000 registered users, scaling requirements would depend on active traffic, database load, and interaction patterns.

1. Optimize MongoDB

  • Add indexes for frequent queries.
  • Analyze slow database operations.
  • Implement pagination.
  • Avoid unnecessary document population.
  • Monitor database connections.

2. Introduce Redis

Redis could support caching, rate limiting, and temporary application data.

MongoDB would remain the primary persistent data store.

3. Scale the Express Backend

Keep API instances stateless where practical so requests can be distributed across multiple server instances.

4. Improve Authentication Infrastructure

Introduce login rate limiting, robust token lifecycle management, and security monitoring.

5. Add Background Processing

Move noninteractive tasks such as notifications and bulk operations into background workers.

6. Optimize Media Delivery

Use object storage and a CDN for user-uploaded media if the application introduces uploads.

7. Add Observability

Monitor:

  • API latency and error rates.
  • Database query performance.
  • Authentication failures.
  • Request throughput.
  • Application resource usage.
  • Infrastructure costs.

Scaling Philosophy

Optimize measured bottlenecks before introducing unnecessary architectural complexity.

๐Ÿ“ Project Structure

Mern_Stack_App/
โ”œโ”€โ”€ _resources/
โ”‚   โ””โ”€โ”€ html_css_theme/    # UI theme resources
โ”œโ”€โ”€ client/                # React frontend
โ”œโ”€โ”€ config/                # Backend configuration
โ”œโ”€โ”€ middleware/            # Express middleware
โ”œโ”€โ”€ models/                # Mongoose models
โ”œโ”€โ”€ routes/
โ”‚   โ””โ”€โ”€ api/               # API endpoints
โ”œโ”€โ”€ .gitignore
โ”œโ”€โ”€ package.json
โ”œโ”€โ”€ package-lock.json
โ”œโ”€โ”€ server.js              # Backend entry point
โ””โ”€โ”€ README.md

๐Ÿ’ป Getting Started

Prerequisites

  • Node.js and npm
  • MongoDB or MongoDB Atlas
  • Backend configuration and authentication secrets

1. Clone the Repository

git clone https://github.com/RittickDatta/Mern_Stack_App.git
cd Mern_Stack_App

2. Install Backend Dependencies

npm install

3. Install Frontend Dependencies

cd client
npm install
cd ..

4. Configure the Application

The repository includes a config/ directory.

A typical MERN application requires a MongoDB connection string, JWT signing secret, and server configuration.

Verify the exact configuration keys from the source code before running the application.

Never commit real credentials or authentication secrets.

5. Start Development

npm run dev

The root development script uses concurrently to run the frontend and backend together.

Available Scripts

CommandPurpose
npm startStart the Node.js server
npm run serverStart backend with Nodemon
npm run clientStart React frontend
npm run devRun frontend and backend together

๐Ÿ”ฎ Future Improvements

  • Stronger authentication and authorization
  • Password reset and account recovery
  • Improved developer profile discovery
  • Pagination for social feeds
  • Real-time notifications
  • Automated API and integration testing
  • OpenAPI documentation
  • Redis-based caching
  • TypeScript migration
  • Docker-based development
  • CI/CD automation
  • Monitoring and performance testing

These represent potential improvements rather than confirmed existing functionality.

๐Ÿ‘จโ€๐Ÿ’ป Author

Rittick Datta

GitHub: @RittickDatta

Repository: Mern_Stack_App

๐Ÿ“„ License

ISC โ€” as declared in the root package.json.


DevConnect โ€” Connecting Developers Through the MERN Stack.