How softwaredeveloper111/ai-battle-arena works
AI Battle Arena is a web application for account-based AI coding battles: users authenticate, submit a problem, receive competing model solutions and judging, and manage saved battle sessions. The client initializes authentication and routes users to the dashboard; the server exposes auth and battle APIs, while battle execution streams updates over sockets. The tree and excerpts support these main paths, but unsampled client dashboard and server routing details limit some connections; optional or unverified links are marked dashed.
Main entry points: battle.controller.ts Battle operations · server.ts HTTP server entry · useBattle.js Battle workflow · App.jsx App bootstrap
Components 32
Web client
- App bootstrap
client/src/app/App.jsx - Route access
client/src/app/router/AppRouter.jsx - Auth pages
client/src/features/auth/pages/LoginPage.jsx - Battle dashboard
client/src/features/dashboard/pages/Dashboard.jsx
Identity and email
- Auth workflow
client/src/features/auth/hooks/useAuth.js - Auth state
client/src/features/auth/store/auth.store.js - Auth API client
client/src/features/auth/services/auth.api.js - Auth routes
server/src/routes/auth.route.ts - Auth operations
server/src/controllers/auth.controller.ts - User records
server/src/models/user.model.ts - Email jobs
server/src/queues/email.queue.ts - Email worker
server/src/workers/email.worker.ts - Email delivery
server/src/services/email.service.ts
Battle workflow
- Battle workflow
client/src/features/dashboard/hooks/useBattle.js - Battle API client
client/src/features/dashboard/services/battle.api.js - Battle state
client/src/features/dashboard/store/battle.store.js - Socket client
client/src/services/sockets/client.socket.js - Battle routes
server/src/routes/battle.route.ts - Battle operations
server/src/controllers/battle.controller.ts - AI battle graph
server/src/ai/battle/graph.ai.ts - Chat title generation
server/src/ai/chatTitleGenerate.ts - Chat sessions
server/src/models/chatSession.model.ts - Battle messages
server/src/models/battleMessage.model.ts - Socket server
server/src/socket/server.socket.ts
API runtime
- HTTP server entry
server/server.ts - Express API
server/src/app.ts - MongoDB connection
server/src/config/db.ts - Redis cache
server/src/config/cache.ts - Runtime configuration
server/src/config/config.ts
Other components
- Visitor / user
- Resend
- AI model providers
server/src/ai/battle/llmModel.provider.ts
Connections 35
- Visitor / user → App bootstrap: opens
- App bootstrap → Auth workflow: initializes auth
client/src/app/App.jsx - App bootstrap → Route access: renders
client/src/app/App.jsx - Route access → Auth pages: routes to
client/src/app/router/AppRouter.jsx - Route access → Battle dashboard: routes to
client/src/app/router/AppRouter.jsx - Auth workflow → Auth state: updates
client/src/features/auth/hooks/useAuth.js - Auth workflow → Auth API client: requests
client/src/features/auth/hooks/useAuth.js - Battle dashboard → Battle workflow: uses
- Battle workflow → Battle state: updates
client/src/features/dashboard/hooks/useBattle.js - Battle workflow → Battle API client: requests
client/src/features/dashboard/hooks/useBattle.js - Battle workflow → Socket client: uses
client/src/features/dashboard/hooks/useBattle.js - Visitor / user → HTTP server entry: sends requests
- HTTP server entry → Express API: serves
server/server.ts - HTTP server entry → MongoDB connection: connects
server/server.ts - HTTP server entry → Redis cache: loads
server/server.ts - HTTP server entry → Socket server: initializes
server/server.ts - HTTP server entry → Email worker: starts
server/server.ts - Express API → Auth routes: mounts
server/src/app.ts - Express API → Battle routes: mounts
server/src/app.ts - Auth routes → Auth operations: dispatches
server/src/routes/auth.route.ts - Auth operations → User records: reads and writes
server/src/controllers/auth.controller.ts - Auth operations → Email jobs: queues mail
server/src/controllers/auth.controller.ts - Email worker → Email delivery: sends through
server/src/workers/email.worker.ts - Email delivery → Resend: delivers via
server/src/services/email.service.ts - Battle routes → Battle operations: dispatches
- Battle operations → AI battle graph: streams solutions
server/src/controllers/battle.controller.ts - Battle operations → Chat title generation: generates title
server/src/controllers/battle.controller.ts - Battle operations → Chat sessions: reads and writes
server/src/controllers/battle.controller.ts - Battle operations → Battle messages: reads and writes
server/src/controllers/battle.controller.ts - Battle operations → Socket server: emits updates
server/src/controllers/battle.controller.ts - AI battle graph → AI model providers: uses providers
- Email jobs → Email worker: consumes jobs
- Auth API client → Auth routes: calls API
- Battle API client → Battle routes: calls API
- Socket client → Socket server: receives streams