A comprehensive demonstration of ArangoDB's multimodal database capabilities, showcasing Document, Graph, and Key-Value operations in a single application.
- User Management: Create and manage user profiles with flexible JSON schemas
- Post System: Store blog posts, articles, or social media content
- Rich Queries: Query documents with complex filters and aggregations
- Social Relationships: Model follow relationships between users
- Interaction Tracking: Track likes, comments, and other user interactions
- Complex Graph Queries: Find mutual connections, recommendation algorithms, and social network analysis
- User Settings: Store user preferences and configuration
- Session Management: Fast key-value lookups for user sessions
- Caching Layer: Use as a high-performance cache for frequently accessed data
- Backend: Node.js with Express.js
- Database: ArangoDB (multimodal database)
- Frontend: Vanilla HTML/CSS/JavaScript
- Database Driver: ArangoJS
- ArangoDB: Install ArangoDB from https://www.arangodb.com/download/
- Node.js: Version 14+ required
- npm: Comes with Node.js
Download and install ArangoDB from the official website. The default installation will:
- Run on
http://localhost:8529 - Have username
rootwith no password (change this in production!)
npm installCopy the .env file and update if necessary:
# Default configuration should work for local ArangoDB installation
ARANGO_URL=http://localhost:8529
ARANGO_DATABASE=multimodal_demo
ARANGO_USERNAME=root
ARANGO_PASSWORD=
PORT=3000npm startThe app will:
- Automatically create the database and collections
- Set up the graph structure
- Start the web server on
http://localhost:3000
- Create Users: Add user profiles with username, display name, email, and bio
- Create Posts: Add posts with titles, content, and tags
- View All: Load and browse all users and posts
- Follow Users: Create follow relationships between users
- Like Posts: Add like relationships from users to posts
- Get User Feed: Retrieve posts from followed users (complex graph traversal)
- Popular Users: Find users with most followers
- Set Settings: Store user preferences like theme, notifications, etc.
- Get Settings: Retrieve specific user settings by key
- users: User profiles and metadata
- posts: Blog posts, articles, social media content
- user_settings: Key-value pairs for user preferences
- follows: User-to-User follow relationships
- likes: User-to-Post like relationships
- social_network: Combines all relationships for complex queries
{
"_key": "12345",
"username": "john_doe",
"displayName": "John Doe",
"email": "john@example.com",
"bio": "Software developer and ArangoDB enthusiast",
"followerCount": 42,
"followingCount": 15,
"createdAt": "2024-01-01T12:00:00Z"
}{
"_key": "67890",
"authorId": "12345",
"title": "Getting Started with ArangoDB",
"content": "ArangoDB is an amazing multimodal database...",
"tags": ["database", "arangodb", "tutorial"],
"likeCount": 23,
"createdAt": "2024-01-02T10:30:00Z"
}{
"_from": "users/12345",
"_to": "users/67890",
"createdAt": "2024-01-01T15:30:00Z"
}This query demonstrates ArangoDB's ability to traverse graphs and join documents:
FOR follow in follows
FILTER follow._from == "users/12345"
FOR post in posts
FILTER post.authorId == PARSE_IDENTIFIER(follow._to).key
SORT post.createdAt DESC
LIMIT 10
LET author = DOCUMENT(follow._to)
RETURN {
post: post,
author: {
username: author.username,
displayName: author.displayName
}
}Find mutual follows between two users:
LET user1_follows = (
FOR follow in follows
FILTER follow._from == "users/user1"
RETURN PARSE_IDENTIFIER(follow._to).key
)
LET user2_follows = (
FOR follow in follows
FILTER follow._from == "users/user2"
RETURN PARSE_IDENTIFIER(follow._to).key
)
LET mutual = INTERSECTION(user1_follows, user2_follows)
FOR userId in mutual
LET user = DOCUMENT('users', userId)
RETURN userPOST /api/users- Create userGET /api/users- Get all usersGET /api/users/:id- Get specific userPOST /api/posts- Create postGET /api/posts- Get all posts
POST /api/users/:followerId/follow/:followeeId- Follow userPOST /api/users/:userId/like/:postId- Like postGET /api/users/:userId/feed- Get user feedGET /api/users/popular- Get popular usersGET /api/users/:userId1/mutual/:userId2- Get mutual follows
POST /api/users/:userId/settings/:key- Set user settingGET /api/users/:userId/settings/:key- Get user setting
npm run devThis uses nodemon for automatic restarts when files change.
โโโ app.js # Main application server
โโโ database.js # ArangoDB connection and operations
โโโ package.json # Dependencies and scripts
โโโ .env # Environment configuration
โโโ public/
โ โโโ index.html # Demo web interface
โโโ README.md # This file
- Multiple Databases: Separate MongoDB for documents, Neo4j for graphs, Redis for caching
- Complex Architecture: Multiple connections, different query languages, data synchronization issues
- Performance Overhead: Network calls between different systems
- Unified Database: One system for all data models
- Single Query Language: AQL works across documents, graphs, and key-value data
- ACID Transactions: Consistent transactions across all data models
- Performance: Local joins and traversals, no network overhead
- Change default ArangoDB password
- Enable authentication and SSL
- Use environment variables for sensitive config
- Implement API rate limiting
- Add database indices for frequently queried fields
- Use connection pooling
- Implement caching strategies
- Monitor query performance
- Consider ArangoDB cluster deployment
- Implement horizontal scaling strategies
- Use ArangoDB's built-in sharding capabilities
Feel free to submit issues, fork the repository, and create pull requests for any improvements.
MIT License - see LICENSE file for details.
Happy coding with ArangoDB! ๐