- Node.js 22.15.0 or higher
- Docker and Docker Compose
- Git
git clone https://github.com/alanoteles/ledn-api.git
cd ledn-api
npm run setup:devThis will:
- Install dependencies
- Start PostgreSQL with Docker
- Run database migrations
- Seed the database with development data
- Start the API server
- API: http://localhost:3000/api/v1/accounts
- Documentation: http://localhost:3000/api-docs
- Health Check: http://localhost:3000
git clone https://github.com/alanoteles/ledn-api.git
cd ledn-api
npm installcp .env.example .env
# Edit .env if needed - defaults should work for local development# Start PostgreSQL
npm run docker:up
# Wait for database to be ready (about 10 seconds)
sleep 10
# Run migrations
npm run db:migrate
# Seed with development data (small dataset)
npm run db:seed:dev# Development mode
npm run dev
# Or production build
npm run build
npm run startnpm run dev- Start in development mode with hot reloadnpm run build- Build TypeScript to JavaScriptnpm run start- Start production build
npm run docker:up- Start PostgreSQL containernpm run docker:down- Stop containersnpm run db:migrate- Run database migrationsnpm run db:seed:dev- Seed with development data (~10k records)npm run db:seed- Seed with production data (~95k records)npm run db:reset- Reset database (careful!)
npm run test- Run all testsnpm run test:unit- Run unit tests onlynpm run test:integration- Run integration testsnpm run test:coverage- Run tests with coverage
npm run lint- Check code stylenpm run format- Format code with Prettiernpm run typecheck- TypeScript type checking
npm run setup:dev- Full development setup (database + seed + start)npm run setup:test- Setup for testing environment
npm run db:seed:dev- ~5,000 accounts
- ~10,000 transactions
- Faster processing (~30 seconds)
npm run db:seed- ~22,000 accounts
- ~95,000 transactions
- Processing time (~5-10 minutes)
curl http://localhost:3000curl http://localhost:3000/api/v1/accountscurl -X POST http://localhost:3000/api/v1/accounts \
-H "Content-Type: application/json" \
-d '{"userEmail": "test@example.com", "initialBalance": 100}'curl -X POST http://localhost:3000/api/v1/accounts/test@example.com/deposit \
-H "Content-Type: application/json" \
-d '{"amount": 50}'npm run docker:build
npm run docker:rundocker-compose -f monitoring/docker-compose.monitoring.yml up -dAccess:
- API: http://localhost:3000
- Grafana: http://localhost:3001 (admin/admin123)
- Prometheus: http://localhost:9090
# Check if PostgreSQL is running
docker ps | grep postgres
# Reset database if corrupted
npm run docker:down
npm run docker:up
sleep 10
npm run db:migrateIf port 3000 or 5432 are in use:
# Stop existing services
npx kill-port 3000
npx kill-port 5432
# Or change ports in .env file# Clean and rebuild
npm run clean
npm install
npm run buildsrc/
├── config/ # Configuration files
├── controllers/ # HTTP request handlers
├── middleware/ # Express middleware
├── repositories/ # Data access layer
├── routes/ # API route definitions
├── services/ # Business logic
├── types/ # TypeScript type definitions
└── utils/ # Utility functions
tests/ # Test files
data/ # Seed data files
monitoring/ # Monitoring configuration
The application is also deployed and accessible at:
- Live API: https://ledn-api.alanoteles.com/api/v1/accounts
- Documentation: https://ledn-api.alanoteles.com/api-docs/
- Monitoring: https://ledn-api.alanoteles.com/grafana/