How sujith123143/movie-application works
Purpose and entry points
This is a MERN movie-management and viewing application: a React/Vite client consumes an Express API for movies, genres, users, authentication, and uploads. Backend startup is backend/index.js; frontend bootstrap and application composition are frontend/src/main.jsx and frontend/src/App.jsx.
Backend HTTP layer
Express routes divide the API by domain: movies, genres, users, and uploads in backend/routes/moviesRoutes.js, backend/routes/genreRoutes.js, backend/routes/userRoutes.js, and backend/routes/uploadRoutes.js. These route modules are the principal boundary between the SPA and server-side application logic.
Controllers and request pipeline
Domain controllers implement API operations and coordinate persistence: backend/controllers/movieController.js, backend/controllers/genreController.js, and backend/controllers/userController.js. Shared middleware handles asynchronous controller failures, identity validation, and authorization before controllers execute: backend/middlewares/asyncHandler.js, backend/middlewares/checkId.js, and backend/middlewares/authMiddleware.js.
Persistence and authentication
MongoDB is the persistence runtime, initialized through backend/config/db.js. Mongoose-style domain records define the core data model in backend/models/Movie.js, backend/models/Genre.js, and backend/models/User.js. Authentication tokens are created in backend/utils/createToken.js and enforced at protected-route boundaries by backend/middlewares/authMiddleware.js.
Client state and API integration
The React client uses Redux Toolkit state plus an API layer. Store assembly is in frontend/src/redux/store.js; authentication state is maintained by frontend/src/redux/features/auth/authSlice.js; movie-specific local state is in frontend/src/redux/features/movies/moviesSlice.js. API endpoints are centralized through frontend/src/redux/api/apiSlice.js and domain endpoint modules such as frontend/src/redux/api/movies.js, frontend/src/redux/api/genre.js, and frontend/src/redux/api/users.js.
User-facing movie flows
Movie discovery, listing, cards, details, and related viewing UI are organized under frontend/src/pages/Movies/AllMovies.jsx, frontend/src/pages/Movies/MovieDetails.jsx, and frontend/src/pages/Movies/MovieTabs.jsx. These views fetch movie/genre/user data through the Redux API layer rather than directly owning backend logic.
Identity and administration boundaries
Authentication screens and client-side protected navigation reside in frontend/src/pages/Auth/Login.jsx, frontend/src/pages/Auth/Register.jsx, and frontend/src/pages/Auth/PrivateRoute.jsx. Administrative workflows—movie creation/editing, genre management, comment review, and dashboard presentation—are separated under frontend/src/pages/Admin/CreateMovie.jsx, frontend/src/pages/Admin/UpdateMovie.jsx, and frontend/src/pages/Admin/Dashboard/AdminDashboard.jsx. Client guards complement, but do not replace, backend token middleware.
Runtime and delivery shape
The frontend is a Vite React application (frontend/vite.config.js, frontend/package.json) styled with Tailwind configuration (frontend/tailwind.config.js). The backend is Node.js/Express with environment-driven settings in .env; it connects to MongoDB and exposes the API consumed by the independently built frontend.
Main entry points: apiSlice.js API client · App.jsx App composition · movieController.js Domain controllers · index.js Server startup
Components 19
React client
Vite SPA for viewing and administration.
- Client bootstrap
frontend/src/main.jsx - App composition
frontend/src/App.jsx - Movie viewing UI · Discovery, detail, and viewing tabs.
frontend/src/pages/Movies/AllMovies.jsx - Auth and route guard · Login, registration, and protected navigation.
frontend/src/pages/Auth/PrivateRoute.jsx - Admin workflows · Movie editing, genre management, comments, and dashboard.
frontend/src/pages/Admin/Dashboard/AdminDashboard.jsx - Redux store
frontend/src/redux/store.js - Auth and movie state · Client-local authentication and movie state.
frontend/src/redux/features/auth/authSlice.js - API client · Central API integration with movie, genre, and user endpoints.
frontend/src/redux/api/apiSlice.js
Express API
Node service exposing domain APIs.
- Server startup
backend/index.js - Domain routes · Movie, genre, user, and upload HTTP boundaries.
backend/routes/moviesRoutes.js - Request middleware · Async failure handling, ID validation, and authorization.
backend/middlewares/authMiddleware.js - Domain controllers · Movie, genre, and user API operations.
backend/controllers/movieController.js - Upload API
backend/routes/uploadRoutes.js
Data and auth
MongoDB-backed records and token identity.
- Token creation
backend/utils/createToken.js - Movie record
backend/models/Movie.js - Genre record
backend/models/Genre.js - User record
backend/models/User.js - MongoDB connection · Initializes the MongoDB persistence runtime.
backend/config/db.js - MongoDB
Connections 27
- Client bootstrap → App composition: mounts
- App composition → Movie viewing UI: renders
- App composition → Auth and route guard: routes to
- App composition → Admin workflows: routes to
- App composition → Redux store: provides
- Movie viewing UI → API client: queries
- Auth and route guard → Auth and movie state: uses
- Auth and route guard → API client: auth requests
- Admin workflows → API client: manages via
- Redux store → Auth and movie state: contains
- Redux store → API client: registers
- API client → Domain routes: HTTP API calls
- API client → Upload API: upload requests
- Server startup → Domain routes: mounts
- Server startup → Upload API: mounts
- Server startup → MongoDB connection: initializes
- Domain routes → Request middleware: protects and validates
- Request middleware → Domain controllers: permits
- Domain controllers → Movie record: reads and writes
- Domain controllers → Genre record: reads and writes
- Domain controllers → User record: reads and writes
- Domain controllers → Token creation: creates tokens
- Request middleware → Token creation: verifies tokens
- MongoDB connection → MongoDB: connects to
- Movie record → MongoDB: persists in
- Genre record → MongoDB: persists in
- User record → MongoDB: persists in