This is the Reydix API - a fun little project that helps you find relevant fans for music events based on the artist that is performing there. It's built with NestJS and follows a microservices domain-driven archtiecture.
We've got three main services playing together:
- API Gateway (port 3000) - The API gateway that handles authentication and orchestrates everything
- Events Service (port 3001) - Manages events and artists data
- Fans Service (port 3002) - Handles fan and their connections to artists
Plus some supporting cast: PostgreSQL databases for each service, Redis for caching, and SuperTokens for authentication.
- First, copy the example environment file:
cp .env.example .env
The default values should work fine for local development, but feel free to tweak them if you need to.
If you want everything to just work without thinking about it:
docker-compose up --build
This will spin up all services, databases, and dependencies. Grab a coffee while it builds - first time takes a few minutes.
OR if you prefer running things locally (you'll need PostgreSQL and Redis running): --Recommended
# Install dependencies
pnpm install
# Start each service in separate terminals
cd apps/api-gateway && pnpm run start:dev
cd apps/events-service && pnpm run start:dev
cd apps/fans-service && pnpm run start:dev
The services need some sample data to be useful. you can first up the database services in docker compose, then go into each service and run the seed script:
docker compose up -d events-db fans-db reydix-db
cd apps/events-service && pnpm run seed
cd apps/fans-service && pnpm run seed
cd apps/api-gateway && pnpm run seed
This creates sample users, events, artists, fans, and the relationships between them. Pretty neat that it all works together!
We're using SuperTokens for authentication - it's a simple, open source, third-party authentication solution.
- Sign up first:
POST /auth/signup
- Or sign in:
POST /auth/signin
- Get a session cookie: SuperTokens handles this automatically
- Use the cookie: Include it in your requests to protected endpoints
The authentication is session-based with cookies, not JWT tokens in headers. Much more secure for web applications.
curl -X POST http://localhost:3000/auth/signup \
-H "Content-Type: application/json" \
-d '{
"formFields": [
{"id": "email", "value": "test@example.com"},
{"id": "password", "value": "password123"}
]
}'
curl -X POST http://localhost:3000/auth/signin \
-H "Content-Type: application/json" \
-d '{
"formFields": [
{"id": "email", "value": "test@example.com"},
{"id": "password", "value": "password123"}
]
}' \
-c cookies.txt
The -c cookies.txt
saves the session cookie to a file.
You can alternatively copy it from the set-cookie
header in the response.
Once you're authenticated, you can find fans who are interested in the artists performing at your event.
GET /events/{eventId}/relevant-fans
# Using the saved cookie from sign-in
curl -X GET http://localhost:3000/events/your-event-id-here/relevant-fans \
-H "Content-Type: application/json" \
-b "Cookie" # Use the cookie saved you got from sign-in
{
"event": {
"id": "123e4567-e89b-12d3-a456-426614174000",
"title": "Summer Music Fest",
"description": "An amazing outdoor festival",
"date": "2024-08-15T19:00:00.000Z",
"location": "Central Park",
"artists": [
{
"id": "456e7890-e89b-12d3-a456-426614174000",
"name": "The Cool Band",
"genre": "Rock"
}
]
},
"relevantFans": {
"fans": [
{
"id": "789e0123-e89b-12d3-a456-426614174000",
"username": "musiclover42",
"email": "fan@example.com"
}
],
"total": 1,
"eventId": "123e4567-e89b-12d3-a456-426614174000"
}
}
GET /events
- List all eventsGET /events/{id}
- Get specific eventGET /events/artists
- List all artists
GET /fans
- List all fansGET /fans/{eventId}/relevant-fans
- Find relevant fans
Double-check you're including the session cookie in your requests. The API uses cookie-based auth, not Authorization headers.
Check if ports 3000, 3001, 3002, 5432, 5433, 6379, and 3567 are available.
Make sure you've seeded the databases. The services need sample data to find relationships between fans and artists.