This is the backend API for the Ailena Test Assessment. It includes user authentication, wallet integration (mocked), real-time messaging via WebSocket, and call logging.
- JWT-based authentication
- User signup & login
- Wallet creation (mocked OnePipe integration)
- Chat room creation
- Real-time messaging with Socket.IO
- Call start/end logging
- Swagger documentation at
/api-docs
- Node.js / Express.js – Backend runtime and framework used for building RESTful APIs
- PostgreSQL (via Prisma ORM) – Relational database used to store and manage application data
- Socket.IO – Real-time bidirectional communication for messaging features
- Swagger – Interactive documentation for exploring and testing API endpoints
- JWT (JSON Web Tokens) – Secure token-based user authentication
⚠️ Note: Firebase was not integrated in this implementation as the system was designed using PostgreSQL and real-time communication handled via Socket.IO. However, the architecture is flexible and can be extended to incorporate Firebase for features like push notifications, Firestore, or authentication if required.
-
Clone the repository
git clone https://github.com/Litezy/Aileana-Test.git cd Aileana-Test -
Install Dependencies
npm install
-
Create a .env file using the example provided
cp .env.example .env
-
Edit
.envand configure as neededPORT=5000 DATABASE_URL=postgresql://USER:PASSWORD@localhost:5432/your_db JWT_SECRET=your_secret
-
Initialize Prisma & Migrate Database
npx prisma migrate dev --name init
-
Start the Server
npm run dev
- Server will run at: http://localhost:5000
- Swagger docs available at: http://localhost:5000/api-docs
You can test endpoints using Swagger at /api-docs.
All main route files are registered in the server (app.js) as shown below:
const testRoute = require("./routes/testRoute");
const authRoutes = require("./routes/authRoutes");
const walletRoutes = require("./routes/walletRoutes");
const callRoutes = require("./routes/callRoutes");
const messageRoutes = require("./routes/messageRoutes");
app.use("/api/test", testRoute); // Testing route to check if server is responding
app.use("/api/auth", authRoutes); // Signup and login routes
app.use("/api/wallet", walletRoutes); // Create wallet and fetch balance
app.use("/api/call", callRoutes); // Call routes
app.use("/api/message", messageRoutes); // Message routesroom_created– Triggered when room is createdprivate-message– Emitted when a message is sentdisconnect– Socket disconnect event
- All users are created before starting a conversation.
- Auto create wallet upon successful signup for users.
receiverIdis passed during messaging and calling — validated.- Call logs are only between two users, not group calls.
- OnePipe integration is mocked — no real API calls.
- WebSocket is used only for private messaging and room creation notification logged in the console.
this can be found in the SYSTEMDESIGN.md