A NestJS backend for crime reporting and criminal tracking system. Users can view wanted criminals, report crimes with location data, and visualize crime statistics on a map.
- Authentication: JWT-based auth with role management (User/Admin)
- Wanted Criminals: View active wanted criminals with location data
- Crime Reports: Submit and track crime reports with GPS coordinates
- Location-based: All reports are tagged with district/city for mapping
- Role-based Access: Different permissions for users and admins
- Framework: NestJS
- Database: PostgreSQL (via Docker)
- ORM: TypeORM
- Authentication: JWT
- Language: TypeScript
- Node.js (v18 or higher)
- Docker and Docker Compose
- pnpm
- Install dependencies:
pnpm install- Start PostgreSQL database:
docker-compose up -d- Set up environment variables (create
.envfile):
DB_HOST=localhost
DB_PORT=5432
DB_USER=postgres
DB_PASSWORD=postgres
DB_NAME=crime_alert
JWT_SECRET=your-secret-key-here
JWT_EXPIRES_IN=1h
CLOUDINARY_NAME=your-cloud-name
CLOUDINARY_API_KEY=your-api-key
CLOUDINARY_API_SECRET=your-api-secret
NODE_ENV=development- Run the application:
pnpm run start:devThe server will start on http://localhost:3000
The application includes a scraper to fetch wanted criminals data.
# Scrape default 5 pages
pnpm run scraper
# Scrape specific number of pages
pnpm run scraper 10- Authentication and user management
- Role-based access (User/Admin)
- Publicly accessible criminal data
- Includes name, description, location, reward info
- User-submitted crime reports
- GPS coordinates, address, district, city
- Status tracking (active/investigating/resolved)
POST /auth/signup- Register new userPOST /auth/login- LoginPOST /auth/refresh- Refresh access tokenPUT /auth/change-password- Change password (protected)
The database schema will be automatically created when you run the app in development mode (synchronize: true).
# Watch mode
pnpm run start:dev
# Production build
pnpm run build
pnpm run start:prod
> **Note**: Ensure `CORS` is properly configured in `main.ts` for your production domain (e.g., `https://www.guardm.space`).
# Run tests
pnpm run testStart database:
docker-compose up -dStop database:
docker-compose downMIT