AllyNet is a production-grade, safety-first community platform that connects neighbors in need with verified helpers in real-time. The platform combines emergency SOS capabilities with community assistance features, all built on a foundation of trust and verified interactions.
- Overview
- Key Features
- Technology Stack
- Project Structure
- Getting Started
- Environment Variables
- API Documentation
- Trust Score System
- Security Features
- Real-Time Features
- Deployment
- Development
AllyNet is a full-stack application designed to enhance community safety through:
- Emergency SOS System: Real-time location-based emergency alerts with instant notification to nearby verified helpers
- Community Help Marketplace: Non-urgent peer-to-peer assistance platform (moving, tech support, tutoring, etc.)
- Trust & Verification: Comprehensive trust score system that rewards helpful behavior and maintains community safety
- Safety Features: Emergency contacts with SMS notifications, safety settings, and reporting mechanisms
- Real-Time Alerts: Instant location-based emergency notifications
- Multiple Emergency Types: Medical, safety, accident, assault, natural disaster, and more
- Privacy Options: Silent mode, anonymous mode, and fake call alerts
- Helper Coordination: Real-time chat, status updates, and location sharing
- Emergency History: Complete history of SOS requested and SOS helped
- Create Help Requests: Post non-urgent assistance requests with location
- Helper Responses: Verified helpers can respond with messages
- Conversation Threads: Full messaging system for creator-helper communication
- Accept/Deny/Report: Creator can accept, deny, or report helper responses
- Response Management: View all requests and responses in one place
- Dynamic Scoring: Trust score ranges from 0-1000
- Score Increases:
- +10 points: When helper's response to help request is accepted
- +50 points: When helper accepts/responds to an SOS emergency
- +50 points: When helper resolves an SOS emergency
- Score Decreases:
- -50 points: When helper is reported by a creator
- Profile Stats: Track helped, requested, SOS alerts, and reports
- Comprehensive Profile: Trust score, stats, and activity history
- Emergency Contacts: Add/delete emergency contacts for SMS notifications
- Safety Settings: Manage emergency contacts and safety preferences
- Help Center: Submit questions, complaints, bug reports, and feature requests
- Emergency History: Detailed view of all SOS interactions
- Location-Based Discovery: Find nearby help requests and emergencies
- Ad System: Create and view marketplace advertisements
- Nearby Ads Preview: Discover local services and offerings
- Runtime: Node.js (>=18.0.0)
- Framework: Express.js
- Database: MongoDB with Mongoose ODM
- Authentication: JWT (JSON Web Tokens) with refresh token support
- Real-Time: Socket.IO for real-time communication
- Validation: express-validator
- Security: bcryptjs for password hashing
- Other: dotenv, cors, uuid
- Framework: React 19.2.0
- Build Tool: Vite 7.2.4
- Routing: React Router DOM 7.11.0
- State Management: Zustand 5.0.9
- Styling: Tailwind CSS 4.1.18
- Animations: Framer Motion 12.23.26
- Icons: Lucide React 0.562.0
- Real-Time: Socket.IO Client 4.8.1
- Utilities: clsx, tailwind-merge
AllyNet-full/
βββ AllyNet-back/ # Backend API Server
β βββ src/
β β βββ config/ # Configuration files
β β β βββ database.js # MongoDB connection
β β βββ controllers/ # Request handlers
β β β βββ authController.js
β β β βββ emergencyController.js
β β β βββ helpRequestController.js
β β β βββ messageController.js
β β β βββ adController.js
β β β βββ contactController.js
β β βββ models/ # Mongoose schemas
β β β βββ User.js
β β β βββ Emergency.js
β β β βββ HelpRequest.js
β β β βββ EmergencyMessage.js
β β β βββ Ad.js
β β β βββ Contact.js
β β β βββ index.js
β β βββ routes/ # Express routes
β β β βββ auth.js
β β β βββ emergency.js
β β β βββ helpRequest.js
β β β βββ health.js
β β β βββ ad.js
β β β βββ contact.js
β β βββ services/ # Business logic layer
β β β βββ emergencyService.js
β β β βββ helpRequestService.js
β β β βββ messageService.js
β β β βββ adService.js
β β β βββ contactService.js
β β βββ middleware/ # Custom middleware
β β β βββ auth.js # JWT authentication
β β β βββ errorHandler.js # Global error handler
β β βββ sockets/ # Socket.IO handlers
β β β βββ index.js
β β β βββ emergencySocket.js
β β β βββ socketAuth.js
β β βββ utils/ # Utility functions
β β β βββ jwt.js
β β β βββ asyncHandler.js
β β β βββ messageSerializer.js
β β β βββ smsService.js
β β βββ app.js # Express app setup
β β βββ server.js # Server bootstrap
β βββ scripts/ # Utility scripts
β β βββ cleanup-stale-emergencies.js
β βββ package.json
β
βββ AllyNet-front/ # Frontend React Application
β βββ src/
β β βββ api/ # API client functions
β β β βββ auth.js
β β β βββ emergency.js
β β β βββ helpRequest.js
β β β βββ socket.js
β β β βββ ad.js
β β β βββ contact.js
β β βββ components/ # Reusable UI components
β β β βββ Button.jsx
β β β βββ Card.jsx
β β β βββ BottomNav.jsx
β β β βββ ProtectedRoute.jsx
β β β βββ ThemeToggle.jsx
β β β βββ EmergencyNotification.jsx
β β β βββ EmergencyEndedNotification.jsx
β β β βββ EmergencyMapModal.jsx
β β β βββ FakeCallAlert.jsx
β β β βββ NearbyAdsPreview.jsx
β β βββ features/ # Feature-based components
β β β βββ auth/
β β β β βββ LoginPage.jsx
β β β β βββ SignupPage.jsx
β β β β βββ Onboarding.jsx
β β β βββ emergency/
β β β β βββ SOSOverlay.jsx
β β β β βββ EmergencyActiveView.jsx
β β β β βββ EmergencyChat.jsx
β β β β βββ EmergencyDetails.jsx
β β β β βββ EmergencyChatHistory.jsx
β β β βββ help/
β β β β βββ CreateHelpRequest.jsx
β β β β βββ HelpFeed.jsx
β β β β βββ HelpRequestsPage.jsx
β β β βββ profile/
β β β β βββ ProfilePage.jsx
β β β β βββ ProfileView.jsx
β β β β βββ EmergencyHistory.jsx
β β β β βββ SafetySettings.jsx
β β β β βββ HelpCenter.jsx
β β β β βββ TrustScoreRing.jsx
β β β β βββ OrganizationView.jsx
β β β β βββ PaymentsView.jsx
β β β βββ marketplace/
β β β β βββ DiscoveryView.jsx
β β β β βββ CreateAdForm.jsx
β β β βββ ads/
β β β β βββ AdDetailView.jsx
β β β β βββ AdHistory.jsx
β β β βββ about/
β β β βββ AboutAllyNet.jsx
β β βββ hooks/ # Custom React hooks
β β β βββ useEmergencySocket.js
β β βββ layouts/ # Layout components
β β β βββ AppShell.jsx
β β βββ store/ # Zustand state stores
β β β βββ useAuthStore.js
β β β βββ useEmergencyStore.js
β β β βββ useEmergencySessionStore.js
β β β βββ useHelpStore.js
β β β βββ useMarketplaceStore.js
β β β βββ useTabStore.js
β β β βββ useThemeStore.js
β β βββ App.jsx # Main app component
β β βββ main.jsx # React entry point
β β βββ index.css # Global styles
β β βββ utils.js # Utility functions
β βββ public/
β β βββ favicon.svg
β βββ index.html
β βββ vite.config.js
β βββ tailwind.config.js
β βββ package.json
β
βββ README.md # This file
- Node.js: >= 18.0.0
- MongoDB: Local installation or MongoDB Atlas account
- npm or yarn: Package manager
-
Navigate to backend directory:
cd AllyNet-back -
Install dependencies:
npm install
-
Create environment file: Create a
.envfile in theAllyNet-backdirectory:NODE_ENV=development PORT=5000 MONGODB_URI=mongodb://localhost:27017/allynet JWT_SECRET=your-super-secret-jwt-key-change-in-production JWT_REFRESH_SECRET=your-super-secret-refresh-key-change-in-production JWT_EXPIRE=1d JWT_REFRESH_EXPIRE=7d FRONTEND_URL=http://localhost:5173
-
Start MongoDB (if running locally):
# Make sure MongoDB is running on localhost:27017 # Or update MONGODB_URI in .env to point to your MongoDB instance
-
Run the server:
# Development mode (with hot reload) npm run dev # Production mode npm start
-
Verify backend is running:
curl http://localhost:5000/api/health
-
Navigate to frontend directory:
cd AllyNet-front -
Install dependencies:
npm install
-
Configure API base URL (if needed): Update the API base URL in
src/api/*.jsfiles if your backend runs on a different port. -
Run the development server:
npm run dev
-
Build for production:
npm run build
-
Preview production build:
npm run preview
The frontend will be available at http://localhost:5173 (or the next available port).
| Variable | Description | Default | Required |
|---|---|---|---|
NODE_ENV |
Environment (development/production) | development |
No |
PORT |
Server port | 5000 |
No |
MONGODB_URI |
MongoDB connection string | - | Yes |
JWT_SECRET |
Secret key for access tokens | - | Yes |
JWT_REFRESH_SECRET |
Secret key for refresh tokens | - | Yes |
JWT_EXPIRE |
Access token expiration | 1d |
No |
JWT_REFRESH_EXPIRE |
Refresh token expiration | 7d |
No |
FRONTEND_URL |
Frontend URL for CORS | http://localhost:5173 |
No |
Security Note: Never commit .env files to version control. Use strong, unique secrets in production.
http://localhost:5000/api/v1
POST /auth/register
Body: { email, password, name (or firstName, lastName), phone?, location? }
Response: { success, data: { user, tokens } }
POST /auth/login
Body: { email, password }
Response: { success, data: { user, tokens } }
GET /auth/me
Headers: { Authorization: "Bearer <access_token>" }
Response: { success, data: { user } }
GET /auth/stats
Headers: { Authorization: "Bearer <access_token>" }
Response: { success, data: { trustScore, helped, requested, sosAlerts, reports } }
GET /auth/emergency-contacts
POST /auth/emergency-contacts (Body: { name, phone })
DELETE /auth/emergency-contacts/:contactId
POST /emergencies
Body: {
location: { latitude, longitude },
type?: string,
description?: string,
silentMode?: boolean,
anonymousMode?: boolean,
fakeCallAlert?: boolean
}
Response: { success, data: { emergency } }
GET /emergencies/active
Response: { success, data: { emergency } }
GET /emergencies/nearby?latitude=...&longitude=...&radius=...
Response: { success, data: { emergencies } }
POST /emergencies/:id/respond
Body: { estimatedArrival?: Date }
Response: { success, data: { emergency } }
POST /emergencies/:id/resolve
Body: { resolutionType?: string, notes?: string }
Response: { success, data: { emergency } }
POST /help-requests
Body: {
title, description, category, location: { latitude, longitude },
urgency, estimatedDuration?, budget?
}
Response: { success, data: { helpRequest } }
GET /help-requests/my
Response: { success, data: { helpRequests } }
GET /help-requests/nearby?latitude=...&longitude=...&radius=...
Response: { success, data: { helpRequests } }
POST /help-requests/:id/respond
Body: { message }
Response: { success, data: { helpRequest } }
POST /help-requests/:id/responses/:helperId/accept
POST /help-requests/:id/responses/:helperId/deny
POST /help-requests/:id/responses/:helperId/report
Body (for report): { reason: string }
Response: { success, data: { helpRequest } }
POST /help-requests/:id/responses/:helperId/reply
Body: { message }
Response: { success, data: { helpRequest } }
POST /contact
Body: { category, subject, message }
Response: { success, message }
The trust score is a numerical representation of a user's reliability and helpfulness in the community, ranging from 0 to 1000.
| Action | Points | Description |
|---|---|---|
| Help Request Accepted | +10 | When a creator accepts a helper's response to their help request |
| SOS Response | +50 | When a helper accepts/responds to an SOS emergency |
| SOS Resolution | +50 | When a helper resolves an SOS emergency (additional to response points) |
| Action | Points | Description |
|---|---|---|
| Reported | -50 | When a helper is reported by a creator (minimum score: 0) |
Users can view their statistics on their profile:
- Trust Score: Current trust score (0-1000)
- Helped: Number of help requests where user's response was accepted
- Requested: Number of help requests created by user
- SOS Alerts: Number of emergencies created by user
- Reports: Number of times user was reported
- JWT-based Authentication: Secure token-based authentication
- Refresh Tokens: Long-lived refresh tokens with short-lived access tokens
- Password Hashing: bcrypt with 12 salt rounds
- Protected Routes: Middleware protection on all private endpoints
- Input Validation: express-validator on all endpoints
- CORS Configuration: Restrictive CORS policies
- Environment Variables: Sensitive data stored in environment variables
- SQL Injection Prevention: Mongoose ODM provides built-in protection
- Anonymous Mode: Users can create emergencies anonymously
- Silent Mode: Silent emergency notifications
- Location Privacy: Location only shared during active emergencies
- Fake Call Alert: Disguised emergency interface
AllyNet uses Socket.IO for real-time communication, particularly for emergency events.
/emergencies
Client β Server:
emergency:join- Join an emergency roomemergency:leave- Leave an emergency roommessage:send- Send a message in emergency chat
Server β Client:
emergency:created- New emergency created nearbyhelper:joined- Helper joined emergencyemergency:status_changed- Emergency status updatedemergency:resolved- Emergency resolvedmessage:received- New message in emergency chat
Socket connections are authenticated using JWT tokens sent during connection.
- Set environment variables on your hosting platform (Heroku, AWS, DigitalOcean, etc.)
- Build command: Not required (Node.js application)
- Start command:
npm start - Port: Use the
PORTenvironment variable (most platforms set this automatically)
-
Build the application:
cd AllyNet-front npm run build -
Deploy the
distfolder to your static hosting service:- Vercel
- Netlify
- AWS S3 + CloudFront
- GitHub Pages
- Any static file server
-
Configure API base URL: Update API endpoints in
src/api/*.jsto point to your production backend URL.
- Set
NODE_ENV=production - Use strong, unique JWT secrets
- Configure MongoDB Atlas or production MongoDB instance
- Set up CORS to allow only your frontend domain
- Enable HTTPS/SSL
- Set up error monitoring (e.g., Sentry)
- Configure backup strategy for MongoDB
- Set up SMS service (Twilio) for emergency contacts
- Test all critical features
- Set up logging and monitoring
- Hot Reload: Use
npm run dev(nodemon) - Health Check:
GET /api/health - Error Handling: Global error handler in
src/middleware/errorHandler.js - Logging: Console logging (consider adding Winston or similar in production)
- Hot Module Replacement: Vite provides instant HMR
- Linting:
npm run lint - Build:
npm run build - Preview:
npm run preview(preview production build locally)
- Backend: Follows MVC pattern with services layer for business logic
- Frontend: Feature-based organization with shared components
- State Management: Zustand for global state, local state for component-specific data
- Styling: Tailwind CSS utility classes with custom theme configuration
The smsService.js utility contains placeholder code for sending SMS notifications. To enable SMS functionality:
- Sign up for Twilio (or another SMS service)
- Add credentials to environment variables
- Implement the
sendEmergencySMSfunction inAllyNet-back/src/utils/smsService.js
The application uses MongoDB indexes for:
- User email (unique)
- User location (2dsphere for geospatial queries)
- Emergency location (2dsphere)
- Help request location (2dsphere)
- Various query optimizations
- Geospatial queries are indexed for fast location-based searches
- Socket.IO rooms are used to minimize broadcast traffic
- Aggregation pipelines are used for complex statistics queries
- Trust score calculations are optimized with proper indexing
This is a production application. When making changes:
- Test thoroughly in development
- Ensure all environment variables are documented
- Update this README if adding new features
- Follow existing code patterns and structure
- Test API endpoints and frontend components
This project is proprietary. All rights reserved.
For issues, questions, or feature requests:
- Use the Help Center feature in the application
- Contact the development team
- Review the About page in the application for more information
Status: π’ Production Ready
Last Updated: 2024
Version: 1.0.0