- Node.js (v18 or higher)
- pnpm (install with
npm install -g pnpm)
# Install dependencies
pnpm installCreate a .env file in the root directory with the following variables:
NODE_ENV=development
PORT=4000
CORE_APP_PORT = 8000
DATABASE_URL=your_database_url
OPENROUTER_API_KEY=your_openrouter_api_keyNote: OPENROUTER_API_KEY is optional but recommended. Without it, you may encounter rate limits on free models. Get your API key from OpenRouter.
# Start Express API server
pnpm run devThe Express API server will start on http://localhost:8000 (or the port specified in your .env file).
# Start Mastra dev server (runs on port 3001)
pnpm run mastra:devNote: Mastra Studio runs on port 4000 to avoid conflicts with the Express API server. You can run both servers simultaneously:
- Express API:
http://localhost:8000 - Mastra Studio:
http://localhost:4000
# Build the project
pnpm run build
# Start the server
pnpm startpnpm run dev- Start Express development server with hot reload (port 8000)pnpm run mastra:dev- Start Mastra Studio for AI development (port 3001)pnpm run build- Build the project for productionpnpm run lint- Run ESLintpnpm run format- Format code with Prettierpnpm run type-check- Run TypeScript type checking
Important: Never commit your .env file or hardcode credentials. Always use environment variables.
POST
https://localhost:8000/api/v1/user/register
Body
{
"name": "test user",
"email": "test@gmail.com",
"password": "password",
"phone": "091122334455",
"city": "Yangon",
"township": "Dagon"
}POST
https://localhost:8000/api/v1/user/login
Body
{
"email": "test@gmail.com",
"password": "password"
}POST
https://localhost:8000/api/v1/user/logout
POST
https://localhost:8000/api/v1/safe
Body
{
"userId": "6912e2c09c5bb1e00e41d376",
"status": "safe"
}GET
https://localhost:8000/api/v1/safe/average
GET
https://localhost:8000/api/v1/safe/average/:city
GET
https://localhost:8000/api/v1/user/get-all-user
POST
https://localhost:8000/api/v1/user/add-friend
Body
{
"myId": "6912e2c09c5bb1e00e41d376",
"phone": "091122334455"
}GET
https://localhost:8000/api/v1/user/:userId/friends
Params
userId = "6912e2c09c5bb1e00e41d376"
PATCH
https://localhost:8000/api/v1/user/:userId/update
DELETE
https://localhost:8000/api/v1/user/:userId/destroy
GET
http://127.0.0.1:8000/api/v1/flooding/chance-percentage
Request Parameters
lat, lon, days
Response Example
{
"date": "2025-11-12",
"river_discharge": 340,
"flood_risk_percent": 65
}π‘ Use this route to get flood risk percentage for a single location (e.g., to notify users about the risk).
GET
http://127.0.0.1:8000/api/v1/flooding/chance-percentage-by-city-town
Response Example
[
{
"city": "Ayeyarwady",
"township": "Labutta",
"coords": [16.15, 94.783],
"status": "Moderate Risk",
"chance": 56,
"locals": 315240,
"items": {
"medical kit": 13,
"food and water": 17,
"shelter": 14,
"clothing": 13,
"hygiene items": 11,
"baby care": 10,
"power and lighting": 12,
"safety and rescue gear": 10
},
"safePercentage": 55,
"unsafePercentage": 35,
"noresponsePercentage": 10
}
]
β οΈ This route returns only Moderate and High Risk locations with coordinates, local population, and survey result summaries.
GET
http://127.0.0.1:8000/api/v1/supply-category
Response Example
[
{
"category": "food and water"
},
{
"category": "medical kit"
}
]π§Ύ This route provides the list of categories used for supply surveys in high-risk areas.
POST
http://127.0.0.1:8000/api/v1/supply-survey
Body
{
"userId": "6912e2c09c5bb1e00e41d376",
"city": "Yangon",
"township": "Dagon",
"supplyList": ["food and water", "shelter", "medical kit"]
}π§ Each user can submit their available supplies based on predefined categories.
Multiple items can be selected insupplyList.
β
Base URL:
http://127.0.0.1:8000/api/v1/