Yo is a production-style backend for a Twitter-like social app. It's built as a Nest.js monorepo with an API gateway and an event service that talk over Kafka, and it covers the things real social platforms need: auth, follows, posts, replies, reposts, likes, search, notifications and media uploads.
- Microservices monorepo:
api-gateway(REST + Swagger) andevent-service(Kafka consumer), with sharedlibs/for config, Kafka, email, types and utils - Event-driven design: domain events (for example, user created) are published to Kafka so async work stays decoupled from the request path
- Data layer: MySQL with TypeORM, versioned migrations, seeders, plus backup and restore scripts
- Performance: Redis caching and DataLoader batching to avoid N+1 queries
- Search: Elasticsearch-powered search module
- Notifications: stored in DynamoDB (see DYNAMODB_IMPLEMENTATION.md)
- Media uploads: S3 presigned URLs, so clients upload avatars directly to S3
- Security: session-based auth guards, bcrypt password hashing, request validation with class-validator
- Observability: Datadog tracing via
dd-trace - Quality: Jest unit tests across controllers, services and guards, plus e2e tests and Compodoc docs
- CI/CD: GitHub Actions pipeline that provisions staging with Terraform and ships Docker images to AWS ECR
flowchart LR
Client([Client]) --> GW[API Gateway<br/>Nest.js REST + Swagger]
GW --> MySQL[(MySQL<br/>TypeORM)]
GW --> Redis[(Redis cache)]
GW --> ES[(Elasticsearch)]
GW --> S3[(S3 presigned uploads)]
GW -- domain events --> Kafka{{Kafka}}
Kafka --> EV[Event Service<br/>Nest.js consumer]
EV --> DDB[(DynamoDB<br/>notifications)]
- The backend generates a presigned S3 URL and object key
- The client uploads the image straight to S3 with a
PUTrequest - The object key is saved on the user record
- Avatars are served through signed URLs generated by the backend
# install dependencies
npm install
# start MySQL, Kafka, Redis, Elasticsearch and admin UIs
npm run docker:up
# run migrations and seed data
npm run migration:run
npm run db:seed
# start the services in watch mode
npm run start:api-gateway
npm run start:event-serviceAPI docs are available at http://localhost:3000/api (Swagger).
More detail lives in readme/GETTING_STARTED.md and readme/MIGRATIONS.md.
npm run test # unit tests
npm run test:e2e # end-to-end tests
npm run test:cov # coverage reportπ = auth required Β· π = paginated
Auth
-
POST /auth/login
Users
-
GET /users/@{username} -
GET /users/{userid} -
POST /users -
PATCH /users/{userid}π -
PUT /users/{userid}/followπ -
DELETE /users/{userid}/followπ -
GET /usersπ -
GET /users/{userid}/followersπ -
GET /users/{userid}/followeesπ
Posts
-
GET /posts/{postid} -
POST /postsπ (simple posts, replies, reposts and quote posts) -
DELETE /posts/{postid}π -
PUT /posts/{postid}/likeπ -
DELETE /posts/{postid}/likeπ -
GET /postsπ filtered by author -
GET /postsfilters for replies, original posts and full-text search - #hashtags and @mentions in posts
Hashtags
-
GET /hashtagsπ -
GET /hashtags/{tag}/postsπ
Nest.js Β· TypeScript Β· TypeORM Β· MySQL Β· Kafka (KafkaJS) Β· Redis (ioredis) Β· DataLoader Β· Elasticsearch Β· DynamoDB Β· AWS S3 Β· Swagger Β· Jest Β· Docker Β· Terraform Β· GitHub Actions Β· Datadog
Mustkeem K, Senior Full Stack Engineer Β· mustkeemk.com Β· LinkedIn
Licensed under the GNU AGPL v3.