This repository contains a stand-alone, animated dashboard for visualizing MongoDB data, focusing on events/alerts and associated images from GridFS. It features a FastAPI backend for read-only data access and a Next.js frontend for a rich, interactive user experience.
This project was built by Jules, an AI software engineer.
- Project Overview
- Live Demo Preview
- Features
- Architecture
- Getting Started
- Project Structure
- API Endpoints
- Environment Variables
This dashboard provides a beautiful and performant interface for exploring event and image data stored in MongoDB. It is designed to be a stand-alone application that connects to an existing MongoDB database in a read-only capacity. The focus is on providing a polished UI with tasteful animations and a clear, intuitive presentation of data.
(This section would ideally contain screenshots or GIFs of the running application.)
Overview Page:
Alerts Page with Details Drawer:

- Dark/Light Mode: Seamless theme switching.
- Responsive Design: Works on all screen sizes, from mobile to desktop.
- Animated UI: Smooth, tasteful animations powered by Framer Motion.
- Containerized: Fully containerized with Docker for easy setup and deployment.
- KPI Cards: Key metrics (Total Alerts, 24h Alerts, etc.) with count-up animations.
- Time-series Chart: An interactive, animated chart from Recharts showing alert trends over time.
- Loading Skeletons: Polished loading states for a better user experience.
- Infinite Scroll: The alerts table uses a virtualized, infinite-scrolling mechanism to handle large datasets gracefully.
- Details Drawer: Click any alert to open an animated drawer with detailed information and a raw JSON view.
- Image Preview: For alerts with an associated image, a button opens a modal lightbox to display the full-resolution image, streamed directly from GridFS.
- Backend: A Python
FastAPIserver provides a read-only API over the MongoDB database. It usesmotorfor async database access,Pydanticfor data validation, andGridFSfor image streaming. - Frontend: A
Next.js(App Router) application built withTypeScript. It is styled withTailwind CSSandshadcn/ui. Animations are powered byFramer Motionand data fetching is managed byTanStack Query. - DevOps: The entire application is containerized using
Dockerand orchestrated withDocker Composefor easy, one-command local development.
- Docker and Docker Compose: For the recommended setup.
- Node.js & npm: For manual frontend setup.
- Python & pip: For manual backend setup.
- Access to a MongoDB instance: The application needs a database to connect to.
-
Clone the repository:
git clone <repository-url> cd <repository-directory>
-
Create your environment file: Copy the example environment file to a new
.envfile.cp .env.example .env
-
Configure your environment: Edit the
.envfile with yourMONGO_URIandMONGO_DBdetails. -
Build and run the containers:
docker-compose up --build
This command will build the Docker images for the API and the web app and start the services.
-
Access the application:
- Frontend:
http://localhost:3000 - API Docs:
http://localhost:8000/api/docs
- Frontend:
cd api
pip install -r requirements.txt
cp ../.env.example ../.env
# Edit .env with your MongoDB details
uvicorn main:app --reloadcd web
npm install
cp ../.env.example ../.env
# Edit .env with NEXT_PUBLIC_API_URL=http://localhost:8000
npm run dev.
├── api/ # FastAPI backend source
│ ├── routers/ # API endpoint routers
│ ├── models/ # Pydantic data models
│ ├── core/ # Configuration
│ ├── db/ # Database utilities
│ ├── Dockerfile
│ └── openapi.json # The generated OpenAPI schema
├── web/ # Next.js frontend source
│ ├── app/ # Next.js App Router pages
│ ├── components/ # Reusable React components
│ ├── hooks/ # Custom React Query hooks
│ ├── lib/ # Utility functions and API client
│ └── Dockerfile
├── .env.example # Template for environment variables
├── docker-compose.yml # Docker orchestration file
└── README.md # This file
The full, interactive API documentation is available via Swagger UI when the application is running at /api/docs. A static copy of the OpenAPI schema is also located at api/openapi.json.
Key endpoints include:
GET /api/v1/stats: Provides aggregated KPI data for the overview page.GET /api/v1/stats/over-time: Provides time-series data for the overview chart.GET /api/v1/alerts: Fetches a paginated list of alerts with filtering capabilities.GET /api/v1/images/by-image-id/{image_id}: Retrieves image metadata.GET /api/v1/images/{file_id}/bytes: Streams full-resolution image data from GridFS.GET /api/v1/images/{file_id}/thumb: Streams cached thumbnail data from GridFS.
All necessary environment variables are documented in the .env.example file.
| Variable | Description | Service |
|---|---|---|
MONGO_URI |
Your full MongoDB connection string. | API |
MONGO_DB |
The name of the MongoDB database to use. | API |
API_PORT |
The port the backend server will run on. | API |
ALLOWED_ORIGINS |
Comma-separated list of origins allowed to access the API. | API |
NEXT_PUBLIC_API_URL |
The public URL of the backend API, used by the frontend. | Web |
ALERTS_COLLECTION_NAME |
(Optional) The name of the alerts collection. Defaults to alerts. |
API |
GRIDFS_BUCKET_NAME |
(Optional) The name of the GridFS bucket. Defaults to fs. |
API |