A full-stack web application for managing songs and lyrics, built with React, GraphQL, Apollo Client, and MongoDB. Users can create songs, add lyrics to songs, and like individual lyrics.
- Song Management: Create, view, and delete songs
- Lyric System: Add lyrics to songs with real-time updates
- Interactive Likes: Like/unlike lyrics with optimistic UI updates
- GraphQL API: Efficient data fetching with GraphQL queries and mutations
- Real-time Updates: Apollo Client cache management for instant UI updates
- Responsive Design: Material Design components for modern UI
- React - UI library
- Apollo Client - GraphQL client with caching
- React Router - Client-side routing
- Material Design - UI components and styling
- Node.js - Runtime environment
- Express.js - Web framework
- GraphQL - Query language and API
- Express-GraphQL - GraphQL middleware
- MongoDB - NoSQL database
- Mongoose - MongoDB object modeling
- Webpack - Module bundler
- Babel - JavaScript transpiler
- Nodemon - Development server with hot reload
lyrical-graphql/
├── client/ # Frontend React application
│ ├── api/ # GraphQL queries and mutations
│ │ ├── mutations/ # GraphQL mutations
│ │ └── queries/ # GraphQL queries
│ ├── components/ # React components
│ │ ├── Layout/ # Layout components
│ │ └── pages/ # Page components
│ ├── style/ # CSS styles
│ └── index.js # Client entry point
├── server/ # Backend Node.js application
│ ├── models/ # Mongoose data models
│ ├── schema/ # GraphQL schema definitions
│ └── server.js # Express server setup
└── index.js # Application entry point
- Node.js (v14 or higher)
- MongoDB (local installation or MongoDB Atlas)
- npm or yarn
-
Clone the repository
git clone <repository-url> cd lyrical-graphql
-
Install dependencies
npm install --legacy-peer-deps
-
Configure MongoDB
- For local MongoDB: Ensure MongoDB is running on
mongodb://localhost:27017/lyricaldb - For MongoDB Atlas: Update the
MONGO_URIinserver/server.jswith your connection string
- For local MongoDB: Ensure MongoDB is running on
-
Start the development server
npm run dev
-
Access the application
- Frontend:
http://localhost:4000 - GraphQL Playground:
http://localhost:4000/graphql
- Frontend:
- Navigate to the home page
- Click the "+" floating action button
- Enter a song title and submit
- Click on any song from the list
- Add lyrics using the input field at the bottom
- Like/unlike lyrics by clicking the thumbs up icon
- View real-time like counts
Access the GraphQL playground at /graphql to explore:
Queries:
songs- Fetch all songssong(id: ID!)- Fetch a specific song with lyrics
Mutations:
addSong(title: String!)- Create a new songdeleteSong(id: ID!)- Delete a songaddLyricToSong(songId: ID!, content: String!)- Add lyric to songlikeLyric(id: ID!)- Like a lyric
- Song: Contains title and references to lyrics
- Lyric: Contains content, like count, and reference to parent song
- Type definitions for Song and Lyric entities
- Resolvers for queries and mutations
- Relationship handling between songs and lyrics
- Automatic caching and cache updates
- Optimistic UI updates for likes
- Query refetching after mutations
npm run dev- Start development server with hot reloadnpm start- Start production server
- Backend changes: Server auto-restarts with nodemon
- Frontend changes: Webpack hot reload updates the browser
- GraphQL schema: Available in GraphQL playground for testing
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
