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.
- 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)
- Node.js + TypeScript
- Express
- Mongoose (MongoDB)
- Socket.IO
- GraphQL
- Zod for validation
- dotenv for environment config
Top-level folders you will interact with:
src/— application sourceconfig/— environment configs (dev.config.ts,prod.config.ts)DB/— database connection, models, repositoriesmodel/— domain models and schema definitions
modules/— feature modules (auth, user, post, comment, chat)socket-io/— Socket.IO logic and validationutils/— helpers (email, token, OTP, providers, etc.)
-
Auth (
modules/auth)auth.service.ts,auth.controller.ts— handles sign-up, login, token generationauth.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)
- CRUD for posts, post-related GraphQL (
-
Comment (
modules/comment)- Comment model, service, and endpoints
-
Chat (
modules/chat+socket-io/chat)- Message model, repository and socket handlers
- Uses Mongoose schemas under
DB/model/*/*.schema.ts - Repositories encapsulate DB access (see
DB/*/*.repository.ts) - Connection logic in
DB/connection.ts
- Environment config files live in
src/config/env/. - Use
.envvariables in development to setMONGO_URI,JWT_SECRET, SMTP credentials, etc.
Note: Ensure secrets are not committed to the repo.
Install deps and start in development mode:
npm install
npm run devdev runs TypeScript compiler in watch mode and restarts the node process.
Build/start scripts can be added as needed (e.g., build, start).
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.
There are no tests configured yet. Recommended next steps:
- Add unit tests for services and repositories (Jest)
- Add integration tests for API/GraphQL routes
- 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.
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
DBfor DB changes. - Look at
modules/*/factoryandmodules/*/entityfor domain entity patterns.
- Ahmed Alashmony
- Portfolio: https://ahmedalashmony.vercel.app/
- LinkedIn: https://www.linkedin.com/in/ahmed-alashmony-90b133253