The backend service for OnchainSage, an AI-driven decentralized trading assistant that combines real-time social sentiment analysis with on-chain market data.
- Authentication System: Secure user authentication and authorization
- Trading Signals: Real-time crypto trading signals and analysis
- Health Monitoring: System health and status endpoints
- Database Integration: PostgreSQL with TypeORM
- Environment Configuration: Flexible environment-based configuration
- Framework: NestJS with TypeScript
- Database: PostgreSQL with TypeORM
- Authentication: JWT-based authentication
- API Documentation: Swagger/OpenAPI
- Testing: Jest for unit and e2e tests
apps/backend/
├── src/
│ ├── auth/ # Authentication module
│ ├── config/ # Configuration files
│ ├── health/ # Health check endpoints
│ ├── signals/ # Trading signals module
│ ├── app.module.ts # Main application module
│ ├── main.ts # Application entry point
│ └── app.service.ts # Core application service
├── test/ # Test files
└── package.json # Dependencies and scripts
- Node.js (v16 or higher)
- PostgreSQL
- npm or yarn
-
Clone the Repository
git clone https://github.com/degenspot/onchainsage.git cd onchainsage/apps/backend -
Install Dependencies
npm install
-
Database Setup
# Connect to PostgreSQL psql -U postgres # Create the database CREATE DATABASE onchainsage; # Verify database creation \l
-
Environment Setup
# Copy environment file cp .env.development.example .env.development # Edit .env.development with your database credentials # Make sure DATABASE_PASSWORD matches your PostgreSQL password
-
Start the Development Server
# Development with hot-reload npm run start:dev # Production build npm run build npm run start:prod
npm run start:dev: Start development server with hot-reloadnpm run start:prod: Start production servernpm run build: Build the applicationnpm run test: Run unit testsnpm run test:e2e: Run end-to-end testsnpm run test:cov: Generate test coverage reportnpm run lint: Run linternpm run format: Format code with Prettier
Required environment variables:
# Database
DATABASE_HOST=localhost
DATABASE_PORT=5432
DATABASE_USER=your_user
DATABASE_PASSWORD=your_password
DATABASE_NAME=onchainsage
# JWT
JWT_SECRET=your_jwt_secret
JWT_EXPIRATION=24h
# API
PORT=3000
NODE_ENV=developmentThe project includes:
- Unit tests with Jest
- E2E tests
- Test coverage reporting
- Integration tests
Run tests with:
# Unit tests
npm run test
# E2E tests
npm run test:e2e
# Coverage report
npm run test:covOnce the server is running, visit:
- Swagger UI:
http://localhost:3000/api - OpenAPI JSON:
http://localhost:3000/api-json
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
For support, please open an issue in the GitHub repository or contact the maintainers.