Skip to content

Latest commit

 

History

73 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

social-app 🚀

Overview

social-app is a Node.js + TypeScript backend that provides core social networking functionality: users, authentication, posts, comments, reactions, real-time chat (Socket.IO), and GraphQL endpoints. The codebase uses a repository pattern layered on top of Mongoose models and includes middleware for auth and validation.


🔧 Features

  • Authentication (JWT, bcrypt)
  • User management (profiles, validation)
  • Posts & Comments with reactions
  • Real-time chat using Socket.IO
  • GraphQL support for some modules
  • Modular architecture (DB layer, services, controllers, middleware)

🧱 Tech Stack

  • Node.js + TypeScript
  • Express
  • Mongoose (MongoDB)
  • Socket.IO
  • GraphQL
  • Zod for validation
  • dotenv for environment config

📁 Project Structure (high level)

Top-level folders you will interact with:

  • src/ — application source
    • config/ — environment configs (dev.config.ts, prod.config.ts)
    • DB/ — database connection, models, repositories
      • model/ — domain models and schema definitions
    • modules/ — feature modules (auth, user, post, comment, chat)
    • socket-io/ — Socket.IO logic and validation
    • utils/ — helpers (email, token, OTP, providers, etc.)

🔍 Important Modules

  • Auth (modules/auth)

    • auth.service.ts, auth.controller.ts — handles sign-up, login, token generation
    • auth.validation.ts — request validation
  • User (modules/user)

    • profile management and GraphQL types
  • Post (modules/post)

    • CRUD for posts, post-related GraphQL (post-service.graphql.ts)
  • Comment (modules/comment)

    • Comment model, service, and endpoints
  • Chat (modules/chat + socket-io/chat)

    • Message model, repository and socket handlers

🗄️ Database & Repositories

  • Uses Mongoose schemas under DB/model/*/*.schema.ts
  • Repositories encapsulate DB access (see DB/*/*.repository.ts)
  • Connection logic in DB/connection.ts

⚙️ Environment & Config

  • Environment config files live in src/config/env/.
  • Use .env variables in development to set MONGO_URI, JWT_SECRET, SMTP credentials, etc.

Note: Ensure secrets are not committed to the repo.


▶️ Run & Develop

Install deps and start in development mode:

npm install
npm run dev

dev runs TypeScript compiler in watch mode and restarts the node process.

Build/start scripts can be added as needed (e.g., build, start).


🔁 Socket.IO Events

Socket handlers live in socket-io/ and include chat validation and status events. Check socket-io/chat/index.ts and socket-io/middleware for specifics.


🧪 Testing

There are no tests configured yet. Recommended next steps:

  • Add unit tests for services and repositories (Jest)
  • Add integration tests for API/GraphQL routes

✅ Contributing

  • Fork, create a feature branch, and open a PR with clear description and tests when applicable.
  • Follow the existing folder/module patterns when adding features.

📬 Contact

For questions or help, refer to the repository owners or add an issue in the tracker.


License: ISC


Short tips:

  • Use the repository layer under DB for DB changes.
  • Look at modules/*/factory and modules/*/entity for domain entity patterns.

Author

About

Backend social app building usign Express.js , Node.js , TS , MongoDB and mongoose

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages