TradeTalks is a scalable backend application designed for a chat-based marketplace where users can create nested chats, interact with each other, and seamlessly buy or sell products. Built using Express.js with a modular architecture, it offers a clean, organized structure for rapid development and scalability.
- Nested Chats: Create and manage chats with hierarchical sub-chats.
- Marketplace Integration: Buy and sell products directly within chat threads.
- Modular Architecture: Organized structure for easy maintenance and scalability.
- Middleware Support: Authentication, error handling, logging, and role-based access control.
- Real-Time Communication: Designed to support WebSocket integration for live updates.
- Robust Database: Supports PostgreSQL with seed data setup.
- Caching: Includes Redis for efficient caching and faster responses.
The project is organized as follows:
thisisby-TradeTalks/
├── Dockerfile
├── docker-compose.local.yaml
├── docker-compose.yaml
├── package.json
├── tsconfig.json
├── .env.docker
├── .gitlab-ci.yml
└── src/
├── context.ts
├── index.ts
├── app/
│ ├── middlewares/ # Middleware for auth, logging, errors, etc.
│ ├── modules/ # Feature modules like chat, user, auth, etc.
│ └── routes/ # Centralized route management
├── config/ # Configuration files for DB, Redis, etc.
├── constants/ # App-wide constants
├── database/ # Database connection and seeding
├── errors/ # Custom error handling
├── helpers/ # Utility functions and helpers
├── services/ # Shared services like AWS, image upload, etc.
└── utils/ # General utilities
- Node.js: v16.17 or later
- Docker: v20.10 or later
- Docker Compose: v2.2 or later
git clone https://github.com/your-username/TradeTalks.git
cd TradeTalks
Create a .env.docker
file for environment variables. Example:
NODE_ENV=development
DATABASE_URL=postgres://postgres:qweQWE123@localhost:5432/db
REDIS_URL=redis://localhost:6379
Run the app with the docker-compose.local.yaml
configuration:
docker-compose -f docker-compose.local.yaml up
Use the production configuration:
docker-compose up --build
- GET
/health-check
: Check the server health.
- POST
/auth/login
: User login. - POST
/auth/register
: User registration.
- POST
/chat
: Create a new chat. - GET
/chat/:id
: Get details of a specific chat. - POST
/chat/:id/message
: Send a message in a chat.
... and more. See the full API documentation here.
npm install
npm start
npm test
The application includes a Dockerfile
and docker-compose
configurations for local and production environments. Services like PostgreSQL and Redis are pre-configured.
- Fork the repository.
- Create a feature branch:
git checkout -b feature-name
. - Commit your changes:
git commit -m 'Add some feature'
. - Push to the branch:
git push origin feature-name
. - Open a pull request.
This project is licensed under the MIT License. See the LICENSE file for details.